feat: add AODH Image Saver (Metadata), Lora Selector, Checkpoint Selector, and various node improvements
This commit is contained in:
@@ -30,45 +30,59 @@ class CharacterJsonReader:
|
||||
"STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING",
|
||||
"STRING", "STRING", "STRING", "STRING", "STRING", "STRING",
|
||||
"STRING", "STRING", "STRING", "STRING",
|
||||
"STRING", "FLOAT", "STRING"
|
||||
"STRING", "FLOAT", "STRING", "INT"
|
||||
)
|
||||
RETURN_NAMES = (
|
||||
"name", "base_specs", "hair", "eyes", "expression", "hands", "arms", "torso", "pelvis", "legs", "feet", "distinguishing_marks",
|
||||
"inner_layer", "outer_layer", "lower_body", "footwear", "gloves", "accessories",
|
||||
"aesthetic", "primary_color", "secondary_color", "tertiary_color",
|
||||
"lora_name", "lora_weight", "lora_triggers"
|
||||
"lora_name", "lora_weight", "lora_triggers", "total_characters"
|
||||
)
|
||||
|
||||
FUNCTION = "read_character"
|
||||
CATEGORY = "AODH Pack"
|
||||
|
||||
_current_index = 0
|
||||
_current_count = 0
|
||||
_last_selection = None
|
||||
def __init__(self):
|
||||
self.current_index = 0
|
||||
self.current_count = 0
|
||||
self.last_selection = None
|
||||
self.last_start_file = None
|
||||
|
||||
def read_character(self, character_file, selection_mode, repeat_count):
|
||||
repeat_count = max(1, repeat_count)
|
||||
base_path = os.path.dirname(os.path.realpath(__file__))
|
||||
char_dir = os.path.join(base_path, "characters")
|
||||
|
||||
characters = sorted([f for f in os.listdir(char_dir) if f.endswith('.json')])
|
||||
|
||||
if not characters:
|
||||
return ("",) * 22 + ("", 0.0, "")
|
||||
return ("",) * 22 + ("", 0.0, "", 0)
|
||||
|
||||
# Reset sequence if character_file changes
|
||||
if self.last_start_file != character_file:
|
||||
try:
|
||||
self.current_index = characters.index(character_file)
|
||||
except ValueError:
|
||||
self.current_index = 0
|
||||
self.current_count = 0
|
||||
self.last_start_file = character_file
|
||||
|
||||
if selection_mode == "manual":
|
||||
selected_file = character_file
|
||||
elif selection_mode == "sequential":
|
||||
if self.__class__._current_count >= repeat_count:
|
||||
self.__class__._current_index += 1
|
||||
self.__class__._current_count = 0
|
||||
selected_file = characters[self.__class__._current_index % len(characters)]
|
||||
self.__class__._current_count += 1
|
||||
if self.current_count >= repeat_count:
|
||||
self.current_index += 1
|
||||
self.current_count = 0
|
||||
selected_file = characters[self.current_index % len(characters)]
|
||||
self.current_count += 1
|
||||
elif selection_mode == "random":
|
||||
if self.__class__._current_count >= repeat_count or self.__class__._last_selection is None or self.__class__._last_selection not in characters:
|
||||
self.__class__._last_selection = random.choice(characters)
|
||||
self.__class__._current_count = 0
|
||||
selected_file = self.__class__._last_selection
|
||||
self.__class__._current_count += 1
|
||||
if self.current_count >= repeat_count or self.last_selection is None or self.last_selection not in characters:
|
||||
# Use a local Random instance to ensure randomness regardless of global seed
|
||||
rng = random.Random()
|
||||
self.last_selection = rng.choice(characters)
|
||||
self.current_count = 0
|
||||
selected_file = self.last_selection
|
||||
self.current_count += 1
|
||||
else:
|
||||
selected_file = character_file
|
||||
|
||||
@@ -114,4 +128,5 @@ class CharacterJsonReader:
|
||||
get_val(lora, "lora_name", prepend_comma=False),
|
||||
float(lora.get("lora_weight", 0.0) if lora.get("lora_weight") else 0.0),
|
||||
get_val(lora, "lora_triggers"),
|
||||
len(characters),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user