Skip to content

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