Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write inference parameters into generated files as image metadata #48

Merged
merged 9 commits into from
Jan 12, 2023

Conversation

jkrafczyk
Copy link
Contributor

@jkrafczyk jkrafczyk commented Sep 7, 2022

This makes demo.py write the parameters used when invoking it as EXIF or as PNG text chunks into the generated images.

That should make it a bit easier to go back to previous attempts and continue working from there.

EXIF for JPEG and TIFF output data contains the contents of the received argparser args as a single json string. PNG metadata additionally contains every argument as a seperate field.

Filenames passed into init-image, mask and output are modified to only contain the files basename, not the entire path for privacy reasons.

In addition to storing parameters when saving the image, demo.py can now also load and re-use parameters from a previously generated image via the --params-from argument. When using --params-from and passing additional parameters via the command-line, the additionally passed parameters will be preferentially used. This way, an old image can be re-created with higher iteration count, or identical parameters but a different seed.

Example Metadata as displayed by exiftool:
PNG

[...]
Created with                    : stable_diffusion.openvino
Stable diffusion model          : bes-dev/stable-diffusion-v1-4-openvino
Stable diffusion beta start     : 0.00085
Stable diffusion beta end       : 0.012
Stable diffusion beta schedule  : scaled_linear
Stable diffusion num inference steps: 3
Stable diffusion guidance scale : 7.5
Stable diffusion eta            : 0.0
Stable diffusion tokenizer      : openai/clip-vit-large-patch14
Stable diffusion prompt         : Banksy-style street art of emilia clark with bright red hair.
Stable diffusion init image     : input.png
Stable diffusion strength       : 0.5
Stable diffusion mask           : mask.png
Stable diffusion output         : output.png
Exif Byte Order                 : Big-endian (Motorola, MM)
Image Description               : {"created_with": "stable_diffusion.openvino", "stable_diffusion_model": "bes-dev/stable-diffusion-v1-4-openvino", "stable_diffusion_beta_start": "0.00085", "stable_diffusion_beta_end": "0.012", "stable_diffusion_beta_schedule": "scaled_linear", "stable_diffusion_num_inference_steps": "3", "stable_diffusion_guidance_scale": "7.5", "stable_diffusion_eta": "0.0", "stable_diffusion_tokenizer": "openai/clip-vit-large-patch14", "stable_diffusion_prompt": "Banksy-style street art of emilia clark with bright red hair.", "stable_diffusion_init_image": "input.png", "stable_diffusion_strength": "0.5", "stable_diffusion_mask": "mask.png", "stable_diffusion_output": "output.png"}
Software                        : stable_diffusion.openvino
[...]

TIFF

[...]
Photometric Interpretation      : RGB
Image Description               : {"created_with": "stable_diffusion.openvino", "stable_diffusion_model": "bes-dev/stable-diffusion-v1-4-openvino", "stable_diffusion_beta_start": "0.00085", "stable_diffusion_beta_end": "0.012", "stable_diffusion_beta_schedule": "scaled_linear", "stable_diffusion_num_inference_steps": "3", "stable_diffusion_guidance_scale": "7.5", "stable_diffusion_eta": "0.0", "stable_diffusion_tokenizer": "openai/clip-vit-large-patch14", "stable_diffusion_prompt": "Banksy-style street art of emilia clark with bright red hair.", "stable_diffusion_init_image": "input.png", "stable_diffusion_strength": "0.5", "stable_diffusion_mask": "mask.png", "stable_diffusion_output": "output.tiff"}
Strip Offsets                   : 868
Samples Per Pixel               : 3
Rows Per Strip                  : 512
[...]

JPEG

[...]
Exif Byte Order                 : Big-endian (Motorola, MM)
Image Description               : {"created_with": "stable_diffusion.openvino", "stable_diffusion_model": "bes-dev/stable-diffusion-v1-4-openvino", "stable_diffusion_beta_start": "0.00085", "stable_diffusion_beta_end": "0.012", "stable_diffusion_beta_schedule": "scaled_linear", "stable_diffusion_num_inference_steps": "3", "stable_diffusion_guidance_scale": "7.5", "stable_diffusion_eta": "0.0", "stable_diffusion_tokenizer": "openai/clip-vit-large-patch14", "stable_diffusion_prompt": "Banksy-style street art of emilia clark with bright red hair.", "stable_diffusion_init_image": "input.png", "stable_diffusion_strength": "0.5", "stable_diffusion_mask": "mask.png", "stable_diffusion_output": "output.jpg"}
Software                        : stable_diffusion.openvino
Image Width                     : 512
Image Height                    : 512
[...]

@bes-dev bes-dev merged commit 958833c into bes-dev:master Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants