Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from diffusers import DiffusionPipeline
|
|
|
|
|
4 |
|
5 |
def load_amused_model():
|
6 |
return DiffusionPipeline.from_pretrained("amused/amused-256")
|
@@ -21,12 +23,16 @@ def inference(prompt):
|
|
21 |
if error:
|
22 |
print(f"Error generating image: {error}") # Debugging statement
|
23 |
return "Error: " + error
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
|
26 |
gradio_interface = gr.Interface(
|
27 |
fn=inference,
|
28 |
inputs="text",
|
29 |
-
outputs="
|
30 |
)
|
31 |
|
32 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from diffusers import DiffusionPipeline
|
4 |
+
import base64
|
5 |
+
from io import BytesIO
|
6 |
|
7 |
def load_amused_model():
|
8 |
return DiffusionPipeline.from_pretrained("amused/amused-256")
|
|
|
23 |
if error:
|
24 |
print(f"Error generating image: {error}") # Debugging statement
|
25 |
return "Error: " + error
|
26 |
+
|
27 |
+
buffered = BytesIO()
|
28 |
+
image.save(buffered, format="PNG")
|
29 |
+
img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
|
30 |
+
return img_str
|
31 |
|
32 |
gradio_interface = gr.Interface(
|
33 |
fn=inference,
|
34 |
inputs="text",
|
35 |
+
outputs="text" # Change output to text to return base64 string
|
36 |
)
|
37 |
|
38 |
if __name__ == "__main__":
|