Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,6 @@ import spaces
|
|
| 9 |
import torch
|
| 10 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
| 11 |
|
| 12 |
-
DESCRIPTIONx = """## STABLE HAMSTER"""
|
| 13 |
-
|
| 14 |
-
|
| 15 |
css = '''
|
| 16 |
.gradio-container {
|
| 17 |
max-width: 100%;
|
|
@@ -105,11 +102,11 @@ def generate(
|
|
| 105 |
image_paths = [save_image(img) for img in images]
|
| 106 |
return image_paths, seed
|
| 107 |
|
| 108 |
-
with gr.Blocks(
|
| 109 |
-
gr.Markdown(
|
| 110 |
|
| 111 |
with gr.Row():
|
| 112 |
-
with gr.Column(scale=
|
| 113 |
with gr.Row():
|
| 114 |
prompt = gr.Text(
|
| 115 |
show_label=False,
|
|
@@ -119,9 +116,15 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 119 |
)
|
| 120 |
run_button = gr.Button("Run", scale=0, variant="primary")
|
| 121 |
|
| 122 |
-
result = gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
with gr.Accordion("Advanced
|
| 125 |
num_images = gr.Slider(
|
| 126 |
label="Number of Images",
|
| 127 |
minimum=1,
|
|
@@ -147,6 +150,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 147 |
value=0,
|
| 148 |
)
|
| 149 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
|
|
|
| 150 |
with gr.Row(visible=True):
|
| 151 |
width = gr.Slider(
|
| 152 |
label="Width",
|
|
@@ -177,20 +181,18 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 177 |
step=1,
|
| 178 |
value=23,
|
| 179 |
)
|
|
|
|
|
|
|
| 180 |
with gr.Column(scale=1):
|
| 181 |
gr.Examples(
|
| 182 |
examples=examples,
|
| 183 |
-
inputs=prompt,
|
|
|
|
|
|
|
| 184 |
cache_examples=False,
|
|
|
|
| 185 |
)
|
| 186 |
|
| 187 |
-
use_negative_prompt.change(
|
| 188 |
-
fn=lambda x: gr.update(visible=x),
|
| 189 |
-
inputs=use_negative_prompt,
|
| 190 |
-
outputs=negative_prompt,
|
| 191 |
-
api_name=False,
|
| 192 |
-
)
|
| 193 |
-
|
| 194 |
gr.on(
|
| 195 |
triggers=[
|
| 196 |
prompt.submit,
|
|
|
|
| 9 |
import torch
|
| 10 |
from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
css = '''
|
| 13 |
.gradio-container {
|
| 14 |
max-width: 100%;
|
|
|
|
| 102 |
image_paths = [save_image(img) for img in images]
|
| 103 |
return image_paths, seed
|
| 104 |
|
| 105 |
+
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
| 106 |
+
gr.Markdown("## STABLE HAMSTER")
|
| 107 |
|
| 108 |
with gr.Row():
|
| 109 |
+
with gr.Column(scale=1):
|
| 110 |
with gr.Row():
|
| 111 |
prompt = gr.Text(
|
| 112 |
show_label=False,
|
|
|
|
| 116 |
)
|
| 117 |
run_button = gr.Button("Run", scale=0, variant="primary")
|
| 118 |
|
| 119 |
+
result = gr.Image(show_label=False, format="png")
|
| 120 |
+
|
| 121 |
+
grid_size_selection = gr.Dropdown(
|
| 122 |
+
choices=list(grid_sizes.keys()),
|
| 123 |
+
value="1x1",
|
| 124 |
+
label="Grid Size"
|
| 125 |
+
)
|
| 126 |
|
| 127 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 128 |
num_images = gr.Slider(
|
| 129 |
label="Number of Images",
|
| 130 |
minimum=1,
|
|
|
|
| 150 |
value=0,
|
| 151 |
)
|
| 152 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 153 |
+
|
| 154 |
with gr.Row(visible=True):
|
| 155 |
width = gr.Slider(
|
| 156 |
label="Width",
|
|
|
|
| 181 |
step=1,
|
| 182 |
value=23,
|
| 183 |
)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
with gr.Column(scale=1):
|
| 187 |
gr.Examples(
|
| 188 |
examples=examples,
|
| 189 |
+
inputs=[prompt],
|
| 190 |
+
outputs=[result, seed],
|
| 191 |
+
fn=infer,
|
| 192 |
cache_examples=False,
|
| 193 |
+
label="Prompt Examples"
|
| 194 |
)
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
gr.on(
|
| 197 |
triggers=[
|
| 198 |
prompt.submit,
|