Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import spaces
|
|
4 |
import torch
|
5 |
import random
|
6 |
import os
|
|
|
7 |
from PIL import Image
|
8 |
|
9 |
# Import the pipeline from diffusers
|
@@ -76,8 +77,12 @@ def chat_fn(message, chat_history, seed, randomize_seed, guidance_scale, steps,
|
|
76 |
pipe = pipe.to("cpu")
|
77 |
torch.cuda.empty_cache()
|
78 |
|
79 |
-
#
|
80 |
-
|
|
|
|
|
|
|
|
|
81 |
|
82 |
# --- UI Definition using gr.ChatInterface ---
|
83 |
|
|
|
4 |
import torch
|
5 |
import random
|
6 |
import os
|
7 |
+
import tempfile
|
8 |
from PIL import Image
|
9 |
|
10 |
# Import the pipeline from diffusers
|
|
|
77 |
pipe = pipe.to("cpu")
|
78 |
torch.cuda.empty_cache()
|
79 |
|
80 |
+
# Save image to temporary file and return the path
|
81 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp_file:
|
82 |
+
image.save(tmp_file.name, format="PNG")
|
83 |
+
temp_path = tmp_file.name
|
84 |
+
|
85 |
+
return temp_path
|
86 |
|
87 |
# --- UI Definition using gr.ChatInterface ---
|
88 |
|