mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-27 06:40:16 +08:00
Merge LoadImageBatch into LoadImage
This commit is contained in:
parent
ec9ff003bf
commit
341fe22b92
44
nodes.py
44
nodes.py
@ -1080,48 +1080,6 @@ class PreviewImage(SaveImage):
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LoadImage:
|
class LoadImage:
|
||||||
@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))]
|
|
||||||
return {"required":
|
|
||||||
{"image": (sorted(files), )},
|
|
||||||
}
|
|
||||||
|
|
||||||
CATEGORY = "image"
|
|
||||||
|
|
||||||
RETURN_TYPES = ("IMAGE", "MASK")
|
|
||||||
FUNCTION = "load_image"
|
|
||||||
def load_image(self, image):
|
|
||||||
image_path = folder_paths.get_annotated_filepath(image)
|
|
||||||
i = Image.open(image_path)
|
|
||||||
i = ImageOps.exif_transpose(i)
|
|
||||||
image = i.convert("RGB")
|
|
||||||
image = np.array(image).astype(np.float32) / 255.0
|
|
||||||
image = torch.from_numpy(image)[None,]
|
|
||||||
if 'A' in i.getbands():
|
|
||||||
mask = np.array(i.getchannel('A')).astype(np.float32) / 255.0
|
|
||||||
mask = 1. - torch.from_numpy(mask)
|
|
||||||
else:
|
|
||||||
mask = torch.zeros((64,64), dtype=torch.float32, device="cpu")
|
|
||||||
return (image, mask)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def IS_CHANGED(s, image):
|
|
||||||
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):
|
|
||||||
if not folder_paths.exists_annotated_filepath(image):
|
|
||||||
return "Invalid image file: {}".format(image)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
class LoadImageBatch:
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
input_dir = folder_paths.get_input_directory()
|
input_dir = folder_paths.get_input_directory()
|
||||||
@ -1372,7 +1330,6 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"PreviewImage": PreviewImage,
|
"PreviewImage": PreviewImage,
|
||||||
"LoadImage": LoadImage,
|
"LoadImage": LoadImage,
|
||||||
"LoadImageMask": LoadImageMask,
|
"LoadImageMask": LoadImageMask,
|
||||||
"LoadImageBatch": LoadImageBatch,
|
|
||||||
"ImageScale": ImageScale,
|
"ImageScale": ImageScale,
|
||||||
"ImageInvert": ImageInvert,
|
"ImageInvert": ImageInvert,
|
||||||
"ImagePadForOutpaint": ImagePadForOutpaint,
|
"ImagePadForOutpaint": ImagePadForOutpaint,
|
||||||
@ -1454,7 +1411,6 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
|||||||
"PreviewImage": "Preview Image",
|
"PreviewImage": "Preview Image",
|
||||||
"LoadImage": "Load Image",
|
"LoadImage": "Load Image",
|
||||||
"LoadImageMask": "Load Image (as Mask)",
|
"LoadImageMask": "Load Image (as Mask)",
|
||||||
"LoadImageBatch": "Load Image Batch",
|
|
||||||
"ImageScale": "Upscale Image",
|
"ImageScale": "Upscale Image",
|
||||||
"ImageUpscaleWithModel": "Upscale Image (using Model)",
|
"ImageUpscaleWithModel": "Upscale Image (using Model)",
|
||||||
"ImageInvert": "Invert Image",
|
"ImageInvert": "Invert Image",
|
||||||
|
|||||||
@ -6,7 +6,6 @@ app.registerExtension({
|
|||||||
name: "Comfy.UploadImage",
|
name: "Comfy.UploadImage",
|
||||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
switch (nodeData.name) {
|
switch (nodeData.name) {
|
||||||
case "LoadImage":
|
|
||||||
case "LoadImageMask":
|
case "LoadImageMask":
|
||||||
nodeData.input.required.upload = ["IMAGEUPLOAD"];
|
nodeData.input.required.upload = ["IMAGEUPLOAD"];
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -453,6 +453,11 @@ async function loadImageAsync(imageURL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MULTIIMAGEUPLOAD = (node, inputName, inputData, app) => {
|
const MULTIIMAGEUPLOAD = (node, inputName, inputData, app) => {
|
||||||
|
console.error("LOADDATA", node, inputName, inputData)
|
||||||
|
if (typeof inputData === "string") {
|
||||||
|
inputData = [inputData]
|
||||||
|
}
|
||||||
|
|
||||||
const imagesWidget = node.addWidget("text", inputName, inputData, () => {})
|
const imagesWidget = node.addWidget("text", inputName, inputData, () => {})
|
||||||
imagesWidget.disabled = true;
|
imagesWidget.disabled = true;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user