Hotfix for Issue #2

Updated node to fix "Folder_paths", corrected init.py to remove inactive nodes and updated requirements.txt to add colorama
This commit is contained in:
tusharbhutt
2023-10-03 17:03:30 -06:00
committed by GitHub
parent 80783644a3
commit e3fbba6edd
3 changed files with 44 additions and 43 deletions

View File

@@ -15,11 +15,11 @@ NODE_CLASS_MAPPINGS = {
"Endless Nodes Parameterizer & Prompts": EndlessNode_XLParameterizerPrompt,
"Endless Nodes Combo Parameterizer": EndlessNode_ComboXLParameterizer,
"Endless Nodes Combo Parameterizer & Prompts": EndlessNode_ComboXLParameterizerPrompt,
"Endless Nodes Image Save with Text File": EndlessNode_ImageSaver,
"Endless Nodes Image Saver with JSON": EndlessNode_ImageSaver,
"Endless Nodes Aesthetic Scoring": EndlessNode_Scoring,
"Endless Nodes Aesthetic Scoring Auto": EndlessNode_ScoringAutoScore,
# "Endless Nodes Aesthetic Scoring Auto": EndlessNode_ScoringAutoScore,
"Endless Nodes Image Reward": EndlessNode_ImageReward,
"Endless Nodes Image Reward Auto": EndlessNode_ImageRewardAutoScore,
# "Endless Nodes Image Reward Auto": EndlessNode_ImageRewardAutoScore,
"Endless Nodes Float to Integer": EndlessNode_FloattoInt,
"Endless Nodes Float to Number": EndlessNode_FloattoNum,
"Endless Nodes Float to String": EndlessNode_FloattoString,
@@ -29,9 +29,9 @@ NODE_CLASS_MAPPINGS = {
"Endless Nodes Integer to Float": EndlessNode_InttoFloat,
"Endless Nodes Integer to Number": EndlessNode_InttoNum,
"Endless Nodes Integer to String": EndlessNode_InttoString,
"Endless Nodes Float to X": EndlessNode_FloattoX,
"Endless Nodes Integer to X": EndlessNode_InttoX,
"Endless Nodes Number to X": EndlessNode_NumtoX,
# "Endless Nodes Float to X": EndlessNode_FloattoX,
# "Endless Nodes Integer to X": EndlessNode_InttoX,
# "Endless Nodes Number to X": EndlessNode_NumtoX,
}

View File

@@ -34,7 +34,7 @@ import ImageReward as RM
import clip
import colorama
import datetime
import folder_paths as endless_paths
import folder_paths
import io
import json
import math
@@ -559,49 +559,49 @@ class EndlessNode_ImageReward:
return (score, str(score), valuescale, str(valuescale))
# #---------------------------------------------- NOT WORKING, NEED TO LOOK AT
# # Image Reward Scoring with score passed to image
#---------------------------------------------- NOT WORKING, NEED TO LOOK AT
# Image Reward Scoring with score passed to image
# class EndlessNode_ImageRewardAutoScore:
# def __init__(self):
# self.model = None
class EndlessNode_ImageRewardAutoScore:
def __init__(self):
self.model = None
# @classmethod
# def INPUT_TYPES(cls):
# return {
# "required": {
# "model": ("STRING", {"multiline": False, "default": "ImageReward-v1.0"}),
# "prompt": ("STRING", {"multiline": True, "forceInput": True}),
# "images": ("IMAGE",),
# },
# }
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"model": ("STRING", {"multiline": False, "default": "ImageReward-v1.0"}),
"prompt": ("STRING", {"multiline": True, "forceInput": True}),
"images": ("IMAGE",),
},
}
# RETURN_TYPES = ("FLOAT", "STRING", "FLOAT", "STRING", "IMAGE")
# RETURN_NAMES = ("SCORE_FLOAT", "SCORE_STRING", "VALUE_FLOAT", "VALUE_STRING", "TO_IMAGE")
# OUTPUT_NODE = True
RETURN_TYPES = ("FLOAT", "STRING", "FLOAT", "STRING", "IMAGE")
RETURN_NAMES = ("SCORE_FLOAT", "SCORE_STRING", "VALUE_FLOAT", "VALUE_STRING", "TO_IMAGE")
OUTPUT_NODE = True
# CATEGORY = "Endless 🌌/Scoring"
CATEGORY = "Endless 🌌/Scoring"
# FUNCTION = "score_meta"
FUNCTION = "score_meta"
# def score_meta(self, model, prompt, images):
# if self.model is None:
# self.model = RM.load(model)
def score_meta(self, model, prompt, images):
if self.model is None:
self.model = RM.load(model)
# # Scoring part
# score = 0.0
# for image in images:
# i = 255.0 * image.cpu().numpy()
# img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
# score += self.model.score(prompt, [img])
# score /= len(images)
# valuescale = 0.5 * (1 + math.erf(score / math.sqrt(2))) * 10
# Scoring part
score = 0.0
for image in images:
i = 255.0 * image.cpu().numpy()
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
score += self.model.score(prompt, [img])
score /= len(images)
valuescale = 0.5 * (1 + math.erf(score / math.sqrt(2))) * 10
# # Metadata part
# extra_pnginfo = {"SCORE": str(score)}
# Metadata part
extra_pnginfo = {"SCORE": str(score)}
# # Returning both the score and the modified image
# return (score, str(score), valuescale, str(valuescale), images)
# Returning both the score and the modified image
return (score, str(score), valuescale, str(valuescale), images)
# ______________________________________________________________________________________________________________________________________________________________
# IMAGE SAVERS BLOCK #
@@ -612,7 +612,7 @@ class EndlessNode_ImageReward:
class EndlessNode_ImageSaver:
def __init__(self):
self.output_dir = endless_paths.get_output_directory()
self.output_dir = folder_paths.get_output_directory()
self.type = "output"
@classmethod

View File

@@ -1,3 +1,4 @@
clip
pytorch-lightning
image-reward==1.4
image-reward==1.4
colorama