feat: add AODH Image Saver (Metadata), Lora Selector, Checkpoint Selector, and various node improvements
This commit is contained in:
@@ -29,17 +29,20 @@ class ResolutionReader:
|
||||
return float("nan")
|
||||
return resolution
|
||||
|
||||
RETURN_TYPES = ("INT", "INT", "FLOAT")
|
||||
RETURN_NAMES = ("width", "height", "upscale")
|
||||
RETURN_TYPES = ("INT", "INT", "FLOAT", "INT")
|
||||
RETURN_NAMES = ("width", "height", "upscale", "total_resolutions")
|
||||
|
||||
FUNCTION = "read_resolution"
|
||||
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_resolution = None
|
||||
|
||||
def read_resolution(self, resolution, selection_mode, repeat_count):
|
||||
repeat_count = max(1, repeat_count)
|
||||
base_path = os.path.dirname(os.path.realpath(__file__))
|
||||
file_path = os.path.join(base_path, "resolutions", "resolutions.txt")
|
||||
|
||||
@@ -49,22 +52,33 @@ class ResolutionReader:
|
||||
lines = [line.strip() for line in f.readlines() if line.strip()]
|
||||
|
||||
if not lines:
|
||||
return (0, 0, 0.0)
|
||||
return (0, 0, 0.0, 0)
|
||||
|
||||
# Reset sequence if resolution changes
|
||||
if self.last_start_resolution != resolution:
|
||||
try:
|
||||
self.current_index = lines.index(resolution)
|
||||
except ValueError:
|
||||
self.current_index = 0
|
||||
self.current_count = 0
|
||||
self.last_start_resolution = resolution
|
||||
|
||||
if selection_mode == "manual":
|
||||
selected_line = resolution
|
||||
elif selection_mode == "sequential":
|
||||
if self.__class__._current_count >= repeat_count:
|
||||
self.__class__._current_index += 1
|
||||
self.__class__._current_count = 0
|
||||
selected_line = lines[self.__class__._current_index % len(lines)]
|
||||
self.__class__._current_count += 1
|
||||
if self.current_count >= repeat_count:
|
||||
self.current_index += 1
|
||||
self.current_count = 0
|
||||
selected_line = lines[self.current_index % len(lines)]
|
||||
self.current_count += 1
|
||||
elif selection_mode == "random":
|
||||
if self.__class__._current_count >= repeat_count or self.__class__._last_selection is None:
|
||||
self.__class__._last_selection = random.choice(lines)
|
||||
self.__class__._current_count = 0
|
||||
selected_line = self.__class__._last_selection
|
||||
self.__class__._current_count += 1
|
||||
if self.current_count >= repeat_count or self.last_selection is None:
|
||||
# Use a local Random instance to ensure randomness regardless of global seed
|
||||
rng = random.Random()
|
||||
self.last_selection = rng.choice(lines)
|
||||
self.current_count = 0
|
||||
selected_line = self.last_selection
|
||||
self.current_count += 1
|
||||
else:
|
||||
selected_line = resolution
|
||||
|
||||
@@ -74,6 +88,6 @@ class ResolutionReader:
|
||||
width = int(parts[0])
|
||||
height = int(parts[1])
|
||||
upscale = float(parts[2])
|
||||
return (width, height, upscale)
|
||||
return (width, height, upscale, len(lines))
|
||||
except (ValueError, IndexError):
|
||||
return (0, 0, 0.0)
|
||||
return (0, 0, 0.0, len(lines))
|
||||
|
||||
Reference in New Issue
Block a user