From 0248119829d05fc977875c0d352bd4e53817d3c5 Mon Sep 17 00:00:00 2001 From: NattoMaki Date: Tue, 28 Nov 2023 17:55:21 +0900 Subject: [PATCH] Added ImageProperties and LatentProperties --- __init__.py | 5 +++++ negi/image_properties.py | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 negi/image_properties.py diff --git a/__init__.py b/__init__.py index 3af3ae3..9c12101 100644 --- a/__init__.py +++ b/__init__.py @@ -2,12 +2,15 @@ from .negi.openai_dalle3 import OpenAiDalle3 from .negi.openai_translate import OpenAiTranslate from .negi.string_function import StringFunction from .negi.seed_generator import SeedGenerator +from .negi.image_properties import ImageProperties, LatentProperties NODE_CLASS_MAPPINGS = { "NegiTools_OpenAiDalle3": OpenAiDalle3, "NegiTools_OpenAiTranslate": OpenAiTranslate, "NegiTools_StringFunction": StringFunction, "NegiTools_SeedGenerator": SeedGenerator, + "NegiTools_ImageProperties": ImageProperties, + "NegiTools_LatentProperties": LatentProperties, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -15,4 +18,6 @@ NODE_DISPLAY_NAME_MAPPINGS = { "NegiTools_OpenAiTranslate": "OpenAI Translate to English 🧅", "NegiTools_StringFunction": "String Function 🧅", "NegiTools_SeedGenerator": "Seed Generator 🧅", + "NegiTools_ImageProperties": "Image Properties 🧅", + "NegiTools_LatentProperties": "Latent Properties 🧅", } diff --git a/negi/image_properties.py b/negi/image_properties.py new file mode 100644 index 0000000..1290940 --- /dev/null +++ b/negi/image_properties.py @@ -0,0 +1,45 @@ +class ImageProperties: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image": ("IMAGE",) + }, + } + + RETURN_TYPES = ("INT", "INT",) + RETURN_NAMES = ("WIDTH", "HEIGHT",) + FUNCTION = "doit" + OUTPUT_NODE = False + CATEGORY = "utils" + + def doit(self, image): + # print("shape = " + str(list(image.shape))) + return (image.shape[2], image.shape[1],) + + +class LatentProperties: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "latent": ("LATENT",) + }, + } + + RETURN_TYPES = ("INT", "INT",) + RETURN_NAMES = ("WIDTH", "HEIGHT",) + FUNCTION = "doit" + OUTPUT_NODE = False + CATEGORY = "utils" + + def doit(self, latent): + image = latent["samples"] + # print("shape = " + str(list(image.shape))) + return (image.shape[3] * 8, image.shape[2] * 8,)