mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
30 lines
730 B
Python
30 lines
730 B
Python
#!/usr/bin/env python3
|
|
'''This script reads the "Dream" Stable Diffusion prompt embedded in files generated by dream.py'''
|
|
|
|
import sys
|
|
from PIL import Image,PngImagePlugin
|
|
|
|
if len(sys.argv) < 2:
|
|
print("Usage: file2prompt.py <file1.png> <file2.png> <file3.png>...")
|
|
exit(-1)
|
|
|
|
filenames = sys.argv[1:]
|
|
for f in filenames:
|
|
try:
|
|
im = Image.open(f)
|
|
try:
|
|
prompt = im.text['Dream']
|
|
except KeyError:
|
|
prompt = ''
|
|
print(f'{f}: {prompt}')
|
|
except FileNotFoundError:
|
|
sys.stderr.write(f'{f} not found\n')
|
|
continue
|
|
except PermissionError:
|
|
sys.stderr.write(f'{f} could not be opened due to inadequate permissions\n')
|
|
continue
|
|
|
|
|
|
|
|
|