Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from diffusers import AutoPipelineForText2Image
|
|
3 |
from io import BytesIO
|
4 |
from generate_propmts import generate_prompt
|
5 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
|
6 |
|
7 |
# Load the model once outside of the function
|
8 |
model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
@@ -14,11 +15,7 @@ def generate_image(prompt):
|
|
14 |
|
15 |
# Check if the model returned images
|
16 |
if isinstance(output.images, list) and len(output.images) > 0:
|
17 |
-
|
18 |
-
buffered = BytesIO()
|
19 |
-
image.save(buffered, format="JPEG")
|
20 |
-
image_bytes = buffered.getvalue()
|
21 |
-
return image_bytes
|
22 |
else:
|
23 |
raise Exception("No images returned by the model.")
|
24 |
|
|
|
3 |
from io import BytesIO
|
4 |
from generate_propmts import generate_prompt
|
5 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
6 |
+
import PIL
|
7 |
|
8 |
# Load the model once outside of the function
|
9 |
model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
|
|
15 |
|
16 |
# Check if the model returned images
|
17 |
if isinstance(output.images, list) and len(output.images) > 0:
|
18 |
+
return output.images[0]
|
|
|
|
|
|
|
|
|
19 |
else:
|
20 |
raise Exception("No images returned by the model.")
|
21 |
|