mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-25 14:25:44 -03:00
Add some more nodes
This commit is contained in:
@@ -20,7 +20,9 @@ from .show_int import ShowInt
|
|||||||
from .show_float import ShowFloat
|
from .show_float import ShowFloat
|
||||||
from .save_text import SaveText
|
from .save_text import SaveText
|
||||||
from .save_tmp_image import SaveTmpImage
|
from .save_tmp_image import SaveTmpImage
|
||||||
|
from .save_image_path import SaveImagePath
|
||||||
from .save_api_image import SaveApiImage
|
from .save_api_image import SaveApiImage
|
||||||
|
from .resize_image import ResizeImage
|
||||||
from .loop_my_combos_samplers_schedulers import LoopCombosSamplersSchedulers
|
from .loop_my_combos_samplers_schedulers import LoopCombosSamplersSchedulers
|
||||||
|
|
||||||
# from .CUSTOM_STRING import CustomStringType
|
# from .CUSTOM_STRING import CustomStringType
|
||||||
@@ -37,7 +39,9 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"Bjornulf_ShowInt": ShowInt,
|
"Bjornulf_ShowInt": ShowInt,
|
||||||
"Bjornulf_ShowFloat": ShowFloat,
|
"Bjornulf_ShowFloat": ShowFloat,
|
||||||
"Bjornulf_SaveText": SaveText,
|
"Bjornulf_SaveText": SaveText,
|
||||||
|
"Bjornulf_ResizeImage": ResizeImage,
|
||||||
"Bjornulf_SaveTmpImage": SaveTmpImage,
|
"Bjornulf_SaveTmpImage": SaveTmpImage,
|
||||||
|
"Bjornulf_SaveImagePath": SaveImagePath,
|
||||||
"Bjornulf_SaveApiImage": SaveApiImage,
|
"Bjornulf_SaveApiImage": SaveApiImage,
|
||||||
"Bjornulf_CombineTexts": CombineTexts,
|
"Bjornulf_CombineTexts": CombineTexts,
|
||||||
"Bjornulf_LoopTexts": LoopTexts,
|
"Bjornulf_LoopTexts": LoopTexts,
|
||||||
@@ -59,6 +63,8 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
|||||||
"Bjornulf_ShowText": "👁 Show (Text)",
|
"Bjornulf_ShowText": "👁 Show (Text)",
|
||||||
"Bjornulf_ShowInt": "👁 Show (Int)",
|
"Bjornulf_ShowInt": "👁 Show (Int)",
|
||||||
"Bjornulf_ShowFloat": "👁 Show (Float)",
|
"Bjornulf_ShowFloat": "👁 Show (Float)",
|
||||||
|
"Bjornulf_ResizeImage": "📏 Resize Image",
|
||||||
|
"Bjornulf_SaveImagePath": "🖼 Save Image (exact path, exact name)",
|
||||||
"Bjornulf_SaveTmpImage": "🖼 Save Image (tmp_api.png)",
|
"Bjornulf_SaveTmpImage": "🖼 Save Image (tmp_api.png)",
|
||||||
"Bjornulf_SaveApiImage": "🖼 Save Image (API_IMAGES/00001.png...)",
|
"Bjornulf_SaveApiImage": "🖼 Save Image (API_IMAGES/00001.png...)",
|
||||||
"Bjornulf_SaveText": "💾 Save Text", #Make SaveCharacter, SaveLocation, SaveCamera, SaveAction, SaveClothes, SaveEmotion...
|
"Bjornulf_SaveText": "💾 Save Text", #Make SaveCharacter, SaveLocation, SaveCamera, SaveAction, SaveClothes, SaveEmotion...
|
||||||
|
|||||||
BIN
__pycache__/__init__.cpython-312.pyc
Normal file
BIN
__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/combine_texts.cpython-312.pyc
Normal file
BIN
__pycache__/combine_texts.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/create_video.cpython-312.pyc
Normal file
BIN
__pycache__/create_video.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/loop_basic_batch.cpython-312.pyc
Normal file
BIN
__pycache__/loop_basic_batch.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/loop_float.cpython-312.pyc
Normal file
BIN
__pycache__/loop_float.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/loop_integer.cpython-312.pyc
Normal file
BIN
__pycache__/loop_integer.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc
Normal file
BIN
__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/loop_samplers.cpython-312.pyc
Normal file
BIN
__pycache__/loop_samplers.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/loop_schedulers.cpython-312.pyc
Normal file
BIN
__pycache__/loop_schedulers.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/loop_texts.cpython-312.pyc
Normal file
BIN
__pycache__/loop_texts.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/ollama.cpython-312.pyc
Normal file
BIN
__pycache__/ollama.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/random_model_clip_vae.cpython-312.pyc
Normal file
BIN
__pycache__/random_model_clip_vae.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/random_texts.cpython-312.pyc
Normal file
BIN
__pycache__/random_texts.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/resize_image.cpython-312.pyc
Normal file
BIN
__pycache__/resize_image.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/save_api_image.cpython-312.pyc
Normal file
BIN
__pycache__/save_api_image.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/save_image_path.cpython-312.pyc
Normal file
BIN
__pycache__/save_image_path.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/save_text.cpython-312.pyc
Normal file
BIN
__pycache__/save_text.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/save_tmp_image.cpython-312.pyc
Normal file
BIN
__pycache__/save_tmp_image.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/show_float.cpython-312.pyc
Normal file
BIN
__pycache__/show_float.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/show_int.cpython-312.pyc
Normal file
BIN
__pycache__/show_int.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/show_text.cpython-312.pyc
Normal file
BIN
__pycache__/show_text.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/video_pingpong.cpython-312.pyc
Normal file
BIN
__pycache__/video_pingpong.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/write_image_allinone.cpython-312.pyc
Normal file
BIN
__pycache__/write_image_allinone.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/write_image_character.cpython-312.pyc
Normal file
BIN
__pycache__/write_image_character.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/write_image_characters.cpython-312.pyc
Normal file
BIN
__pycache__/write_image_characters.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/write_image_environment.cpython-312.pyc
Normal file
BIN
__pycache__/write_image_environment.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/write_text.cpython-312.pyc
Normal file
BIN
__pycache__/write_text.cpython-312.pyc
Normal file
Binary file not shown.
43
resize_image.py
Normal file
43
resize_image.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import numpy as np
|
||||||
|
import torch
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
class ResizeImage:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"image": ("IMAGE", {}),
|
||||||
|
"width": ("INT", {"default": 256}),
|
||||||
|
"height": ("INT", {"default": 256}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FUNCTION = "resize_image"
|
||||||
|
RETURN_TYPES = ("IMAGE",)
|
||||||
|
OUTPUT_NODE = True
|
||||||
|
CATEGORY = "Bjornulf"
|
||||||
|
|
||||||
|
def resize_image(self, image, width=256, height=256):
|
||||||
|
# Convert the image from ComfyUI format to PIL Image
|
||||||
|
i = 255. * image.cpu().numpy()
|
||||||
|
|
||||||
|
# Reshape the image if it's not in the expected format, remove any leading dimensions of size 1
|
||||||
|
if i.ndim > 3:
|
||||||
|
i = np.squeeze(i)
|
||||||
|
# Ensure the image is 3D (height, width, channels)
|
||||||
|
if i.ndim == 2:
|
||||||
|
i = i[:, :, np.newaxis] # Add a channel dimension if it's missing
|
||||||
|
|
||||||
|
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
|
||||||
|
|
||||||
|
# Resize the image
|
||||||
|
img_resized = img.resize((width, height), Image.LANCZOS)
|
||||||
|
|
||||||
|
# Convert the PIL image back to numpy array
|
||||||
|
img_resized_np = np.array(img_resized).astype(np.float32) / 255.0
|
||||||
|
|
||||||
|
# Assuming ComfyUI format needs the image back in tensor format, convert it back
|
||||||
|
img_resized_tensor = torch.tensor(img_resized_np)
|
||||||
|
|
||||||
|
return (img_resized_tensor, )
|
||||||
39
save_image_path.py
Normal file
39
save_image_path.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
class SaveImagePath:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"image": ("IMAGE", {"forceInput": True}),
|
||||||
|
"path": ("STRING", {"default":"./output/default.png"}), # Add path input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FUNCTION = "save_image_path"
|
||||||
|
RETURN_TYPES = ()
|
||||||
|
OUTPUT_NODE = True
|
||||||
|
CATEGORY = "Bjornulf"
|
||||||
|
|
||||||
|
def save_image_path(self, image, path):
|
||||||
|
# Ensure the output directory exists
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
|
||||||
|
# Convert the image from ComfyUI format to PIL Image
|
||||||
|
i = 255. * image.cpu().numpy()
|
||||||
|
|
||||||
|
# Reshape the image if it's not in the expected format, remove any leading dimensions of size 1
|
||||||
|
if i.ndim > 3:
|
||||||
|
i = np.squeeze(i)
|
||||||
|
# Ensure the image is 3D (height, width, channels)
|
||||||
|
if i.ndim == 2:
|
||||||
|
i = i[:, :, np.newaxis] # Add a channel dimension if it's missing
|
||||||
|
|
||||||
|
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
|
||||||
|
|
||||||
|
# Save the image, overwriting if it exists
|
||||||
|
img.save(path, format="PNG")
|
||||||
|
|
||||||
|
return ()
|
||||||
Reference in New Issue
Block a user