Created
January 19, 2023 04:23
-
-
Save dmarx/1961f770edf0c52a7aa094c52a5f24a5 to your computer and use it in GitHub Desktop.
code snippets for getting useful exif metadata from generative art outputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############### | |
# DreamStudio # | |
############### | |
import PIL | |
from PIL import Image, ExifTags | |
def get_exif(img): | |
outv = {} | |
for k, v in img.getexif().items(): | |
tag_name = ExifTags.TAGS[k] | |
outv[tag_name] = v | |
return outv | |
def prompt_from_exif_dreamstudio(image:PIL.Image.Image) -> str: | |
exif = get_exif(image) | |
return exif['ImageDescription'] | |
if __name__ == '__main__': | |
#import sys | |
#fpath = sys.argv[1] | |
fpath = "my_image.png" | |
img = Image.open(fpath) | |
prompt = prompt_from_exif_dreamstudio(img) | |
print(prompt) | |
############ | |
# InvokeAI # | |
############ | |
# ? talk to PBaylies | |
################### | |
# Automatic WebUI # | |
################### | |
# ? | |
######################### | |
# Huggingface Diffusers # | |
######################### | |
# ? | |
############## | |
# Midjourney # | |
############## | |
# ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment