RupertAvery / DiffusionToolkit

Metadata-indexer and Viewer for AI-generated images
MIT License
743 stars 46 forks source link

[BUG] Updated sqlite rows for images do not display updated information in preview pane #252

Closed shidarin closed 2 months ago

shidarin commented 3 months ago

Describe the bug My workflow uses comfyui, and DiffusionToolkit doesn't have the ability to read the metadata present. This is to be expected, as every workflow is different and it'd be an uphill battle for DiffusionToolkit to understand everything ever made. So I threw together a quick python script which opens the sqlite3 database, finds rows/images with missing prompts from the Image table, opens up that image metadata with pillow, and then updates that row with the new values for each column. Commit the changes, open DiffusionToolkit and the preview information is blank.

My images appear correctly when I select a model (since I populated the ModelHash column). They appear correctly if I select the a prompt (Since I populated the Prompt column). However, with an image selected, the information never appears in the preview pane- either as permanent text or overlay.

I thought this would be a good workaround, rather than hardcoding my workflows, node names, classes and construction into DiffusionToolkit itself.

Nothing shows in the log.

Version: 1.6.1

Tool: ComfyUI, python 3.10, sqlite3 library

To Reproduce Import an image into Diffusion Toolkit with no or limited metadata. Close DiffusionToolkit. Update the sqlite3 entry for that DB manually. Relaunch DiffusionToolkit.

You will now see your image under things like Models and Prompts, but its information is still blank.

Expected behavior Image DB information updated outside of the program, if done correctly, should show in the app.

Screenshots image

Additional context Of course, the big "if" here is if I put the db entry in correctly. Like I said, they show up under prompts and models, and that information still doesn't display in the preview pane. Comparing two rows, one generated by DiffusionToolkit and one manually inputted, they appear the exact same.

Does this ring any bells on why updated db information wouldn't show in the preview pane?

If it doesn't, I'll move to the next step- fresh db with 2 sample images I can give you.

Thank you for the great tool!

RupertAvery commented 2 months ago

Hi,

The metadata is read directly from the file when displaying. This was done because the metadata in the file might contain more information than the metadata stored in the database. This was designed around AUTOMATIC1111's Other field, which is a plain text field that contains multiple entries, some of which Diffusion Toolkit does not support since plugins will usually add their metadata there.

The metadata is read into the database to facilitate search.

To fix your problem, you should update your image to store the metadata A1111 style. There is a node for ComfyUI that will add this metadata. This will work for new images. For existing images, you will need to copy the A1111-style metadata yourself.

shidarin commented 2 months ago

Thanks for the reply. In between filing this and now, that's exactly what I implemented- I used Pillow to read the png, used the code from my attempt at injecting the database, and then used Pillow to save the png. Took a while to iterate through all the images, and like you suggested I added one of those metadata injecting nodes to my comfyui workflows, so all future PNGs are covered.

Appreciate you taking the time and reading the report, I'll close this out.