girishwangikar commited on
Commit
b57e1fc
·
verified ·
1 Parent(s): cfae4d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -73,7 +73,12 @@ def generate_image(prompt):
73
 
74
  if isinstance(result, tuple) and len(result) > 0 and isinstance(result[0], str):
75
  img_str = result[0]
76
- img_str += '=' * (-len(img_str) % 4)
 
 
 
 
 
77
  img_data = base64.b64decode(img_str)
78
  image = PILImage.open(BytesIO(img_data))
79
  elif isinstance(result, tuple) and len(result) > 0 and isinstance(result[0], np.ndarray):
 
73
 
74
  if isinstance(result, tuple) and len(result) > 0 and isinstance(result[0], str):
75
  img_str = result[0]
76
+
77
+ # Fix padding if necessary
78
+ missing_padding = len(img_str) % 4
79
+ if missing_padding:
80
+ img_str += '=' * (4 - missing_padding)
81
+
82
  img_data = base64.b64decode(img_str)
83
  image = PILImage.open(BytesIO(img_data))
84
  elif isinstance(result, tuple) and len(result) > 0 and isinstance(result[0], np.ndarray):