bes-dev / stable_diffusion.openvino

Apache License 2.0
1.53k stars 208 forks source link

Store prompts and parameters used to create image as metadata inside the image itself #58

Closed senthilnayagam closed 1 year ago

senthilnayagam commented 1 year ago

after generating several hundred images I realised saving prompts, and parameters as separate file is not very effective.

made changes to demo.py to save parameters as metadata.

had to convert opencv image to PIL image and then save the metadata.

added a sample script to print metadata stored inside the generated images.

pjsg commented 1 year ago

Is there a way to include the init-image and mask? Yes, it would make the output bigger, but then it would allow regeneration of the image exactly.

On Sat, Sep 10, 2022 at 6:17 AM Senthil Nayagam @.***> wrote:

after generating several hundred images I realised saving prompts, and parameters as separate file is not very effective.

made changes to demo.py to save parameters as metadata.

had to convert opencv image to PIL image and then save the metadata.

added a sample script to print metadata stored inside the generated images.

You can view, comment on, or merge this pull request online at:

https://github.com/bes-dev/stable_diffusion.openvino/pull/58 Commit Summary

File Changes

(2 files https://github.com/bes-dev/stable_diffusion.openvino/pull/58/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/bes-dev/stable_diffusion.openvino/pull/58, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALQLTMKU7JCR5CLJP56C63V5RN25ANCNFSM6AAAAAAQJIYDYU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jkrafczyk commented 1 year ago

Is there a way to include the init-image and mask? Yes, it would make the output bigger, but then it would allow regeneration of the image exactly.

I'm not convinced fully including the referenced images would be a good idea. I expect including both images would roughly triple the output image size. Also, the metadata fields in PNG are designed for text, so there might be additional encoding problems.

And, of course, including the init_image would likely cause some unpleasant copyright questions when distributing the generated image.

As a compromise, one might instead write the input/mask filenames or hashes of the images. That at least allows the original creator of a generated image to more easily resume/reproduce their work.

Also, as a note to senthilnayagam: There's already an existing, slightly older, PR to include image metadata which provides a bit more functionality than yours: https://github.com/bes-dev/stable_diffusion.openvino/pull/48

Specifically, my PR:

pjsg commented 1 year ago

Lets include the name of the image/mask files and the sha256 hash of the file contents. This does not increase the4 size significantly, but does allow finding the relevant image (if it is still available).