Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,12 +3,11 @@ import numpy as np
|
|
| 3 |
import random
|
| 4 |
import uuid
|
| 5 |
from PIL import Image
|
|
|
|
| 6 |
import spaces
|
| 7 |
from diffusers import DiffusionPipeline
|
| 8 |
import torch
|
| 9 |
|
| 10 |
-
DESCRIPTIONx = """## SD3.5 LARGE TURBO """
|
| 11 |
-
|
| 12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
model_repo_id = "stabilityai/stable-diffusion-3.5-large-turbo"
|
| 14 |
|
|
@@ -59,7 +58,7 @@ grid_sizes = {
|
|
| 59 |
"1x1": (1, 1)
|
| 60 |
}
|
| 61 |
|
| 62 |
-
@spaces.GPU
|
| 63 |
def infer(
|
| 64 |
prompt,
|
| 65 |
negative_prompt="",
|
|
@@ -124,94 +123,92 @@ footer {
|
|
| 124 |
'''
|
| 125 |
|
| 126 |
with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
|
| 127 |
-
gr.
|
| 128 |
-
|
| 129 |
-
prompt = gr.Text(
|
| 130 |
-
label="Prompt",
|
| 131 |
-
show_label=False,
|
| 132 |
-
max_lines=1,
|
| 133 |
-
placeholder="Enter your prompt",
|
| 134 |
-
container=False,
|
| 135 |
-
)
|
| 136 |
-
run_button = gr.Button("Run", scale=0, variant="primary")
|
| 137 |
-
result = gr.Image(label="Result", columns=1, preview=True, show_label=False)
|
| 138 |
-
|
| 139 |
-
with gr.Row(visible=True):
|
| 140 |
-
grid_size_selection = gr.Dropdown(
|
| 141 |
-
choices=["2x1", "1x2", "2x2", "2x3", "3x2", "1x1"],
|
| 142 |
-
value="1x1",
|
| 143 |
-
label="Grid Size"
|
| 144 |
-
)
|
| 145 |
-
|
| 146 |
-
with gr.Row(visible=True):
|
| 147 |
-
style_selection = gr.Radio(
|
| 148 |
-
show_label=True,
|
| 149 |
-
container=True,
|
| 150 |
-
interactive=True,
|
| 151 |
-
choices=STYLE_NAMES,
|
| 152 |
-
value=DEFAULT_STYLE_NAME,
|
| 153 |
-
label="Quality Style",
|
| 154 |
-
)
|
| 155 |
-
|
| 156 |
-
with gr.Accordion("Advanced Settings", open=False):
|
| 157 |
-
negative_prompt = gr.Text(
|
| 158 |
-
label="Negative prompt",
|
| 159 |
-
max_lines=1,
|
| 160 |
-
placeholder="Enter a negative prompt",
|
| 161 |
-
visible=False,
|
| 162 |
-
)
|
| 163 |
-
|
| 164 |
-
seed = gr.Slider(
|
| 165 |
-
label="Seed",
|
| 166 |
-
minimum=0,
|
| 167 |
-
maximum=MAX_SEED,
|
| 168 |
-
step=1,
|
| 169 |
-
value=0,
|
| 170 |
-
)
|
| 171 |
-
|
| 172 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 173 |
|
| 174 |
with gr.Row():
|
| 175 |
-
|
| 176 |
-
label="
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
)
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
)
|
| 190 |
|
| 191 |
-
with gr.
|
| 192 |
-
|
| 193 |
-
label="
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
value=0.0,
|
| 198 |
)
|
| 199 |
|
| 200 |
-
|
| 201 |
-
label="
|
| 202 |
-
minimum=
|
| 203 |
-
maximum=
|
| 204 |
step=1,
|
| 205 |
-
value=
|
| 206 |
)
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
gr.on(
|
| 217 |
triggers=[run_button.click, prompt.submit],
|
|
|
|
| 3 |
import random
|
| 4 |
import uuid
|
| 5 |
from PIL import Image
|
| 6 |
+
|
| 7 |
import spaces
|
| 8 |
from diffusers import DiffusionPipeline
|
| 9 |
import torch
|
| 10 |
|
|
|
|
|
|
|
| 11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 12 |
model_repo_id = "stabilityai/stable-diffusion-3.5-large-turbo"
|
| 13 |
|
|
|
|
| 58 |
"1x1": (1, 1)
|
| 59 |
}
|
| 60 |
|
| 61 |
+
@spaces.GPU
|
| 62 |
def infer(
|
| 63 |
prompt,
|
| 64 |
negative_prompt="",
|
|
|
|
| 123 |
'''
|
| 124 |
|
| 125 |
with gr.Blocks(css=css, theme="prithivMLmods/Minecraft-Theme") as demo:
|
| 126 |
+
with gr.Column(elem_id="col-container"):
|
| 127 |
+
gr.Markdown("## SD3.5-Turbo")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
with gr.Row():
|
| 130 |
+
prompt = gr.Text(
|
| 131 |
+
label="Prompt",
|
| 132 |
+
show_label=False,
|
| 133 |
+
max_lines=1,
|
| 134 |
+
placeholder="Enter your prompt",
|
| 135 |
+
container=False,
|
| 136 |
)
|
| 137 |
+
|
| 138 |
+
run_button = gr.Button("Run", scale=0, variant="primary")
|
| 139 |
+
|
| 140 |
+
result = gr.Image(label="Result", show_label=False)
|
| 141 |
+
|
| 142 |
+
with gr.Row(visible=True):
|
| 143 |
+
style_selection = gr.Radio(
|
| 144 |
+
show_label=True,
|
| 145 |
+
container=True,
|
| 146 |
+
interactive=True,
|
| 147 |
+
choices=STYLE_NAMES,
|
| 148 |
+
value=DEFAULT_STYLE_NAME,
|
| 149 |
+
label="Quality Style",
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
with gr.Row(visible=True):
|
| 153 |
+
grid_size_selection = gr.Dropdown(
|
| 154 |
+
choices=["2x1", "1x2", "2x2", "2x3", "3x2", "1x1"],
|
| 155 |
+
value="1x1",
|
| 156 |
+
label="Grid Size"
|
| 157 |
)
|
| 158 |
|
| 159 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 160 |
+
negative_prompt = gr.Text(
|
| 161 |
+
label="Negative prompt",
|
| 162 |
+
max_lines=1,
|
| 163 |
+
placeholder="Enter a negative prompt",
|
| 164 |
+
visible=False,
|
|
|
|
| 165 |
)
|
| 166 |
|
| 167 |
+
seed = gr.Slider(
|
| 168 |
+
label="Seed",
|
| 169 |
+
minimum=0,
|
| 170 |
+
maximum=MAX_SEED,
|
| 171 |
step=1,
|
| 172 |
+
value=0,
|
| 173 |
)
|
| 174 |
+
|
| 175 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 176 |
+
|
| 177 |
+
with gr.Row():
|
| 178 |
+
width = gr.Slider(
|
| 179 |
+
label="Width",
|
| 180 |
+
minimum=512,
|
| 181 |
+
maximum=MAX_IMAGE_SIZE,
|
| 182 |
+
step=32,
|
| 183 |
+
value=1024,
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
height = gr.Slider(
|
| 187 |
+
label="Height",
|
| 188 |
+
minimum=512,
|
| 189 |
+
maximum=MAX_IMAGE_SIZE,
|
| 190 |
+
step=32,
|
| 191 |
+
value=1024,
|
| 192 |
+
)
|
| 193 |
+
|
| 194 |
+
with gr.Row():
|
| 195 |
+
guidance_scale = gr.Slider(
|
| 196 |
+
label="Guidance scale",
|
| 197 |
+
minimum=0.0,
|
| 198 |
+
maximum=7.5,
|
| 199 |
+
step=0.1,
|
| 200 |
+
value=0.0,
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
num_inference_steps = gr.Slider(
|
| 204 |
+
label="Number of inference steps",
|
| 205 |
+
minimum=1,
|
| 206 |
+
maximum=50,
|
| 207 |
+
step=1,
|
| 208 |
+
value=4,
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
|
| 212 |
|
| 213 |
gr.on(
|
| 214 |
triggers=[run_button.click, prompt.submit],
|