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

Add EXIF info containing parameters to outputs #65

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TapuCosmo
Copy link

EXIF code based on https://github.com/lstein/stable-diffusion, but with more info than just the prompt. This will help users view the parameters they used in the future.

Downside: Many online image sharing platforms (including Discord and reddit) strip EXIF info from images in order to protect people's privacy, since many cameras embed GPS info into EXIF data as well. This means that the parameters used can't be easily shared to other people with this method.

@AltoRetrato
Copy link

I have made something similar, using IPTC (with https://github.com/james-see/iptcinfo3), but saving all parameters (even argv[0]) in the "caption/abstract", so you could copy and paste it into the command prompt to run it. Snippet:

parser.add_argument("--iptc", type=bool, nargs="?", default=True, help="save IPTC data to output image (only for JPG)")
# ...
fn = os.path.join(sample_path, "seed_" + str(opt.seed) + "_" + f"{base_count:05}.{opt.format}")
Image.fromarray(x_sample.astype(np.uint8)).save(
    fp = fn,
    quality = 95,
)
if opt.iptc and opt.format == "jpg":
    info = IPTCInfo(fn, force=True)
    cmd  = " ".join([f'"{x}"' if " " in x else x for x in sys.argv])
    info["caption/abstract"] = f"{cmd}{f' --seed {opt.seed}' if '--seed' not in cmd else ''}"[:2000]
    info["supplemental category"] = ["stable diffusion"]
    info.save(options="overwrite")

Result (as seen in Irfanview):
image

I wonder if using this format (reproducing exactly how the parameters are used in the input of the program) would be better, because it would make it easier to reproduce the original image (instead of doing a lot of copy-and-paste and editing)...

@veni-vidi-code
Copy link

Some comments to this:

  1. I think it is quite important to add this
  2. This should also be added for the gradio stuff
  3. PNGInfo will not work on jpeg files which are an option in the gradio scripts

@veni-vidi-code
Copy link

Also, possibly using iTXT might be better since it supports UTF-8

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.

3 participants