We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7efe0f3 commit f745f78Copy full SHA for f745f78
ldm/invoke/pngwriter.py
@@ -57,8 +57,13 @@ def retrieve_metadata(img_path):
57
metadata stored there, as a dict
58
'''
59
im = Image.open(img_path)
60
- md = im.text.get('sd-metadata', '{}')
61
- dream_prompt = im.text.get('Dream', '')
+ if hasattr(im, 'text'):
+ md = im.text.get('sd-metadata', '{}')
62
+ dream_prompt = im.text.get('Dream', '')
63
+ else:
64
+ # When trying to retrieve metadata from images without a 'text' payload, such as JPG images.
65
+ md = '{}'
66
+ dream_prompt = ''
67
return {'sd-metadata': json.loads(md), 'Dream': dream_prompt}
68
69
def write_metadata(img_path:str, meta:dict):
0 commit comments