yfszzx / stable-diffusion-webui-images-browser

an images browse for stable-diffusion-webui
489 stars 235 forks source link

[feature request] search ALL of image metadata? #58

Open createperhaps opened 1 year ago

createperhaps commented 1 year ago

How hard would it be to expand the search to look in all of an images meta data? For example, if I rated an image 1-5 in an adobe or capture one product (or colour coded it red, blue, green, etc). I am looking around in the javascript code myself but I am unfamiliar with the code and might take me a bit to orient myself with it. There is a search bar in the viewer that searches parameters, but I'd like it to search other chunks too. Is this doable?

ghost commented 1 year ago

You might be interested in this which allows for searching of the full prompt text. You could modify it to check against other exif data as needed.

if img.info is not None and img.info["parameters"] is not None:

https://github.com/yfszzx/stable-diffusion-webui-images-browser/pull/66/files

createperhaps commented 1 year ago

Not overly familiar with python, but I can try. Should I need to reload SD every time I edit the script, like does it have a cache, or can I keep uploading to google drive and trying?

ghost commented 1 year ago

If you click Apply and restart UI under the extensions tab it'll reload any code changes you make.

createperhaps commented 1 year ago

Thanks. Does this script do what I want, and its just not merged, or do I need to modify the script? I see references to all_metadata.

ghost commented 1 year ago

It probably doesn't do what you want. This checks for the "parameters" exif data which is where the prompt info is stored. I'm not sure where adobe ratings would be stored but it'll likely be somewhere under img.info["XXXX"]. You'll need to figure out what the XXXX should be for your use case or loop through every entry in img.info[] and do a string comparison against every single one.

createperhaps commented 1 year ago

Right, okay. image Does this help me?

ghost commented 1 year ago

Probably, yea. You'll have to play around with the img object to see where you can pull this information from but it sounds like the right direction.

See this post for more info https://stackoverflow.com/questions/21697645/how-to-extract-metadata-from-an-image-using-python

createperhaps commented 1 year ago

Thanks. Another stupid question, should print(whatever) send info and variables to google collab? or would it go to chrome console?

ghost commented 1 year ago

Probably google collab, but I'm not familiar with google collab as I use stable diffusion locally.

createperhaps commented 1 year ago

I can't figure out how to output print/log to either collab or to chrome, so I can't see if I am getting the right data or not. I saw gradio has something called CSVLogger but I can't get it to work. Thanks for the suggestion but I might just need to wait to see if anyone more knowledgeable can implement this.

createperhaps commented 1 year ago

@AnonPrompts, I used ChatopenAI to fix the script.

Would you be able to push this fix to your reposit, or don't want it? (I didn't mess with the GUI and make a new box)

if img.info is not None:
                adobe_metadata_text = img.info.get("XML:com.adobe.xmp", "")
            else:
                adobe_metadata_text = ""

            if all_metadata.lower() in adobe_metadata_text.lower():
                unique_fileinfos.add(fileinfo)

It goes in get_all_images

ghost commented 1 year ago

lmao that's hilarious. Looking at this issue/PR it might be better to call img.getxmp()

The UI is already a bit bloated but I guess a xmp textbox could go side by side with the prompt, negative prompt, or settings textbox. I might see how that looks soon-ish.

createperhaps commented 1 year ago

Yah i could understand how the pr of using ai to make an ai script could go. Are you able to handle the gui? I struggled as is.

Id be happy to send you a few images with the adobe metadata for testing if you don’t have adobe.

I ran out of time on colab yesterday but searching “5” for a 5 star rating brought up every image with a 5 in the file name. I suspect that if I searched “rating=5” it would filter better. Don’t think that’s an issue though.

Given not every user will use adobe (but I know there are more people who do further edit in adobe) would it make sense to put an option in the settings to turn it on?

Just to give you context on why I’m rating and colour labeling, red means generation issue like weird hand or eye, and that I need to run it through img 2 img. This will help me filter by red in automatic111 itself, so I can bring up the reds then go through img2img. I wish I could rate the images in auto rather than just favourite, but thought using adobes built in meta may be easier and make more sense.

On Thu, Dec 29, 2022 at 4:25 AM AnonPrompts @.***> wrote:

lmao that's hilarious. Looking at this issue/PR it might be better to call img.getxmp()

The UI is already a bit bloated but I guess a xmp textbox could go side by side with the prompt, negative prompt, or settings textbox. I might see how that looks soon-ish.

— Reply to this email directly, view it on GitHub https://github.com/yfszzx/stable-diffusion-webui-images-browser/issues/58#issuecomment-1367183582, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4TQTDA3M2H3APOTOYXE3FDWPVKHNANCNFSM6AAAAAASXBDM3Q . You are receiving this because you authored the thread.Message ID: @.*** com>