mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-09 21:04:41 +08:00
update latent image presets and other small stuff
This commit is contained in:
parent
7aa591b3a6
commit
8c456d5307
14
__init__.py
14
__init__.py
@ -165,9 +165,11 @@ from server import PromptServer
|
||||
from pathlib import Path
|
||||
|
||||
if hasattr(PromptServer, "instance"):
|
||||
|
||||
# NOTE: we add an extra static path to avoid comfy mechanism
|
||||
# that loads every script in web.
|
||||
PromptServer.instance.app.add_routes(
|
||||
[web.static("/kjweb_async", (Path(__file__).parent.absolute() / "kjweb_async").as_posix())]
|
||||
)
|
||||
try:
|
||||
# NOTE: we add an extra static path to avoid comfy mechanism
|
||||
# that loads every script in web.
|
||||
PromptServer.instance.app.add_routes(
|
||||
[web.static("/kjweb_async", (Path(__file__).parent.absolute() / "kjweb_async").as_posix())]
|
||||
)
|
||||
except:
|
||||
pass
|
||||
@ -523,9 +523,8 @@ Can be used for realtime diffusion with autoqueue.
|
||||
class Screencap_mss:
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls):
|
||||
|
||||
return
|
||||
def IS_CHANGED(s, **kwargs):
|
||||
return float("NaN")
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
@ -1660,13 +1659,13 @@ highest dimension.
|
||||
image = image.movedim(1,-1)
|
||||
|
||||
return(image, image.shape[2], image.shape[1],)
|
||||
|
||||
import pathlib
|
||||
class LoadAndResizeImage:
|
||||
_color_channels = ["alpha", "red", "green", "blue"]
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
input_dir = folder_paths.get_input_directory()
|
||||
files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
|
||||
files = [f.name for f in pathlib.Path(input_dir).iterdir() if f.is_file()]
|
||||
return {"required":
|
||||
{
|
||||
"image": (sorted(files), {"image_upload": True}),
|
||||
@ -1691,7 +1690,7 @@ class LoadAndResizeImage:
|
||||
import numpy as np
|
||||
import torch
|
||||
image_path = folder_paths.get_annotated_filepath(image)
|
||||
|
||||
|
||||
import node_helpers
|
||||
img = node_helpers.pillow(Image.open, image_path)
|
||||
|
||||
@ -1799,13 +1798,13 @@ class LoadAndResizeImage:
|
||||
return (output_image, output_mask, width, height, image_path)
|
||||
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(s, image, **kwargs):
|
||||
image_path = folder_paths.get_annotated_filepath(image)
|
||||
m = hashlib.sha256()
|
||||
with open(image_path, 'rb') as f:
|
||||
m.update(f.read())
|
||||
return m.digest().hex()
|
||||
# @classmethod
|
||||
# def IS_CHANGED(s, image, **kwargs):
|
||||
# image_path = folder_paths.get_annotated_filepath(image)
|
||||
# m = hashlib.sha256()
|
||||
# with open(image_path, 'rb') as f:
|
||||
# m.update(f.read())
|
||||
# return m.digest().hex()
|
||||
|
||||
@classmethod
|
||||
def VALIDATE_INPUTS(s, image):
|
||||
|
||||
@ -659,19 +659,21 @@ class EmptyLatentImagePresets:
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"dimensions": (
|
||||
[ '512 x 512',
|
||||
'768 x 512',
|
||||
'960 x 512',
|
||||
'1024 x 512',
|
||||
'1536 x 640',
|
||||
'1344 x 768',
|
||||
'1216 x 832',
|
||||
'1152 x 896',
|
||||
'1024 x 1024',
|
||||
"dimensions": (
|
||||
[
|
||||
'512 x 512 (1:1)',
|
||||
'768 x 512 (1.5:1)',
|
||||
'960 x 512 (1.875:1)',
|
||||
'1024 x 512 (2:1)',
|
||||
'1024 x 576 (1.778:1)',
|
||||
'1536 x 640 (2.4:1)',
|
||||
'1344 x 768 (1.75:1)',
|
||||
'1216 x 832 (1.46:1)',
|
||||
'1152 x 896 (1.286:1)',
|
||||
'1024 x 1024 (1:1)',
|
||||
],
|
||||
{
|
||||
"default": '512 x 512'
|
||||
"default": '512 x 512 (1:1)'
|
||||
}),
|
||||
|
||||
"invert": ("BOOLEAN", {"default": False}),
|
||||
@ -691,6 +693,10 @@ class EmptyLatentImagePresets:
|
||||
def generate(self, dimensions, invert, batch_size):
|
||||
from nodes import EmptyLatentImage
|
||||
result = [x.strip() for x in dimensions.split('x')]
|
||||
|
||||
# Remove the aspect ratio part
|
||||
result[0] = result[0].split('(')[0].strip()
|
||||
result[1] = result[1].split('(')[0].strip()
|
||||
|
||||
if invert:
|
||||
width = int(result[1].split(' ')[0])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user