stable_diffusion.openvino icon indicating copy to clipboard operation
stable_diffusion.openvino copied to clipboard

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

Open senthilnayagam opened this issue 3 years ago • 3 comments

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.

senthilnayagam avatar Sep 10 '22 10:09 senthilnayagam

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:

  • https://github.com/bes-dev/stable_diffusion.openvino/pull/58.patch
  • https://github.com/bes-dev/stable_diffusion.openvino/pull/58.diff

— 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: @.***>

pjsg avatar Sep 10 '22 21:09 pjsg

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:

  • Includes the beta and eta parameters, the used model name and tokenizer, and the filenames for input and mask
  • Supports writing metadata not only to PNG files, but also for JPEG and TIFF output
  • Doesn't use a hard-coded list of metadata to write, so will automatically include new command-line arguments, should they be added.
  • And, as of today: Stores the used seed even if it wasn't explicitly passed by the user via args

jkrafczyk avatar Sep 11 '22 11:09 jkrafczyk

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).

pjsg avatar Sep 12 '22 00:09 pjsg