update latent image presets and other small stuff

This commit is contained in:
kijai 2024-09-17 15:25:34 +03:00
parent 7aa591b3a6
commit 8c456d5307
3 changed files with 37 additions and 30 deletions

View File

@ -165,9 +165,11 @@ from server import PromptServer
from pathlib import Path from pathlib import Path
if hasattr(PromptServer, "instance"): if hasattr(PromptServer, "instance"):
try:
# NOTE: we add an extra static path to avoid comfy mechanism # NOTE: we add an extra static path to avoid comfy mechanism
# that loads every script in web. # that loads every script in web.
PromptServer.instance.app.add_routes( PromptServer.instance.app.add_routes(
[web.static("/kjweb_async", (Path(__file__).parent.absolute() / "kjweb_async").as_posix())] [web.static("/kjweb_async", (Path(__file__).parent.absolute() / "kjweb_async").as_posix())]
) )
except:
pass

View File

@ -523,9 +523,8 @@ Can be used for realtime diffusion with autoqueue.
class Screencap_mss: class Screencap_mss:
@classmethod @classmethod
def IS_CHANGED(cls): def IS_CHANGED(s, **kwargs):
return float("NaN")
return
RETURN_TYPES = ("IMAGE",) RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("image",) RETURN_NAMES = ("image",)
@ -1660,13 +1659,13 @@ highest dimension.
image = image.movedim(1,-1) image = image.movedim(1,-1)
return(image, image.shape[2], image.shape[1],) return(image, image.shape[2], image.shape[1],)
import pathlib
class LoadAndResizeImage: class LoadAndResizeImage:
_color_channels = ["alpha", "red", "green", "blue"] _color_channels = ["alpha", "red", "green", "blue"]
@classmethod @classmethod
def INPUT_TYPES(s): def INPUT_TYPES(s):
input_dir = folder_paths.get_input_directory() 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": return {"required":
{ {
"image": (sorted(files), {"image_upload": True}), "image": (sorted(files), {"image_upload": True}),
@ -1691,7 +1690,7 @@ class LoadAndResizeImage:
import numpy as np import numpy as np
import torch import torch
image_path = folder_paths.get_annotated_filepath(image) image_path = folder_paths.get_annotated_filepath(image)
import node_helpers import node_helpers
img = node_helpers.pillow(Image.open, image_path) img = node_helpers.pillow(Image.open, image_path)
@ -1799,13 +1798,13 @@ class LoadAndResizeImage:
return (output_image, output_mask, width, height, image_path) return (output_image, output_mask, width, height, image_path)
@classmethod # @classmethod
def IS_CHANGED(s, image, **kwargs): # def IS_CHANGED(s, image, **kwargs):
image_path = folder_paths.get_annotated_filepath(image) # image_path = folder_paths.get_annotated_filepath(image)
m = hashlib.sha256() # m = hashlib.sha256()
with open(image_path, 'rb') as f: # with open(image_path, 'rb') as f:
m.update(f.read()) # m.update(f.read())
return m.digest().hex() # return m.digest().hex()
@classmethod @classmethod
def VALIDATE_INPUTS(s, image): def VALIDATE_INPUTS(s, image):

View File

@ -659,19 +659,21 @@ class EmptyLatentImagePresets:
def INPUT_TYPES(cls): def INPUT_TYPES(cls):
return { return {
"required": { "required": {
"dimensions": ( "dimensions": (
[ '512 x 512', [
'768 x 512', '512 x 512 (1:1)',
'960 x 512', '768 x 512 (1.5:1)',
'1024 x 512', '960 x 512 (1.875:1)',
'1536 x 640', '1024 x 512 (2:1)',
'1344 x 768', '1024 x 576 (1.778:1)',
'1216 x 832', '1536 x 640 (2.4:1)',
'1152 x 896', '1344 x 768 (1.75:1)',
'1024 x 1024', '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}), "invert": ("BOOLEAN", {"default": False}),
@ -691,6 +693,10 @@ class EmptyLatentImagePresets:
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')] 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: if invert:
width = int(result[1].split(' ')[0]) width = int(result[1].split(' ')[0])