Added the RS MultiPatent node
This commit is contained in:
+143
-209
@@ -1,117 +1,82 @@
|
||||
import torch
|
||||
import math
|
||||
|
||||
class RS_multilatent:
|
||||
class RS_Image_MultiLatent:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"vae": ("VAE",),
|
||||
"size_mode": (["Preset", "Custom", "Megapixels"],),
|
||||
"preset": (
|
||||
"active_preset": (["Standard", "Qwen", "Krea2"], {"default": "Standard"}),
|
||||
"preset_standard": (
|
||||
[
|
||||
"Square - 512x512 (1:1)",
|
||||
"Square - 640x640 (1:1)",
|
||||
"Square - 768x768 (1:1)",
|
||||
"Square - 1008x1008 (1:1)",
|
||||
"Square - 1024x1024 (1:1)",
|
||||
"Square - 1120x1120 (1:1)",
|
||||
"Square - 1280x1280 (1:1)",
|
||||
"Square - 1344x1344 (1:1)",
|
||||
"Square - 1536x1536 (1:1)",
|
||||
"Square - 1568x1568 (1:1)",
|
||||
"Square - 1792x1792 (1:1)",
|
||||
"Square - 512x512 (1:1)", "Square - 640x640 (1:1)", "Square - 768x768 (1:1)",
|
||||
"Square - 1024x1024 (1:1)", "Square - 1280x1280 (1:1)", "Square - 1536x1536 (1:1)",
|
||||
"Square - 1920x1920 (1:1)",
|
||||
"Square - 2016x2016 (1:1)",
|
||||
"Portrait - 480x640 (3:4)",
|
||||
"Portrait - 512x768 (3:2)",
|
||||
"Portrait - 768x1024 (3:4)",
|
||||
"Portrait - 864x1152 (3:4)",
|
||||
"Portrait - 896x1120 (4:5)",
|
||||
"Portrait - 896x1344 (2:3)",
|
||||
"Portrait - 960x1280 (3:4)",
|
||||
"Portrait - 768x1152 (2:3)",
|
||||
"Portrait - 1008x1344 (3:4)",
|
||||
"Portrait - 1008x1792 (9:16)",
|
||||
"Portrait - 768x1344 (9:16)",
|
||||
"Portrait - 832x1152 (3:4)",
|
||||
"Portrait - 832x1216 (13:19)",
|
||||
"Portrait - 896x1088 (14:17)",
|
||||
"Portrait - 896x1152 (7:9)",
|
||||
"Portrait - 960x1024 (15:16)",
|
||||
"Portrait - 960x1088 (15:17)",
|
||||
"Portrait - 1024x1280 (4:5)",
|
||||
"Portrait - 1120x1456 (10:13)",
|
||||
"Portrait - 1120x1680 (2:3)",
|
||||
"Portrait - 1120x1792 (5:8)",
|
||||
"Portrait - 1120x1904 (10:17)",
|
||||
"Portrait - 1120x2016 (5:6)",
|
||||
"Portrait - 1120x2240 (1:2)",
|
||||
"Portrait - 1232x2016 (11:18)",
|
||||
"Portrait - 1232x2464 (1:2)",
|
||||
"Portrait - 1280x1536 (5:6)",
|
||||
"Portrait - 1344x1728 (7:9)",
|
||||
"Portrait - 1344x1792 (3:4)",
|
||||
"Portrait - 1344x2016 (2:3)",
|
||||
"Portrait - 1344x2240 (3:5)",
|
||||
"Portrait - 1344x2688 (1:2)",
|
||||
"Portrait - 1440x1920 (3:4)",
|
||||
"Portrait - 1456x1792 (13:16)",
|
||||
"Portrait - 1456x2912 (1:2)",
|
||||
"Portrait - 1568x2352 (2:3)",
|
||||
"Portrait - 1680x2016 (5:6)",
|
||||
"Portrait - 1680x2240 (3:4)",
|
||||
"Portrait - 480x640 (3:4)", "Portrait - 512x768 (3:2)", "Portrait - 768x1024 (3:4)",
|
||||
"Portrait - 864x1152 (3:4)", "Portrait - 960x1280 (3:4)", "Portrait - 768x1152 (2:3)",
|
||||
"Portrait - 896x1344 (2:3)", "Portrait - 768x1344 (9:16)", "Portrait - 832x1152 (3:4)",
|
||||
"Portrait - 832x1216 (13:19)", "Portrait - 896x1088 (14:17)", "Portrait - 896x1152 (7:9)",
|
||||
"Portrait - 960x1024 (15:16)", "Portrait - 960x1088 (15:17)", "Portrait - 1024x1280 (4:5)",
|
||||
"Portrait - 1280x1536 (5:6)", "Portrait - 1344x1728 (7:9)", "Portrait - 1440x1920 (3:4)",
|
||||
"Portrait - 1024x1536 (2:3)", "Portrait - 1088x1856 (~6:10)", "Portrait - 1280x1920 (2:3)",
|
||||
"Portrait - 1080x1920 (9:16)", "Portrait - 816x1920 (21:9)",
|
||||
"Landscape - 640x480 (4:3)", "Landscape - 768x512 (3:2)", "Landscape - 1024x768 (4:3)",
|
||||
"Landscape - 1280x864 (4:3)", "Landscape - 1280x960 (4:3)", "Landscape - 1152x768 (3:2)",
|
||||
"Landscape - 1344x896 (3:2)", "Landscape - 1344x768 (7:4)", "Landscape - 1152x832 (9:7)",
|
||||
"Landscape - 1216x832 (19:13)", "Landscape - 1088x896 (17:14)", "Landscape - 1152x896 (9:7)",
|
||||
"Landscape - 1024x960 (16:15)", "Landscape - 1088x960 (17:15)", "Landscape - 1280x1024 (5:4)",
|
||||
"Landscape - 1536x1280 (6:5)", "Landscape - 1728x1344 (9:7)", "Landscape - 1920x1440 (4:3)",
|
||||
"Landscape - 1536x1024 (3:2)", "Landscape - 1856x1088 (~16:9)", "Landscape - 1920x1280 (3:2)",
|
||||
"Landscape - 1920x1080 (16:9)", "Landscape - 1920x1024 (15:8)", "Landscape - 1920x816 (20:9)",
|
||||
],
|
||||
{"default": "Square - 1024x1024 (1:1)"}
|
||||
),
|
||||
"preset_qwen": (
|
||||
[
|
||||
"Square - 1008x1008 (1:1)", "Square - 1120x1120 (1:1)", "Square - 1344x1344 (1:1)",
|
||||
"Square - 1568x1568 (1:1)", "Square - 1792x1792 (1:1)", "Square - 2016x2016 (1:1)",
|
||||
"Portrait - 896x1120 (4:5)", "Portrait - 896x1344 (2:3)", "Portrait - 1008x1344 (3:4)",
|
||||
"Portrait - 1008x1792 (9:16)", "Portrait - 1120x1456 (10:13)", "Portrait - 1120x1680 (2:3)",
|
||||
"Portrait - 1120x1792 (5:8)", "Portrait - 1120x1904 (10:17)", "Portrait - 1120x2016 (5:6)",
|
||||
"Portrait - 1120x2240 (1:2)", "Portrait - 1232x2016 (11:18)", "Portrait - 1232x2464 (1:2)",
|
||||
"Portrait - 1344x1792 (3:4)", "Portrait - 1344x2016 (2:3)", "Portrait - 1344x2240 (3:5)",
|
||||
"Portrait - 1344x2688 (1:2)", "Portrait - 1456x1792 (13:16)", "Portrait - 1456x2912 (1:2)",
|
||||
"Portrait - 1568x2352 (2:3)", "Portrait - 1680x2016 (5:6)", "Portrait - 1680x2240 (3:4)",
|
||||
"Portrait - 1792x2240 (4:5)",
|
||||
"Portrait - 1024x1536 (2:3)",
|
||||
"Portrait - 1088x1856 (~6:10)",
|
||||
"Portrait - 1280x1920 (2:3)",
|
||||
"Portrait - 1080x1920 (9:16)",
|
||||
"Portrait - 816x1920 (21:9)",
|
||||
"Landscape - 640x480 (4:3)",
|
||||
"Landscape - 768x512 (3:2)",
|
||||
"Landscape - 1024x768 (4:3)",
|
||||
"Landscape - 1120x896 (5:4)",
|
||||
"Landscape - 1280x864 (4:3)",
|
||||
"Landscape - 1280x960 (4:3)",
|
||||
"Landscape - 1152x768 (3:2)",
|
||||
"Landscape - 1344x896 (3:2)",
|
||||
"Landscape - 1344x768 (7:4)",
|
||||
"Landscape - 1344x1008 (4:3)",
|
||||
"Landscape - 1792x1008 (16:9)",
|
||||
"Landscape - 1152x832 (9:7)",
|
||||
"Landscape - 1216x832 (19:13)",
|
||||
"Landscape - 1088x896 (17:14)",
|
||||
"Landscape - 1152x896 (9:7)",
|
||||
"Landscape - 1024x960 (16:15)",
|
||||
"Landscape - 1088x960 (17:15)",
|
||||
"Landscape - 1280x1024 (5:4)",
|
||||
"Landscape - 1456x1120 (13:10)",
|
||||
"Landscape - 1536x1280 (6:5)",
|
||||
"Landscape - 1680x1120 (3:2)",
|
||||
"Landscape - 1728x1344 (9:7)",
|
||||
"Landscape - 1792x1120 (8:5)",
|
||||
"Landscape - 1904x1120 (17:10)",
|
||||
"Landscape - 1920x1440 (4:3)",
|
||||
"Landscape - 2016x1120 (6:5)",
|
||||
"Landscape - 2240x1120 (2:1)",
|
||||
"Landscape - 2016x1232 (18:11)",
|
||||
"Landscape - 2464x1232 (2:1)",
|
||||
"Landscape - 1536x1024 (3:2)",
|
||||
"Landscape - 1792x1344 (4:3)",
|
||||
"Landscape - 2016x1344 (3:2)",
|
||||
"Landscape - 2240x1344 (5:3)",
|
||||
"Landscape - 2688x1344 (2:1)",
|
||||
"Landscape - 1792x1456 (16:13)",
|
||||
"Landscape - 2912x1456 (2:1)",
|
||||
"Landscape - 1856x1088 (~16:9)",
|
||||
"Landscape - 1920x1280 (3:2)",
|
||||
"Landscape - 2352x1568 (3:2)",
|
||||
"Landscape - 2016x1680 (6:5)",
|
||||
"Landscape - 2240x1680 (4:3)",
|
||||
"Landscape - 1120x896 (5:4)", "Landscape - 1344x896 (3:2)", "Landscape - 1344x1008 (4:3)",
|
||||
"Landscape - 1792x1008 (16:9)", "Landscape - 1456x1120 (13:10)", "Landscape - 1680x1120 (3:2)",
|
||||
"Landscape - 1792x1120 (8:5)", "Landscape - 1904x1120 (17:10)", "Landscape - 2016x1120 (6:5)",
|
||||
"Landscape - 2240x1120 (2:1)", "Landscape - 2016x1232 (18:11)", "Landscape - 2464x1232 (2:1)",
|
||||
"Landscape - 1792x1344 (4:3)", "Landscape - 2016x1344 (3:2)", "Landscape - 2240x1344 (5:3)",
|
||||
"Landscape - 2688x1344 (2:1)", "Landscape - 1792x1456 (16:13)", "Landscape - 2912x1456 (2:1)",
|
||||
"Landscape - 2352x1568 (3:2)", "Landscape - 2016x1680 (6:5)", "Landscape - 2240x1680 (4:3)",
|
||||
"Landscape - 2240x1792 (5:4)",
|
||||
"Landscape - 1920x1080 (16:9)",
|
||||
"Landscape - 1920x1024 (15:8)",
|
||||
"Landscape - 1920x816 (20:9)",
|
||||
],
|
||||
{"default": "Square - 1008x1008 (1:1)"}
|
||||
),
|
||||
"preset_krea2": (
|
||||
[
|
||||
"Square - 512x512 (1:1)", "Square - 640x640 (1:1)", "Square - 768x768 (1:1)",
|
||||
"Square - 1024x1024 (1:1)", "Square - 1280x1280 (1:1)", "Square - 1536x1536 (1:1)",
|
||||
"Square - 1920x1920 (1:1)",
|
||||
"Portrait - 480x640 (3:4)", "Portrait - 512x768 (3:2)", "Portrait - 768x1024 (3:4)",
|
||||
"Portrait - 864x1152 (3:4)", "Portrait - 960x1280 (3:4)", "Portrait - 768x1152 (2:3)",
|
||||
"Portrait - 896x1344 (2:3)", "Portrait - 768x1344 (9:16)", "Portrait - 832x1152 (3:4)",
|
||||
"Portrait - 832x1216 (13:19)", "Portrait - 896x1088 (14:17)", "Portrait - 896x1152 (7:9)",
|
||||
"Portrait - 960x1024 (15:16)", "Portrait - 960x1088 (15:17)", "Portrait - 1024x1280 (4:5)",
|
||||
"Portrait - 1280x1536 (5:6)", "Portrait - 1344x1728 (7:9)", "Portrait - 1440x1920 (3:4)",
|
||||
"Portrait - 1024x1536 (2:3)", "Portrait - 1088x1856 (~6:10)", "Portrait - 1280x1920 (2:3)",
|
||||
"Portrait - 1080x1920 (9:16)", "Portrait - 816x1920 (21:9)",
|
||||
"Landscape - 640x480 (4:3)", "Landscape - 768x512 (3:2)", "Landscape - 1024x768 (4:3)",
|
||||
"Landscape - 1280x864 (4:3)", "Landscape - 1280x960 (4:3)", "Landscape - 1152x768 (3:2)",
|
||||
"Landscape - 1344x896 (3:2)", "Landscape - 1344x768 (7:4)", "Landscape - 1152x832 (9:7)",
|
||||
"Landscape - 1216x832 (19:13)", "Landscape - 1088x896 (17:14)", "Landscape - 1152x896 (9:7)",
|
||||
"Landscape - 1024x960 (16:15)", "Landscape - 1088x960 (17:15)", "Landscape - 1280x1024 (5:4)",
|
||||
"Landscape - 1536x1280 (6:5)", "Landscape - 1728x1344 (9:7)", "Landscape - 1920x1440 (4:3)",
|
||||
"Landscape - 1536x1024 (3:2)", "Landscape - 1856x1088 (~16:9)", "Landscape - 1920x1280 (3:2)",
|
||||
"Landscape - 1920x1080 (16:9)", "Landscape - 1920x1024 (15:8)", "Landscape - 1920x816 (20:9)",
|
||||
],
|
||||
{"default": "Square - 1024x1024 (1:1)"}
|
||||
),
|
||||
@@ -123,12 +88,13 @@ class RS_multilatent:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("LATENT", "INT", "INT", "INT", "INT")
|
||||
RETURN_NAMES = ("latent", "width_px", "height_px", "width_latent", "height_latent")
|
||||
RETURN_TYPES = ("LATENT", "INT", "INT")
|
||||
RETURN_NAMES = ("latent", "width_px", "height_px")
|
||||
FUNCTION = "generate"
|
||||
CATEGORY = "🦊 RaykoStudio"
|
||||
|
||||
def generate(self, vae, size_mode, preset, width, height, megapixels, aspect_ratio, batch_size):
|
||||
def generate(self, vae, size_mode, active_preset, preset_standard, preset_qwen, preset_krea2, width, height, megapixels, aspect_ratio, batch_size):
|
||||
# Определение параметров из VAE
|
||||
latent_channels = 4
|
||||
scale_factor = 8
|
||||
|
||||
@@ -147,110 +113,80 @@ class RS_multilatent:
|
||||
except:
|
||||
pass
|
||||
|
||||
# Валидация
|
||||
if latent_channels <= 0 or latent_channels > 256:
|
||||
raise ValueError(f"Invalid latent_channels: {latent_channels}")
|
||||
if scale_factor <= 0 or scale_factor > 64:
|
||||
raise ValueError(f"Invalid scale_factor: {scale_factor}")
|
||||
|
||||
print(f"[RS_Image_MultiLatent] VAE: {latent_channels} channels, {scale_factor}x scale. Active: {active_preset}")
|
||||
|
||||
# Расчёт размеров
|
||||
if size_mode == "Preset":
|
||||
# Выбираем значение из активного списка
|
||||
if active_preset == "Standard":
|
||||
preset = preset_standard
|
||||
elif active_preset == "Qwen":
|
||||
preset = preset_qwen
|
||||
else:
|
||||
preset = preset_krea2
|
||||
|
||||
size_map = {
|
||||
"Square - 512x512 (1:1)": (512, 512),
|
||||
"Square - 640x640 (1:1)": (640, 640),
|
||||
"Square - 768x768 (1:1)": (768, 768),
|
||||
"Square - 1008x1008 (1:1)": (1008, 1008),
|
||||
"Square - 1024x1024 (1:1)": (1024, 1024),
|
||||
"Square - 1120x1120 (1:1)": (1120, 1120),
|
||||
"Square - 1280x1280 (1:1)": (1280, 1280),
|
||||
"Square - 1344x1344 (1:1)": (1344, 1344),
|
||||
"Square - 1536x1536 (1:1)": (1536, 1536),
|
||||
"Square - 1568x1568 (1:1)": (1568, 1568),
|
||||
"Square - 1792x1792 (1:1)": (1792, 1792),
|
||||
# Standard & Krea2 (одинаковые размеры)
|
||||
"Square - 512x512 (1:1)": (512, 512), "Square - 640x640 (1:1)": (640, 640),
|
||||
"Square - 768x768 (1:1)": (768, 768), "Square - 1024x1024 (1:1)": (1024, 1024),
|
||||
"Square - 1280x1280 (1:1)": (1280, 1280), "Square - 1536x1536 (1:1)": (1536, 1536),
|
||||
"Square - 1920x1920 (1:1)": (1920, 1920),
|
||||
"Square - 2016x2016 (1:1)": (2016, 2016),
|
||||
"Portrait - 480x640 (3:4)": (480, 640),
|
||||
"Portrait - 512x768 (3:2)": (512, 768),
|
||||
"Portrait - 768x1024 (3:4)": (768, 1024),
|
||||
"Portrait - 864x1152 (3:4)": (864, 1152),
|
||||
"Portrait - 896x1120 (4:5)": (896, 1120),
|
||||
"Portrait - 896x1344 (2:3)": (896, 1344),
|
||||
"Portrait - 960x1280 (3:4)": (960, 1280),
|
||||
"Portrait - 768x1152 (2:3)": (768, 1152),
|
||||
"Portrait - 1008x1344 (3:4)": (1008, 1344),
|
||||
"Portrait - 1008x1792 (9:16)": (1008, 1792),
|
||||
"Portrait - 768x1344 (9:16)": (768, 1344),
|
||||
"Portrait - 832x1152 (3:4)": (832, 1152),
|
||||
"Portrait - 832x1216 (13:19)": (832, 1216),
|
||||
"Portrait - 896x1088 (14:17)": (896, 1088),
|
||||
"Portrait - 896x1152 (7:9)": (896, 1152),
|
||||
"Portrait - 960x1024 (15:16)": (960, 1024),
|
||||
"Portrait - 960x1088 (15:17)": (960, 1088),
|
||||
"Portrait - 1024x1280 (4:5)": (1024, 1280),
|
||||
"Portrait - 1120x1456 (10:13)": (1120, 1456),
|
||||
"Portrait - 1120x1680 (2:3)": (1120, 1680),
|
||||
"Portrait - 1120x1792 (5:8)": (1120, 1792),
|
||||
"Portrait - 1120x1904 (10:17)": (1120, 1904),
|
||||
"Portrait - 1120x2016 (5:6)": (1120, 2016),
|
||||
"Portrait - 1120x2240 (1:2)": (1120, 2240),
|
||||
"Portrait - 1232x2016 (11:18)": (1232, 2016),
|
||||
"Portrait - 1232x2464 (1:2)": (1232, 2464),
|
||||
"Portrait - 1280x1536 (5:6)": (1280, 1536),
|
||||
"Portrait - 1344x1728 (7:9)": (1344, 1728),
|
||||
"Portrait - 1344x1792 (3:4)": (1344, 1792),
|
||||
"Portrait - 1344x2016 (2:3)": (1344, 2016),
|
||||
"Portrait - 1344x2240 (3:5)": (1344, 2240),
|
||||
"Portrait - 1344x2688 (1:2)": (1344, 2688),
|
||||
"Portrait - 1440x1920 (3:4)": (1440, 1920),
|
||||
"Portrait - 1456x1792 (13:16)": (1456, 1792),
|
||||
"Portrait - 1456x2912 (1:2)": (1456, 2912),
|
||||
"Portrait - 1568x2352 (2:3)": (1568, 2352),
|
||||
"Portrait - 1680x2016 (5:6)": (1680, 2016),
|
||||
"Portrait - 1680x2240 (3:4)": (1680, 2240),
|
||||
"Portrait - 1792x2240 (4:5)": (1792, 2240),
|
||||
"Portrait - 1024x1536 (2:3)": (1024, 1536),
|
||||
"Portrait - 1088x1856 (~6:10)": (1088, 1856),
|
||||
"Portrait - 1280x1920 (2:3)": (1280, 1920),
|
||||
"Portrait - 1080x1920 (9:16)": (1080, 1920),
|
||||
"Portrait - 480x640 (3:4)": (480, 640), "Portrait - 512x768 (3:2)": (512, 768),
|
||||
"Portrait - 768x1024 (3:4)": (768, 1024), "Portrait - 864x1152 (3:4)": (864, 1152),
|
||||
"Portrait - 960x1280 (3:4)": (960, 1280), "Portrait - 768x1152 (2:3)": (768, 1152),
|
||||
"Portrait - 896x1344 (2:3)": (896, 1344), "Portrait - 768x1344 (9:16)": (768, 1344),
|
||||
"Portrait - 832x1152 (3:4)": (832, 1152), "Portrait - 832x1216 (13:19)": (832, 1216),
|
||||
"Portrait - 896x1088 (14:17)": (896, 1088), "Portrait - 896x1152 (7:9)": (896, 1152),
|
||||
"Portrait - 960x1024 (15:16)": (960, 1024), "Portrait - 960x1088 (15:17)": (960, 1088),
|
||||
"Portrait - 1024x1280 (4:5)": (1024, 1280), "Portrait - 1280x1536 (5:6)": (1280, 1536),
|
||||
"Portrait - 1344x1728 (7:9)": (1344, 1728), "Portrait - 1440x1920 (3:4)": (1440, 1920),
|
||||
"Portrait - 1024x1536 (2:3)": (1024, 1536), "Portrait - 1088x1856 (~6:10)": (1088, 1856),
|
||||
"Portrait - 1280x1920 (2:3)": (1280, 1920), "Portrait - 1080x1920 (9:16)": (1080, 1920),
|
||||
"Portrait - 816x1920 (21:9)": (816, 1920),
|
||||
"Landscape - 640x480 (4:3)": (640, 480),
|
||||
"Landscape - 768x512 (3:2)": (768, 512),
|
||||
"Landscape - 1024x768 (4:3)": (1024, 768),
|
||||
"Landscape - 1120x896 (5:4)": (1120, 896),
|
||||
"Landscape - 1280x864 (4:3)": (1280, 864),
|
||||
"Landscape - 1280x960 (4:3)": (1280, 960),
|
||||
"Landscape - 1152x768 (3:2)": (1152, 768),
|
||||
"Landscape - 1344x896 (3:2)": (1344, 896),
|
||||
"Landscape - 1344x768 (7:4)": (1344, 768),
|
||||
"Landscape - 1344x1008 (4:3)": (1344, 1008),
|
||||
"Landscape - 1792x1008 (16:9)": (1792, 1008),
|
||||
"Landscape - 1152x832 (9:7)": (1152, 832),
|
||||
"Landscape - 1216x832 (19:13)": (1216, 832),
|
||||
"Landscape - 1088x896 (17:14)": (1088, 896),
|
||||
"Landscape - 1152x896 (9:7)": (1152, 896),
|
||||
"Landscape - 1024x960 (16:15)": (1024, 960),
|
||||
"Landscape - 1088x960 (17:15)": (1088, 960),
|
||||
"Landscape - 1280x1024 (5:4)": (1280, 1024),
|
||||
"Landscape - 1456x1120 (13:10)": (1456, 1120),
|
||||
"Landscape - 1536x1280 (6:5)": (1536, 1280),
|
||||
"Landscape - 1680x1120 (3:2)": (1680, 1120),
|
||||
"Landscape - 1728x1344 (9:7)": (1728, 1344),
|
||||
"Landscape - 1792x1120 (8:5)": (1792, 1120),
|
||||
"Landscape - 1904x1120 (17:10)": (1904, 1120),
|
||||
"Landscape - 1920x1440 (4:3)": (1920, 1440),
|
||||
"Landscape - 2016x1120 (6:5)": (2016, 1120),
|
||||
"Landscape - 2240x1120 (2:1)": (2240, 1120),
|
||||
"Landscape - 2016x1232 (18:11)": (2016, 1232),
|
||||
"Landscape - 2464x1232 (2:1)": (2464, 1232),
|
||||
"Landscape - 1536x1024 (3:2)": (1536, 1024),
|
||||
"Landscape - 1792x1344 (4:3)": (1792, 1344),
|
||||
"Landscape - 2016x1344 (3:2)": (2016, 1344),
|
||||
"Landscape - 2240x1344 (5:3)": (2240, 1344),
|
||||
"Landscape - 2688x1344 (2:1)": (2688, 1344),
|
||||
"Landscape - 1792x1456 (16:13)": (1792, 1456),
|
||||
"Landscape - 2912x1456 (2:1)": (2912, 1456),
|
||||
"Landscape - 1856x1088 (~16:9)": (1856, 1088),
|
||||
"Landscape - 1920x1280 (3:2)": (1920, 1280),
|
||||
"Landscape - 2352x1568 (3:2)": (2352, 1568),
|
||||
"Landscape - 2016x1680 (6:5)": (2016, 1680),
|
||||
"Landscape - 2240x1680 (4:3)": (2240, 1680),
|
||||
"Landscape - 2240x1792 (5:4)": (2240, 1792),
|
||||
"Landscape - 1920x1080 (16:9)": (1920, 1080),
|
||||
"Landscape - 1920x1024 (15:8)": (1920, 1024),
|
||||
"Landscape - 1920x816 (20:9)": (1920, 816),
|
||||
"Landscape - 640x480 (4:3)": (640, 480), "Landscape - 768x512 (3:2)": (768, 512),
|
||||
"Landscape - 1024x768 (4:3)": (1024, 768), "Landscape - 1280x864 (4:3)": (1280, 864),
|
||||
"Landscape - 1280x960 (4:3)": (1280, 960), "Landscape - 1152x768 (3:2)": (1152, 768),
|
||||
"Landscape - 1344x896 (3:2)": (1344, 896), "Landscape - 1344x768 (7:4)": (1344, 768),
|
||||
"Landscape - 1152x832 (9:7)": (1152, 832), "Landscape - 1216x832 (19:13)": (1216, 832),
|
||||
"Landscape - 1088x896 (17:14)": (1088, 896), "Landscape - 1152x896 (9:7)": (1152, 896),
|
||||
"Landscape - 1024x960 (16:15)": (1024, 960), "Landscape - 1088x960 (17:15)": (1088, 960),
|
||||
"Landscape - 1280x1024 (5:4)": (1280, 1024), "Landscape - 1536x1280 (6:5)": (1536, 1280),
|
||||
"Landscape - 1728x1344 (9:7)": (1728, 1344), "Landscape - 1920x1440 (4:3)": (1920, 1440),
|
||||
"Landscape - 1536x1024 (3:2)": (1536, 1024), "Landscape - 1856x1088 (~16:9)": (1856, 1088),
|
||||
"Landscape - 1920x1280 (3:2)": (1920, 1280), "Landscape - 1920x1080 (16:9)": (1920, 1080),
|
||||
"Landscape - 1920x1024 (15:8)": (1920, 1024), "Landscape - 1920x816 (20:9)": (1920, 816),
|
||||
# Qwen
|
||||
"Square - 1008x1008 (1:1)": (1008, 1008), "Square - 1120x1120 (1:1)": (1120, 1120),
|
||||
"Square - 1344x1344 (1:1)": (1344, 1344), "Square - 1568x1568 (1:1)": (1568, 1568),
|
||||
"Square - 1792x1792 (1:1)": (1792, 1792), "Square - 2016x2016 (1:1)": (2016, 2016),
|
||||
"Portrait - 896x1120 (4:5)": (896, 1120), "Portrait - 896x1344 (2:3)": (896, 1344),
|
||||
"Portrait - 1008x1344 (3:4)": (1008, 1344), "Portrait - 1008x1792 (9:16)": (1008, 1792),
|
||||
"Portrait - 1120x1456 (10:13)": (1120, 1456), "Portrait - 1120x1680 (2:3)": (1120, 1680),
|
||||
"Portrait - 1120x1792 (5:8)": (1120, 1792), "Portrait - 1120x1904 (10:17)": (1120, 1904),
|
||||
"Portrait - 1120x2016 (5:6)": (1120, 2016), "Portrait - 1120x2240 (1:2)": (1120, 2240),
|
||||
"Portrait - 1232x2016 (11:18)": (1232, 2016), "Portrait - 1232x2464 (1:2)": (1232, 2464),
|
||||
"Portrait - 1344x1792 (3:4)": (1344, 1792), "Portrait - 1344x2016 (2:3)": (1344, 2016),
|
||||
"Portrait - 1344x2240 (3:5)": (1344, 2240), "Portrait - 1344x2688 (1:2)": (1344, 2688),
|
||||
"Portrait - 1456x1792 (13:16)": (1456, 1792), "Portrait - 1456x2912 (1:2)": (1456, 2912),
|
||||
"Portrait - 1568x2352 (2:3)": (1568, 2352), "Portrait - 1680x2016 (5:6)": (1680, 2016),
|
||||
"Portrait - 1680x2240 (3:4)": (1680, 2240), "Portrait - 1792x2240 (4:5)": (1792, 2240),
|
||||
"Landscape - 1120x896 (5:4)": (1120, 896), "Landscape - 1344x896 (3:2)": (1344, 896),
|
||||
"Landscape - 1344x1008 (4:3)": (1344, 1008), "Landscape - 1792x1008 (16:9)": (1792, 1008),
|
||||
"Landscape - 1456x1120 (13:10)": (1456, 1120), "Landscape - 1680x1120 (3:2)": (1680, 1120),
|
||||
"Landscape - 1792x1120 (8:5)": (1792, 1120), "Landscape - 1904x1120 (17:10)": (1904, 1120),
|
||||
"Landscape - 2016x1120 (6:5)": (2016, 1120), "Landscape - 2240x1120 (2:1)": (2240, 1120),
|
||||
"Landscape - 2016x1232 (18:11)": (2016, 1232), "Landscape - 2464x1232 (2:1)": (2464, 1232),
|
||||
"Landscape - 1792x1344 (4:3)": (1792, 1344), "Landscape - 2016x1344 (3:2)": (2016, 1344),
|
||||
"Landscape - 2240x1344 (5:3)": (2240, 1344), "Landscape - 2688x1344 (2:1)": (2688, 1344),
|
||||
"Landscape - 1792x1456 (16:13)": (1792, 1456), "Landscape - 2912x1456 (2:1)": (2912, 1456),
|
||||
"Landscape - 2352x1568 (3:2)": (2352, 1568), "Landscape - 2016x1680 (6:5)": (2016, 1680),
|
||||
"Landscape - 2240x1680 (4:3)": (2240, 1680), "Landscape - 2240x1792 (5:4)": (2240, 1792),
|
||||
}
|
||||
width, height = size_map.get(preset, (1024, 1024))
|
||||
|
||||
@@ -284,15 +220,13 @@ class RS_multilatent:
|
||||
dtype=dtype
|
||||
)
|
||||
|
||||
return ({
|
||||
"samples": latent
|
||||
}, width, height, latent_width, latent_height)
|
||||
return ({"samples": latent}, width, height)
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"RS_multilatent": RS_multilatent
|
||||
"RS_Image_MultiLatent": RS_Image_MultiLatent
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"RS_multilatent": "🦊 RS MultiLatent"
|
||||
"RS_Image_MultiLatent": "🦊 RS Image MultiLatent"
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "RS.MultiLatent",
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeData.name !== "RS_Image_MultiLatent") return;
|
||||
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function() {
|
||||
const result = onNodeCreated ? onNodeCreated.apply(this) : undefined;
|
||||
initCustomPresets(this);
|
||||
|
||||
// === ДОБАВЛЯЕМ ОГРАНИЧЕНИЕ МИНИМАЛЬНОГО РАЗМЕРА ===
|
||||
const minWidth = 240;
|
||||
const minHeight = 310;
|
||||
const origOnResize = this.onResize;
|
||||
this.onResize = function(size) {
|
||||
if (size[0] < minWidth) size[0] = minWidth;
|
||||
if (size[1] < minHeight) size[1] = minHeight;
|
||||
if (origOnResize) {
|
||||
origOnResize.apply(this, [size]);
|
||||
} else {
|
||||
this.size = size;
|
||||
this.setDirtyCanvas(true, true);
|
||||
}
|
||||
};
|
||||
// ================================================
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
function initCustomPresets(node) {
|
||||
const wActive = node.widgets.find(w => w.name === "active_preset");
|
||||
const wStd = node.widgets.find(w => w.name === "preset_standard");
|
||||
const wQwen = node.widgets.find(w => w.name === "preset_qwen");
|
||||
const wKrea = node.widgets.find(w => w.name === "preset_krea2");
|
||||
|
||||
if (!wActive || !wStd || !wQwen || !wKrea) return;
|
||||
|
||||
[wStd, wQwen, wKrea, wActive].forEach(w => {
|
||||
w.type = "hidden";
|
||||
w.hidden = true;
|
||||
w.computeSize = () => [0, 0];
|
||||
});
|
||||
|
||||
const container = document.createElement("div");
|
||||
container.style.display = "flex";
|
||||
container.style.flexDirection = "column";
|
||||
container.style.gap = "4px";
|
||||
container.style.padding = "4px 0";
|
||||
container.style.width = "100%";
|
||||
|
||||
const placeholderDiv = document.createElement("div");
|
||||
placeholderDiv.textContent = "SELECT A PRESET CATEGORY";
|
||||
placeholderDiv.style.textAlign = "center";
|
||||
placeholderDiv.style.fontSize = "10px";
|
||||
placeholderDiv.style.color = "#00FF00";
|
||||
placeholderDiv.style.padding = "2px 0";
|
||||
placeholderDiv.style.fontWeight = "bold";
|
||||
|
||||
const buttonsContainer = document.createElement("div");
|
||||
buttonsContainer.style.display = "flex";
|
||||
buttonsContainer.style.gap = "8px";
|
||||
buttonsContainer.style.width = "100%";
|
||||
|
||||
const infoDiv = document.createElement("div");
|
||||
infoDiv.style.textAlign = "center";
|
||||
infoDiv.style.padding = "6px 8px";
|
||||
infoDiv.style.backgroundColor = "rgba(74, 158, 255, 0.1)";
|
||||
infoDiv.style.borderRadius = "4px";
|
||||
infoDiv.style.fontSize = "11px";
|
||||
infoDiv.style.color = "#aaa";
|
||||
infoDiv.style.fontWeight = "500";
|
||||
|
||||
const lists = [
|
||||
{ id: "Standard", w: wStd, label: "STANDARD", color: "#4a9eff" },
|
||||
{ id: "Qwen", w: wQwen, label: "QWEN", color: "#ff6b4a" },
|
||||
{ id: "Krea2", w: wKrea, label: "KREA2", color: "#4aff9e" }
|
||||
];
|
||||
|
||||
let currentOpen = null;
|
||||
const buttons = [];
|
||||
|
||||
document.addEventListener("click", (e) => {
|
||||
if (currentOpen && !container.contains(e.target)) {
|
||||
currentOpen.remove();
|
||||
currentOpen = null;
|
||||
}
|
||||
});
|
||||
|
||||
const updateInfo = () => {
|
||||
const activeList = lists.find(l => l.id === wActive.value);
|
||||
const presetValue = activeList ? activeList.w.value : "Not selected";
|
||||
|
||||
const orientationMatch = presetValue.match(/^(Square|Portrait|Landscape)\s*-\s*/);
|
||||
const sizeMatch = presetValue.match(/(\d+)\s*[×x]\s*(\d+)/);
|
||||
const aspectMatch = presetValue.match(/\(([^)]+)\)$/);
|
||||
|
||||
let infoText = "";
|
||||
if (orientationMatch && sizeMatch) {
|
||||
const orientation = orientationMatch[1];
|
||||
const width = sizeMatch[1];
|
||||
const height = sizeMatch[2];
|
||||
const aspect = aspectMatch ? ` ${aspectMatch[1]}` : "";
|
||||
infoText = `${orientation} - ${width}×${height}${aspect} — ${activeList ? activeList.label : ""}`;
|
||||
} else {
|
||||
infoText = presetValue;
|
||||
}
|
||||
|
||||
infoDiv.textContent = infoText;
|
||||
if (activeList) {
|
||||
infoDiv.style.backgroundColor = `${activeList.color}15`;
|
||||
infoDiv.style.color = activeList.color;
|
||||
}
|
||||
};
|
||||
|
||||
lists.forEach(list => {
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.style.flex = "1";
|
||||
wrapper.style.position = "relative";
|
||||
|
||||
const btn = document.createElement("button");
|
||||
btn.textContent = list.label;
|
||||
btn.style.width = "100%";
|
||||
btn.style.padding = "6px 4px";
|
||||
btn.style.borderRadius = "4px";
|
||||
btn.style.cursor = "pointer";
|
||||
btn.style.fontSize = "10px";
|
||||
btn.style.textAlign = "center";
|
||||
btn.style.overflow = "hidden";
|
||||
btn.style.textOverflow = "ellipsis";
|
||||
btn.style.whiteSpace = "nowrap";
|
||||
btn.style.transition = "all 0.15s";
|
||||
|
||||
btn.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
if (currentOpen) { currentOpen.remove(); currentOpen = null; }
|
||||
wActive.value = list.id;
|
||||
updateAllButtons();
|
||||
updateInfo();
|
||||
node.setDirtyCanvas(true, true);
|
||||
|
||||
const dropdown = document.createElement("div");
|
||||
dropdown.style.position = "absolute";
|
||||
dropdown.style.left = "0";
|
||||
dropdown.style.width = "220px";
|
||||
dropdown.style.maxHeight = "250px";
|
||||
dropdown.style.overflowY = "auto";
|
||||
dropdown.style.backgroundColor = "#1a1a1a";
|
||||
dropdown.style.border = `1px solid ${list.color}`;
|
||||
dropdown.style.borderRadius = "4px";
|
||||
dropdown.style.boxShadow = "0 4px 12px rgba(0,0,0,0.8)";
|
||||
dropdown.style.zIndex = "9999";
|
||||
dropdown.style.fontSize = "11px";
|
||||
|
||||
const btnRect = btn.getBoundingClientRect();
|
||||
const windowHeight = window.innerHeight;
|
||||
const spaceBelow = windowHeight - btnRect.bottom;
|
||||
const spaceAbove = btnRect.top;
|
||||
|
||||
if (spaceBelow < 250 && spaceAbove > spaceBelow) {
|
||||
dropdown.style.bottom = "100%";
|
||||
dropdown.style.marginBottom = "4px";
|
||||
dropdown.style.maxHeight = `${Math.min(250, spaceAbove - 20)}px`;
|
||||
} else {
|
||||
dropdown.style.top = "100%";
|
||||
dropdown.style.marginTop = "4px";
|
||||
}
|
||||
|
||||
list.w.options.values.forEach(opt => {
|
||||
const item = document.createElement("div");
|
||||
item.textContent = opt;
|
||||
item.style.padding = "6px 8px";
|
||||
item.style.cursor = "pointer";
|
||||
item.style.color = "#ddd";
|
||||
item.style.borderBottom = "1px solid #2a2a2a";
|
||||
item.style.whiteSpace = "nowrap";
|
||||
item.style.overflow = "hidden";
|
||||
item.style.textOverflow = "ellipsis";
|
||||
|
||||
item.onmouseenter = () => item.style.backgroundColor = "#333";
|
||||
item.onmouseleave = () => item.style.backgroundColor = "transparent";
|
||||
|
||||
item.onclick = (ev) => {
|
||||
ev.stopPropagation();
|
||||
list.w.value = opt;
|
||||
dropdown.remove();
|
||||
currentOpen = null;
|
||||
updateAllButtons();
|
||||
updateInfo();
|
||||
node.setDirtyCanvas(true, true);
|
||||
};
|
||||
|
||||
dropdown.appendChild(item);
|
||||
});
|
||||
|
||||
wrapper.appendChild(dropdown);
|
||||
currentOpen = dropdown;
|
||||
};
|
||||
|
||||
wrapper.appendChild(btn);
|
||||
buttonsContainer.appendChild(wrapper);
|
||||
buttons.push({ btn, list });
|
||||
});
|
||||
|
||||
const updateAllButtons = () => {
|
||||
buttons.forEach(({ btn, list }) => {
|
||||
const isActive = wActive.value === list.id;
|
||||
btn.style.border = `2px solid ${isActive ? list.color : "#555"}`;
|
||||
btn.style.backgroundColor = isActive ? `${list.color}22` : "#1e1e1e";
|
||||
btn.style.color = isActive ? "#fff" : "#777";
|
||||
btn.style.fontWeight = isActive ? "bold" : "normal";
|
||||
btn.title = list.w.value;
|
||||
});
|
||||
};
|
||||
|
||||
updateAllButtons();
|
||||
updateInfo();
|
||||
|
||||
container.appendChild(placeholderDiv);
|
||||
container.appendChild(buttonsContainer);
|
||||
container.appendChild(infoDiv);
|
||||
|
||||
node.addDOMWidget("preset_ui", "preset_ui", container, {
|
||||
serialize: false,
|
||||
hideOnZoom: false,
|
||||
computeSize: () => [node.size[0] - 20, 70]
|
||||
});
|
||||
|
||||
const originalCallback = wActive.callback;
|
||||
wActive.callback = function(value) {
|
||||
if (originalCallback) originalCallback.apply(this, arguments);
|
||||
updateAllButtons();
|
||||
updateInfo();
|
||||
};
|
||||
|
||||
node.size = [240, 310];
|
||||
}
|
||||
Reference in New Issue
Block a user