lelafav502 commited on
Commit
95a6dcd
·
1 Parent(s): b321c35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -30
app.py CHANGED
@@ -1,33 +1,5 @@
1
  import gradio as gr
2
- import torch
3
- from diffusers import StableDiffusionPipeline
4
- from PIL import Image
5
- import io
6
 
7
- # Load the model
8
- pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
9
- pipe = pipe.to("cuda")
10
-
11
- def generate_image(prompt):
12
- image = pipe(prompt).images[0]
13
- # Save the image to a bytes buffer
14
- img_buffer = io.BytesIO()
15
- image.save(img_buffer, format="PNG")
16
- img_buffer.seek(0)
17
- return img_buffer
18
 
19
- iface = gr.Interface(
20
- fn=generate_image,
21
- inputs="text",
22
- outputs="image",
23
- layout="vertical",
24
- inputs_label="Enter Prompt",
25
- outputs_label="Generated Image",
26
- examples=[
27
- ["a photograph of an astronaut riding a horse"],
28
- ["a beautiful sunset over the mountains"]
29
- ]
30
- )
31
-
32
- if __name__ == "__main__":
33
- iface.launch()
 
1
  import gradio as gr
 
 
 
 
2
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ # Load the model
5
+ gr.Interface.load("CompVis/stable-diffusion-v1-4").launch()