Sergidev commited on
Commit
9f429dc
·
verified ·
1 Parent(s): f39a325

History v3

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -154,32 +154,31 @@ def generate(
154
  ).images
155
 
156
  if images:
157
- for image in images:
158
- # Create thumbnail
159
- thumbnail = image.copy()
160
- thumbnail.thumbnail((256, 256))
161
-
162
- # Convert thumbnail to base64
163
- buffered = BytesIO()
164
- thumbnail.save(buffered, format="PNG")
165
- img_str = base64.b64encode(buffered.getvalue()).decode()
166
-
167
- # Add to history
168
- image_history.appendleft({
169
- "thumbnail": f"data:image/png;base64,{img_str}",
170
- "prompt": prompt,
171
- "negative_prompt": negative_prompt,
172
- "seed": seed,
173
- "width": width,
174
- "height": height,
175
- })
176
-
177
- if images and IS_COLAB:
178
- for image in images:
179
  filepath = utils.save_image(image, metadata, OUTPUT_DIR)
180
  logger.info(f"Image saved as {filepath} with metadata")
181
 
182
- return images, metadata, list(image_history)
183
 
184
  except Exception as e:
185
  logger.exception(f"An error occurred: {e}")
 
154
  ).images
155
 
156
  if images:
157
+ image = images[0]
158
+ # Create thumbnail
159
+ thumbnail = image.copy()
160
+ thumbnail.thumbnail((256, 256))
161
+
162
+ # Convert thumbnail to base64
163
+ buffered = BytesIO()
164
+ thumbnail.save(buffered, format="PNG")
165
+ img_str = base64.b64encode(buffered.getvalue()).decode()
166
+
167
+ # Add to history
168
+ image_history.appendleft({
169
+ "thumbnail": f"data:image/png;base64,{img_str}",
170
+ "prompt": prompt,
171
+ "negative_prompt": negative_prompt,
172
+ "seed": seed,
173
+ "width": width,
174
+ "height": height,
175
+ })
176
+
177
+ if IS_COLAB:
 
178
  filepath = utils.save_image(image, metadata, OUTPUT_DIR)
179
  logger.info(f"Image saved as {filepath} with metadata")
180
 
181
+ return image, metadata, list(image_history)
182
 
183
  except Exception as e:
184
  logger.exception(f"An error occurred: {e}")