nroggendorff commited on
Commit
7f31f24
·
verified ·
1 Parent(s): 5c1c970

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import spaces
3
+ import gradio as gr
4
+ from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline
5
+
6
+ prior_pipeline = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=dtype)#.to("CUDA")
7
+ #decoder_pipeline = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade", torch_dtype=dtype)#.to("CUDA")
8
+
9
+ def generate(prompt, negative_prompt, width, height, steps):
10
+ prior_output = prior_pipeline(
11
+ prompt=prompt,
12
+ height=height,
13
+ width=width,
14
+ num_inference_steps=steps,
15
+ negative_prompt=negative_prompt
16
+ )
17
+ return prior_output
18
+
19
+ with gr.Blocks() as demo:
20
+ with gr.Row():
21
+ prompt = gr.Textbox(label="Prompt")
22
+
23
+ with gr.Row():
24
+ generate_btn = gr.Button("Generate")
25
+ output = gr.Image(label="Output")
26
+
27
+ with gr.Accordion("Advanced", open=False):
28
+ negative_prompt = gr.Textbox(label="Negative Prompt")
29
+ width = gr.Slider(minimum=64, maximum=1024, step=64, label="Width")
30
+ height = gr.Slider(minimum=64, maximum=1024, step=64, label="Height")
31
+ steps = gr.Slider(minimum=1, maximum=50, step=1, label="Steps")
32
+
33
+ generate_btn.click(generate, inputs=[prompt, negative_prompt, width, height, steps], outputs=output)
34
+
35
+ demo.launch()