update custom presets

This commit is contained in:
kijai 2024-09-17 16:57:53 +03:00
parent 3dacf166df
commit 999be76780
2 changed files with 34 additions and 28 deletions

View File

@ -1,12 +1,22 @@
[ [
"512x512", {
"768x512", "label": "SD",
"960x512", "value": "512x512"
"1024x512", },
"1024x576", {
"1536x640", "label": "HD",
"1344x768", "value": "768x768"
"1216x832", },
"1152x896", {
"1024x1024" "label": "Full HD",
"value": "1024x1024"
},
{
"label": "4k",
"value": "2048x2048"
},
{
"label": "SVD",
"value": "1024x576"
}
] ]

View File

@ -712,11 +712,11 @@ class EmptyLatentImageCustomPresets:
@classmethod @classmethod
def INPUT_TYPES(cls): def INPUT_TYPES(cls):
with open(os.path.join(script_directory, 'custom_dimensions.json')) as f: with open(os.path.join(script_directory, 'custom_dimensions.json')) as f:
dimensions = json.load(f) dimensions_dict = json.load(f)
return { return {
"required": { "required": {
"dimensions": ( "dimensions": (
dimensions, [f"{d['label']} - {d['value']}" for d in dimensions_dict],
), ),
"invert": ("BOOLEAN", {"default": False}), "invert": ("BOOLEAN", {"default": False}),
@ -739,19 +739,15 @@ The choices are loaded from 'custom_dimensions.json' in the nodes folder.
def generate(self, dimensions, invert, batch_size): def generate(self, dimensions, invert, batch_size):
from nodes import EmptyLatentImage from nodes import EmptyLatentImage
result = [x.strip() for x in dimensions.split('x')] # Split the string into label and value
label, value = dimensions.split(' - ')
# Remove the aspect ratio part # Split the value into width and height
result[0] = result[0].split('(')[0].strip() width, height = [x.strip() for x in value.split('x')]
result[1] = result[1].split('(')[0].strip()
if invert: if invert:
width = int(result[1].split(' ')[0]) width, height = height, width
height = int(result[0])
else: latent = EmptyLatentImage().generate(int(width), int(height), batch_size)[0]
width = int(result[0])
height = int(result[1].split(' ')[0])
latent = EmptyLatentImage().generate(width, height, batch_size)[0]
return (latent, int(width), int(height),) return (latent, int(width), int(height),)