You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is something I added to my (heavily modified) 'CLIP_Guided_Diffusion_HQ_256x256' notebook last year.
Basically, just as $topic - store all of the parameters used to generate an image in the metadata of the image itself.
Example:
AFAICT, GitHub doesn't munge the image in any way, so opening it with something like TweakPNG (no affiliation) will let you easily read all of the metadata.
The code is pretty straightforward, something like this should suffice
# RequiredfromPIL.PngImagePluginimportPngInfo# For example (not necessary)fromtorchvision.transformsimportfunctionalasTF# For e.g.global_config= {
'clip_guidance_scale': 1000,
'perlin_init': True,
'perlin_mode': 'gray',
# etc.
}
# This stores each param as a separate metadata entry, but dumping the# whole thing into one field would work just as welldefcreate_png_metadata(cfg):
metadata=PngInfo()
forkey, valueincfg.items():
try:
metadata.add_text(f'AI_{key}', str(value))
exceptUnicodeEncodeError:
passreturnmetadatathis_metadata=create_png_metadata(global_config)
this_metadata.add_text('AI_this_filename', filename)
# Obviously this relies on tensorflow's image writing...TF.to_pil_image(image).save(str(filename), pnginfo=this_metadata)
My first thought was to open a PR, but for the life of me, I can't find the image writing code... 😆
The text was updated successfully, but these errors were encountered:
This is something I added to my (heavily modified) 'CLIP_Guided_Diffusion_HQ_256x256' notebook last year.
Basically, just as $topic - store all of the parameters used to generate an image in the metadata of the image itself.
Example:
AFAICT, GitHub doesn't munge the image in any way, so opening it with something like TweakPNG (no affiliation) will let you easily read all of the metadata.
The code is pretty straightforward, something like this should suffice
My first thought was to open a PR, but for the life of me, I can't find the image writing code... 😆
The text was updated successfully, but these errors were encountered: