pseudotheos
commited on
Commit
•
e7bf78a
1
Parent(s):
7d7dadd
Update app.py
Browse files
app.py
CHANGED
@@ -235,13 +235,17 @@ async def generate_image(
|
|
235 |
control_image = Image.open(temp_image_path)
|
236 |
|
237 |
# Call existing inference function with the provided parameters
|
238 |
-
generated_image
|
239 |
if generated_image is None:
|
240 |
return "Failed to generate image"
|
241 |
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
|
|
|
|
|
|
245 |
|
246 |
except Exception as e:
|
247 |
# Handle exceptions and return an error message if something goes wrong
|
|
|
235 |
control_image = Image.open(temp_image_path)
|
236 |
|
237 |
# Call existing inference function with the provided parameters
|
238 |
+
generated_image = inference(control_image, prompt, "", guidance_scale, controlnet_scale, 0, controlnet_end, upscaler_strength, seed, sampler_type)
|
239 |
if generated_image is None:
|
240 |
return "Failed to generate image"
|
241 |
|
242 |
+
# Save the generated image as binary data
|
243 |
+
output_image_io = io.BytesIO()
|
244 |
+
generated_image.save(output_image_io, format="PNG")
|
245 |
+
output_image_io.seek(0)
|
246 |
+
|
247 |
+
# Return the image as a streaming response
|
248 |
+
return StreamingResponse(content=output_image_io, media_type="image/png")
|
249 |
|
250 |
except Exception as e:
|
251 |
# Handle exceptions and return an error message if something goes wrong
|