KOMATHY commited on
Commit
390b720
·
verified ·
1 Parent(s): e3193d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import StableDiffusionPipeline
4
 
5
+ model_id = "runwayml/stable-diffusion-v1-5"
 
6
 
7
+ pipe = StableDiffusionPipeline.from_pretrained(
8
+ model_id,
9
+ torch_dtype=torch.float32
10
+ )
11
+ pipe = pipe.to("cpu")
12
+
13
+ def generate_image(prompt):
14
+ image = pipe(prompt).images[0]
15
+ return image
16
+
17
+ interface = gr.Interface(
18
+ fn=generate_image,
19
+ inputs=gr.Textbox(label="Enter text prompt"),
20
+ outputs=gr.Image(label="Generated Image"),
21
+ title="Text to Image Generator",
22
+ description="Generate images from text using Stable Diffusion"
23
+ )
24
+
25
+ interface.launch()