Yatheshr commited on
Commit
2b62e8c
·
verified ·
1 Parent(s): f898814

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from diffusers import StableDiffusionPipeline
4
+
5
+ # Load the pretrained text-to-image pipeline
6
+ pipe = StableDiffusionPipeline.from_pretrained(
7
+ "stabilityai/stable-diffusion-2-1",
8
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
9
+ ).to("cuda" if torch.cuda.is_available() else "cpu")
10
+
11
+ # Automatically generate a UI from the pipeline
12
+ demo = gr.Interface.from_pipeline(pipe, title="Text-to-Image with Stable Diffusion")
13
+
14
+ demo.launch()