giriss / comfy-image-saver

All the tools you need to save images with their generation metadata on ComfyUI. Compatible with Civitai & Prompthero geninfo auto-detection. Works with png, jpeg and webp.
MIT License
172 stars 30 forks source link

WD14 Tagger metadata #14

Open ericko777 opened 10 months ago

ericko777 commented 10 months ago

Im using WD14 Tagger to get TAGS for a loaded image.

I would like to save those TAGS into png or jpeg

is there any chance you could add a metadata TAGS as a String?

2023-10-29_21-17-07

MokkaBoss1 commented 7 months ago

Screenshot 2024-02-03 111532

ericko777 commented 7 months ago

nice, but some question four you 1- The idea is to add metadata to image, what's the point go have steps,cfg, modelname, sampler_name, scheduler, etc. ? 2- Tried to add: path: c:\temp\ and got an error:

"Traceback (most recent call last): File "C:\ComfyUI_windows_portable\python_embeded\lib\site-packages\aiohttp\web_protocol.py", line 433, in _handle_request resp = await request_handler(request) File "C:\ComfyUI_windows_portable\python_embeded\lib\site-packages\aiohttp\web_app.py", line 504, in _handle resp = await handler(request) File "C:\ComfyUI_windows_portable\python_embeded\lib\site-packages\aiohttp\web_middlewares.py", line 117, in impl return await handler(request) File "C:\ComfyUI_windows_portable\ComfyUI\server.py", line 47, in cache_control response: web.Response = await handler(request) File "C:\ComfyUI_windows_portable\ComfyUI\server.py", line 273, in view_image if os.path.commonpath((os.path.abspath(full_output_dir), output_dir)) != output_dir: File "ntpath.py", line 804, in commonpath ValueError: Paths don't have the same drive"

3- If no path written, where is the file saved? 4- can you handle many CLIP MODEL by listing them and download if selected? (if you can, look at "Interrogator" inside A1111

image

Nice work ny the way! ;)

MokkaBoss1 commented 7 months ago

wd14 tagger.json

including my comfy workflow for loading images from a directory path and adding the metadata from WD14 and then saving it. Agree the other settings are a bit irrelevant but at least it allows you to save the metadata.

To start it you need to put in the path, reset the counter (primitive node) to 0, switch on the extra options autoqueue and start the work flow. it will create a new folder jpg in the path you provide and create a copy of each image with the wd14 tagger information.

I use digiKam to manage my photo collection and can use the search captions to find any pictures with the same metadata components.

not sure what you are refering with the clip models. These are not needed for my workflow.

avviano commented 5 months ago

Unfortunately, there is currently no ComfyUI node for SAVING IMAGES available anywhere that lets you save keywords generated by WD14 Tagger to the internal PNG xmp metadata (or standard PNG meta values such as "TITLE", "AUTHOR", "DESCRIPTION", "COMMENT".

The whole point of having the KEYWORDS in the correct adobe.xmp KEYWORD meta value, is that software like Adobe Bridge, Adobe Lightroom and many other online services and stock sites can then automatically read these tags as image keywords.

This is unfortunately currently the missing link for using ComfyUI to automatically tag images with keywords and save those keywords directly into the PNG file (not external text file or wrong value field like "Positive prompt"). More on the topic of PNG Meta standards can be found here: https://www.w3.org/TR/png/#11textinfo

Its possible to auto-generate keyword tags for any LOAD IMAGE, using either "MS Kosmos-2 Interrogator" or "WD14 Tagger" or "CXH_JoyTag", but its not possible in any available node to actually save these keywords into the default PNG metadata or XMP info (its only possible to save them as external text files or into meta values that don't make any sense).

Why is XMP so important? The adobe xmp standard can store all kinds of metadata directly in the image which will survive any conversion from PNG to JPG and vice versa (which is unique). There is a python library available on GIT that can handle adobe xmp meta here:

https://github.com/Lambda-IT/xmp-toolkit

I am hoping that one day, someone, somewhere will implement XMP into a SAVE IMAGE node. I have the perfect comfyUI workflow all set, just missing a SAVE IMAGE node with XMP capabilities.

The most important values I find would be a the xmp "DESCRIPTION" value and the xmp "KEYWORDS" value. I find that the node "MS Kosmos-2 Interrogator" creates a very nice descriptive text string. It's not the same as a "positive prompt" but its an actual short description - you don't want technical prompts visible on any stock sites, while the nodes "WD14 Tagger" and "CXH_JoyTag" both are great for comprehensive keyword tagging.

Cheers!

MokkaBoss1 commented 5 months ago

thanks for your post. I made a bit of progress in the mean time by feeding into the save with meta data also the model name, steps, cfg, sampler and scheduler values in addition to any positive and negative prompt values. Admittedly not into the XMP data as mentioned previously I can search using the captions for these items using digikam and saving the file as webp format. If you are interested I'm including a basic workflow that integrates all these things. The save with Meta data node does take a long time to run which I'm a bit mystified about but it seems to do the job. save metadata.json

avviano commented 5 months ago

Thanks, sure I would love to see your JSON workflow. Unfortunately I cannot download the link you posted, it keeps trying to save it as HTML.

MokkaBoss1 commented 5 months ago

have posted it here. Hope it works for you.

https://openart.ai/workflows/JbdXJ3mIo5YwZORrVOd6