RanM commited on
Commit
9e09422
·
verified ·
1 Parent(s): 9aa8b10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
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
- return image
 
 
 
 
25
 
26
  gradio_interface = gr.Interface(
27
  fn=inference,
28
  inputs="text",
29
- outputs="image"
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__":