Spaces:
Runtime error
Runtime error
Add seed.
Browse files
app.py
CHANGED
|
@@ -198,7 +198,8 @@ def sample(model, model_inputs, latent_shape,
|
|
| 198 |
|
| 199 |
# -----
|
| 200 |
|
| 201 |
-
def infer(prompt, negative_prompt):
|
|
|
|
| 202 |
text = tokenizer.tokenize([prompt] * latent_shape[0]).to(device)
|
| 203 |
with torch.inference_mode():
|
| 204 |
if negative_prompt:
|
|
@@ -425,8 +426,18 @@ with block:
|
|
| 425 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 426 |
).style(grid=[2], height="auto")
|
| 427 |
|
| 428 |
-
|
| 429 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 430 |
|
| 431 |
gr.HTML(
|
| 432 |
"""
|
|
|
|
| 198 |
|
| 199 |
# -----
|
| 200 |
|
| 201 |
+
def infer(prompt, negative_prompt, seed):
|
| 202 |
+
torch.manual_seed(seed)
|
| 203 |
text = tokenizer.tokenize([prompt] * latent_shape[0]).to(device)
|
| 204 |
with torch.inference_mode():
|
| 205 |
if negative_prompt:
|
|
|
|
| 426 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 427 |
).style(grid=[2], height="auto")
|
| 428 |
|
| 429 |
+
with gr.Group():
|
| 430 |
+
with gr.Accordion("Advanced settings", open=False):
|
| 431 |
+
seed = gr.Slider(
|
| 432 |
+
label="Seed",
|
| 433 |
+
minimum=0,
|
| 434 |
+
maximum=2147483647,
|
| 435 |
+
step=1,
|
| 436 |
+
randomize=True,
|
| 437 |
+
)
|
| 438 |
+
|
| 439 |
+
text.submit(infer, inputs=[text, negative, seed], outputs=gallery)
|
| 440 |
+
btn.click(infer, inputs=[text, negative, seed], outputs=gallery)
|
| 441 |
|
| 442 |
gr.HTML(
|
| 443 |
"""
|