receyuki / comfyui-prompt-reader-node

The ultimate solution for managing image metadata and multi-tool compatibility. ComfyUI node version of the SD Prompt Reader
MIT License
289 stars 22 forks source link

[BUG] - SD Prompt Saver multiplying by batch number #30

Closed RangerFrank closed 11 months ago

RangerFrank commented 11 months ago

Description

Single images work fine, increasing batch size results in multiplying results, 2x2, 3x3, etc. So a with a batch size set to 4 you get 16 images being processed in SD Prompt Saver, there's also a problem with filename output sanitation, error related:

Error occurred when executing StringFunction|pysssss:

'list' object has no attribute 'replace'

File "D:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 153, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 83, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 76, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\string_function.py", line 43, in exec out = text_a.replace(text_b, text_c) ^^^^^^^^^^^^^^

Similar issue seems to occur with SD Prompt Merge when using null strings that I already posted about.

Reproduction steps

image

Image file

Workflow image: ComfyUI_34305983516218_2023-12-04_51

receyuki commented 11 months ago

The cause of the issue is that the String Function doesn't support list input. From my perspective, the Saver is working fine. It outputs a list because you have inputted a list into it (WD14 Tagger has two text boxes means it is a list).

Normally, when the batch size is set to 2, only 2 images should be output. The reason why you are seeing 2x2 images in your workflow is that the list output by the WD14 Tagger doubles everything.

It seems like you want to store the metadata of images separately as text files, which seems to be a very practical feature. I can consider adding this function to the Prompt Saver.

RangerFrank commented 11 months ago

Yes, the intention is to create keyword files at image generation for a number of purposes including being able to reference, parse, and process those keywords back into the same or different workflows for an iterative generation, having training files pre-made at the generation stage also provides flexibility and removes a step for training loras by including it in image gen.

Also I can't get pythongosssss savetext to work and I think it might be to do with the same issue with being passed a list not a string. Do you know if there's a simple way to string split the WD14 output in the meantime?

receyuki commented 11 months ago
image

The comfyroll includes a node called “CR Split String” which can be used to split a string.

receyuki commented 11 months ago

Please try out the save_metadata_file feature in the new version of Prompt Saver node.

RangerFrank commented 11 months ago

This works well for my purposes, appreciated.