sachin the king commited on
Commit
75550e7
·
verified ·
1 Parent(s): 49f5916

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.utils import move_cache
2
+ move_cache()
3
+
4
+ from diffusers import StableDiffusionPipeline
5
+ import torch
6
+ import gradio as gr
7
+
8
+ get_completion = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
9
+
10
+
11
+ def texttoImage(input):
12
+ output = get_completion(input)
13
+ return output.images[0]
14
+
15
+ demo = gr.Interface(fn=texttoImage,
16
+ inputs=[gr.Textbox(label="Your prompt")],
17
+ outputs=[gr.Image(label="Result")],
18
+ title="Image Generation with Stable Diffusion",
19
+ description="Generate any image with Stable Diffusion",
20
+ allow_flagging="never",
21
+ examples=["the spirit of a tamagotchi wandering in the city of Vienna",
22
+ "a mecha robot in a favela"])
23
+
24
+ demo.launch()