AbdulRahim07 commited on
Commit
6069e8e
β€’
1 Parent(s): c86620d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import transformers
2
+ import gradio as gr
3
+ from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
4
+ import torch
5
+
6
+ model_id = "stabilityai/stable-diffusion-2"
7
+ scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
8
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16)
9
+ pipe = pipe.to("cuda")
10
+
11
+ def imgtext(inp):
12
+ image = pipe(inp).images[0]
13
+ return image
14
+
15
+ wp=gr.Interface(fn=imgtext,inputs="text",outputs="image")
16
+ wp.launch()