DiffusionToolkit icon indicating copy to clipboard operation
DiffusionToolkit copied to clipboard

[BUG] Some ComfyUI generated images are not imported in the database

Open thecat99z opened this issue 2 years ago • 10 comments

Describe the bug Log show errors like : An error occurred while reading E:\ComfyUI\output\0816\s3_00079_.png: The given key was not present in the dictionary An error occurred while reading E:\ComfyUI\output\ComfyUI_00002_.png: The requested operation requires an element of type 'Number', but the target element has type 'Array'.

Version: 1.3 To Reproduce This is likely to happen with custom or complex workflows. exemple : by just converting the seed widget to an input

Source Image 1st image with default workflow will be imported without problem 2nd image with a seed input will not

ComfyUI_00001_ ComfyUI_00002_

Prompt metadata for the 1st image look like this Prompt {"3": {"inputs": {"seed": 156680208700286, "steps": 20, "cfg": 8.0, "sampler_name": "euler", "scheduler": "normal", "denoise": 1.0, "model": ["4", 0], "positive": ["6", 0], "negative": ["7", 0], "latent_image": ["5", 0]}, "class_type": "KSampler"}, "4": {"inputs": {"ckpt_name": "v1-5-pruned-emaonly.ckpt"}, "class_type": "CheckpointLoaderSimple"}, "5": {"inputs": {"width": 512, "height": 512, "batch_size": 1}, "class_type": "EmptyLatentImage"}, "6": {"inputs": {"text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "7": {"inputs": {"text": "text, watermark", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "8": {"inputs": {"samples": ["3", 0], "vae": ["4", 2]}, "class_type": "VAEDecode"}, "9": {"inputs": {"filename_prefix": "ComfyUI", "images": ["8", 0]}, "class_type": "SaveImage"}}

and the second one Prompt {"3": {"inputs": {"seed": ["10", 0], "steps": 20, "cfg": 8.0, "sampler_name": "euler", "scheduler": "normal", "denoise": 1.0, "model": ["4", 0], "positive": ["6", 0], "negative": ["7", 0], "latent_image": ["5", 0]}, "class_type": "KSampler"}, "4": {"inputs": {"ckpt_name": "v1-5-pruned-emaonly.ckpt"}, "class_type": "CheckpointLoaderSimple"}, "5": {"inputs": {"width": 512, "height": 512, "batch_size": 1}, "class_type": "EmptyLatentImage"}, "6": {"inputs": {"text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "7": {"inputs": {"text": "text, watermark", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "8": {"inputs": {"samples": ["3", 0], "vae": ["4", 2]}, "class_type": "VAEDecode"}, "9": {"inputs": {"filename_prefix": "ComfyUI", "images": ["8", 0]}, "class_type": "SaveImage"}, "10": {"inputs": {"seed": 1}, "class_type": "Seed (rgthree)"}}

Now we understand why we have this error The requested operation requires an element of type 'Number', but the target element has type 'Array'.

thecat99z avatar Oct 01 '23 14:10 thecat99z

What would the real (numerical) value for seed be? I don't want to have to implement any domain-specific logic for calculating the seed, so I would be inclined to ignore it, but that would leave the seed with a zero value

From my understanding, seed": ["10", 0] points to node

"10": {"inputs": {"seed": 1}, "class_type": "Seed (rgthree)"}

What does this node do? Is the seed value just then 1? I realize that this would be better directed at ComfyUI node devs, is there some standard for this? i.e. any seed node input implementation will have "inputs": {"seed": 1} and the value is the value of seed?

RupertAvery avatar Oct 01 '23 15:10 RupertAvery

Yes the seed value of the second image is 1

I typed it instinctively but I should have let the node randomize it for less confusion.

thecat99z avatar Oct 01 '23 16:10 thecat99z

With this image it is more easy to understand the metadata ComfyUI_00003_

Prompt {"3": {"inputs": {"seed": ["10", 0], "steps": 20, "cfg": 8.0, "sampler_name": "euler", "scheduler": "normal", "denoise": 1.0, "model": ["4", 0], "positive": ["6", 0], "negative": ["7", 0], "latent_image": ["5", 0]}, "class_type": "KSampler"}, "4": {"inputs": {"ckpt_name": "v1-5-pruned-emaonly.ckpt"}, "class_type": "CheckpointLoaderSimple"}, "5": {"inputs": {"width": 512, "height": 512, "batch_size": 1}, "class_type": "EmptyLatentImage"}, "6": {"inputs": {"text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "7": {"inputs": {"text": "text, watermark", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "8": {"inputs": {"samples": ["3", 0], "vae": ["4", 2]}, "class_type": "VAEDecode"}, "9": {"inputs": {"filename_prefix": "ComfyUI", "images": ["8", 0]}, "class_type": "SaveImage"}, "10": {"inputs": {"seed": 94621249842678}, "class_type": "Seed (rgthree)"}}

thecat99z avatar Oct 01 '23 16:10 thecat99z

Okay that makes sense. Let me know if this fixes the issue for you:

v1.3-SeedFix.zip

RupertAvery avatar Oct 01 '23 16:10 RupertAvery

Unfortunately it's still the same errors.

thecat99z avatar Oct 01 '23 16:10 thecat99z

Can you try that link again? I may have uploaded the wrong version initially.

RupertAvery avatar Oct 01 '23 16:10 RupertAvery

Oh yes now it works :+1:

But now I found out about the other error : The given key was not present in the dictionary

This one at least appears when Controlnet is applied

here is an image that will not import

ComfyUI_00005_

metadata is Prompt {"3": {"inputs": {"seed": 156680208700286, "steps": 20, "cfg": 8.0, "sampler_name": "euler", "scheduler": "normal", "denoise": 1.0, "model": ["4", 0], "positive": ["12", 0], "negative": ["7", 0], "latent_image": ["5", 0]}, "class_type": "KSampler"}, "4": {"inputs": {"ckpt_name": "v1-5-pruned-emaonly.ckpt"}, "class_type": "CheckpointLoaderSimple"}, "5": {"inputs": {"width": 512, "height": 512, "batch_size": 1}, "class_type": "EmptyLatentImage"}, "6": {"inputs": {"text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "7": {"inputs": {"text": "text, watermark", "clip": ["4", 1]}, "class_type": "CLIPTextEncode"}, "8": {"inputs": {"samples": ["3", 0], "vae": ["4", 2]}, "class_type": "VAEDecode"}, "9": {"inputs": {"filename_prefix": "ComfyUI", "images": ["8", 0]}, "class_type": "SaveImage"}, "10": {"inputs": {"control_net_name": "control_v11p_sd15_lineart.pth"}, "class_type": "ControlNetLoader"}, "11": {"inputs": {"image": "ComfyUI_00004_.png", "choose file to upload": "image"}, "class_type": "LoadImage", "is_changed": ["3f7f1c8511f19d7cbe8e6db69490f3a8995220471d04a95e2852e1e6b40252de"]}, "12": {"inputs": {"strength": 1.0, "conditioning": ["6", 0], "control_net": ["10", 0], "image": ["11", 0]}, "class_type": "ControlNetApply"}}

thecat99z avatar Oct 01 '23 16:10 thecat99z

For controlnet, is there a direct prompt? Or is the image the input? I guess the question here is, would the conditioning (node 6) be considered the prompt, or would the prompt be empty?

RupertAvery avatar Oct 01 '23 17:10 RupertAvery

Don't know exactly but the CLIPTextEncode conditioning output is send to the Apply Controlnet conditioning input and then the conditioning Controlnet output is directly send to the positive Ksampler node.

thecat99z avatar Oct 01 '23 17:10 thecat99z

I'm also hitting this problem with almost all of my ComfyUI images. If it's a problem with extracting the meta information from the image, could it not just import the images without the data? Ideally it would be great to have that information searchable, but if it can't be parsed then I'd much rather have the image included without info that not have the image there at all. This is the only thing stopping me from switching over fully to use Diffusion Toolkit at the moment, as the rest of the features are great.

chrish-slingshot avatar Oct 24 '23 15:10 chrish-slingshot