Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,6 @@ def infer(
|
|
| 30 |
height=1024,
|
| 31 |
guidance_scale=3,
|
| 32 |
num_inference_steps=20,
|
| 33 |
-
num_images=1,
|
| 34 |
progress=gr.Progress(track_tqdm=True),
|
| 35 |
):
|
| 36 |
if randomize_seed:
|
|
@@ -38,7 +37,7 @@ def infer(
|
|
| 38 |
|
| 39 |
generator = torch.Generator().manual_seed(seed)
|
| 40 |
|
| 41 |
-
|
| 42 |
prompt=prompt,
|
| 43 |
negative_prompt=negative_prompt,
|
| 44 |
guidance_scale=guidance_scale,
|
|
@@ -46,10 +45,10 @@ def infer(
|
|
| 46 |
width=width,
|
| 47 |
height=height,
|
| 48 |
generator=generator,
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
-
return images, seed
|
| 53 |
|
| 54 |
examples = [
|
| 55 |
"A capybara wearing a suit holding a sign that reads Hello World",
|
|
@@ -64,7 +63,7 @@ css = """
|
|
| 64 |
|
| 65 |
with gr.Blocks(css=css) as demo:
|
| 66 |
with gr.Column(elem_id="col-container"):
|
| 67 |
-
gr.Markdown(" # [Stable Diffusion 3.5 Medium Turbo
|
| 68 |
with gr.Row():
|
| 69 |
prompt = gr.Text(
|
| 70 |
label="Prompt",
|
|
@@ -76,7 +75,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 76 |
|
| 77 |
run_button = gr.Button("Run", scale=0, variant="primary")
|
| 78 |
|
| 79 |
-
result = gr.
|
| 80 |
|
| 81 |
with gr.Accordion("Advanced Settings", open=False):
|
| 82 |
negative_prompt = gr.Text(
|
|
@@ -130,14 +129,6 @@ with gr.Blocks(css=css) as demo:
|
|
| 130 |
value=20,
|
| 131 |
)
|
| 132 |
|
| 133 |
-
num_images = gr.Slider(
|
| 134 |
-
label="Number of Images",
|
| 135 |
-
minimum=1,
|
| 136 |
-
maximum=4,
|
| 137 |
-
step=1,
|
| 138 |
-
value=1,
|
| 139 |
-
)
|
| 140 |
-
|
| 141 |
gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
|
| 142 |
gr.on(
|
| 143 |
triggers=[run_button.click, prompt.submit],
|
|
@@ -151,10 +142,9 @@ with gr.Blocks(css=css) as demo:
|
|
| 151 |
height,
|
| 152 |
guidance_scale,
|
| 153 |
num_inference_steps,
|
| 154 |
-
num_images,
|
| 155 |
],
|
| 156 |
outputs=[result, seed],
|
| 157 |
)
|
| 158 |
|
| 159 |
if __name__ == "__main__":
|
| 160 |
-
demo.launch()
|
|
|
|
| 30 |
height=1024,
|
| 31 |
guidance_scale=3,
|
| 32 |
num_inference_steps=20,
|
|
|
|
| 33 |
progress=gr.Progress(track_tqdm=True),
|
| 34 |
):
|
| 35 |
if randomize_seed:
|
|
|
|
| 37 |
|
| 38 |
generator = torch.Generator().manual_seed(seed)
|
| 39 |
|
| 40 |
+
image = pipe(
|
| 41 |
prompt=prompt,
|
| 42 |
negative_prompt=negative_prompt,
|
| 43 |
guidance_scale=guidance_scale,
|
|
|
|
| 45 |
width=width,
|
| 46 |
height=height,
|
| 47 |
generator=generator,
|
| 48 |
+
).images[0]
|
| 49 |
+
|
| 50 |
+
return image, seed
|
| 51 |
|
|
|
|
| 52 |
|
| 53 |
examples = [
|
| 54 |
"A capybara wearing a suit holding a sign that reads Hello World",
|
|
|
|
| 63 |
|
| 64 |
with gr.Blocks(css=css) as demo:
|
| 65 |
with gr.Column(elem_id="col-container"):
|
| 66 |
+
gr.Markdown(" # [Stable Diffusion 3.5 Medium Turbo")
|
| 67 |
with gr.Row():
|
| 68 |
prompt = gr.Text(
|
| 69 |
label="Prompt",
|
|
|
|
| 75 |
|
| 76 |
run_button = gr.Button("Run", scale=0, variant="primary")
|
| 77 |
|
| 78 |
+
result = gr.Image(label="Result", show_label=False)
|
| 79 |
|
| 80 |
with gr.Accordion("Advanced Settings", open=False):
|
| 81 |
negative_prompt = gr.Text(
|
|
|
|
| 129 |
value=20,
|
| 130 |
)
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
|
| 133 |
gr.on(
|
| 134 |
triggers=[run_button.click, prompt.submit],
|
|
|
|
| 142 |
height,
|
| 143 |
guidance_scale,
|
| 144 |
num_inference_steps,
|
|
|
|
| 145 |
],
|
| 146 |
outputs=[result, seed],
|
| 147 |
)
|
| 148 |
|
| 149 |
if __name__ == "__main__":
|
| 150 |
+
demo.launch()
|