fffiloni commited on
Commit
1c79e62
1 Parent(s): 0dca599

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import AutoPipelineForText2Image
3
+ import torch
4
+
5
+ device = "cuda" if torch.cuda.is_available() else "cpu"
6
+ pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
7
+ pipe.to(device)
8
+
9
+ def infer(prompt):
10
+
11
+ prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe."
12
+ image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0]
13
+
14
+ return image
15
+
16
+ with gr.Blocks() as demo:
17
+
18
+ with gr.Column():
19
+
20
+ with gr.Row():
21
+ prompt = gr.Text(
22
+ label="Prompt",
23
+ show_label=False,
24
+ max_lines=1,
25
+ placeholder="Enter your prompt",
26
+ container=False,
27
+ )
28
+ run_button = gr.Button("Run", scale=0)
29
+
30
+ result = gr.Image(label="Result", show_label=False)
31
+
32
+ run_button.click(
33
+ fn = infer,
34
+ inputs = [prompt],
35
+ outputs = [result]
36
+ )
37
+
38
+ demo.queue().launch()