Spaces:
Paused
Paused
ehristoforu
commited on
Commit
•
f2e9ef7
1
Parent(s):
9b2326c
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
-
from PIL import
|
4 |
import spaces
|
5 |
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline
|
6 |
|
@@ -10,8 +10,30 @@ num_images_per_prompt = 1
|
|
10 |
prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16).to(device)
|
11 |
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade", torch_dtype=torch.float16).to(device)
|
12 |
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
@spaces.GPU
|
17 |
def gen(prompt, negative, width, height):
|
@@ -34,3 +56,20 @@ def gen(prompt, negative, width, height):
|
|
34 |
).images
|
35 |
return decoder_output
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
import spaces
|
5 |
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline
|
6 |
|
|
|
10 |
prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16).to(device)
|
11 |
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade", torch_dtype=torch.float16).to(device)
|
12 |
|
13 |
+
css = """
|
14 |
+
footer {
|
15 |
+
visibility: hidden
|
16 |
+
}
|
17 |
+
|
18 |
+
#generate_button {
|
19 |
+
color: white;
|
20 |
+
border-color: #007bff;
|
21 |
+
background: #2563eb;
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
#save_button {
|
26 |
+
color: white;
|
27 |
+
border-color: #028b40;
|
28 |
+
background: #01b97c;
|
29 |
+
width: 200px;
|
30 |
+
}
|
31 |
+
|
32 |
+
#settings_header {
|
33 |
+
background: rgb(245, 105, 105);
|
34 |
+
|
35 |
+
}
|
36 |
+
"""
|
37 |
|
38 |
@spaces.GPU
|
39 |
def gen(prompt, negative, width, height):
|
|
|
56 |
).images
|
57 |
return decoder_output
|
58 |
|
59 |
+
with gr.Blocks(css=css) as demo:
|
60 |
+
gr.Markdown("# Stable Cascade ```DEMO```")
|
61 |
+
with gr.Row():
|
62 |
+
prompt = gr.Textbox(show_label=False, placeholder="Enter your prompt", max_lines=3, lines=1, interactive=True, scale=20)
|
63 |
+
button = gr.Button(value="Generate", scale=1)
|
64 |
+
with gr.Accordion("Advanced options", open=False):
|
65 |
+
with gr.Row():
|
66 |
+
negative = gr.Textbox(show_label=False, placeholder="Enter a negative", max_lines=2, lines=1, interactive=True)
|
67 |
+
with gr.Row():
|
68 |
+
width = gr.Slider(label="Width", minimum=1024, maximum=2048, step=8, value=1024, interactive=True)
|
69 |
+
height = gr.Slider(label="Height", minimum=1024, maximum=2048, step=8, value=1024, interactive=True)
|
70 |
+
with gr.Row()
|
71 |
+
gallery = gr.Gallery(show_label=False, rows=1, columns=1)
|
72 |
+
|
73 |
+
button.click(gen, inputs=[prompt, negative, width, height], outputs=gallery)
|
74 |
+
|
75 |
+
demo.launch(show_api=False)
|