RussellGibbon commited on
Commit
0a11297
·
verified ·
1 Parent(s): 352ede5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from diffusers import DiffusionPipeline
4
+
5
+ device = "cuda" if torch.cuda.is_available() else "cpu"
6
+
7
+ pipe = DiffusionPipeline.from_pretrained(
8
+ "stabilityai/stable-diffusion-xl-base-1.0",
9
+ torch_dtype=torch.float16 if device == "cuda" else torch.float32,
10
+ use_safetensors=True,
11
+ )
12
+ pipe.to(device)
13
+
14
+ def generate(prompt):
15
+ image = pipe(prompt=prompt).images[0]
16
+ return image
17
+
18
+ gr.Interface(
19
+ fn=generate,
20
+ inputs=gr.Textbox(label="Prompt", placeholder="A painting of a cat in Van Gogh style"),
21
+ outputs=gr.Image(label="Generated Image"),
22
+ title="SDXL Free Generator"
23
+ ).launch()