akhaliq HF Staff commited on
Commit
4ec59b3
·
verified ·
1 Parent(s): c4c2a88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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
- # Return the PIL Image directly - ChatInterface will handle it properly
80
- return image
 
 
 
 
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