Spaces:
Runtime error
Runtime error
Add negative prompts
Browse files
app.py
CHANGED
|
@@ -134,7 +134,7 @@ del prior_ckpt, state_dict
|
|
| 134 |
|
| 135 |
# -----
|
| 136 |
|
| 137 |
-
def infer(prompt, negative_prompt
|
| 138 |
tokenized_text = tokenizer.tokenize([prompt] * batch_size).to(device)
|
| 139 |
negative_text = tokenizer.tokenize([negative_prompt] * batch_size).to(device)
|
| 140 |
with torch.inference_mode():
|
|
@@ -319,17 +319,29 @@ with block:
|
|
| 319 |
with gr.Group():
|
| 320 |
with gr.Box():
|
| 321 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
btn = gr.Button("Generate image").style(
|
| 334 |
margin=False,
|
| 335 |
rounded=(False, True, True, False),
|
|
@@ -340,8 +352,8 @@ with block:
|
|
| 340 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 341 |
).style(grid=[2], height="auto")
|
| 342 |
|
| 343 |
-
text.submit(infer, inputs=text, outputs=gallery)
|
| 344 |
-
btn.click(infer, inputs=text, outputs=gallery)
|
| 345 |
|
| 346 |
gr.HTML(
|
| 347 |
"""
|
|
|
|
| 134 |
|
| 135 |
# -----
|
| 136 |
|
| 137 |
+
def infer(prompt, negative_prompt):
|
| 138 |
tokenized_text = tokenizer.tokenize([prompt] * batch_size).to(device)
|
| 139 |
negative_text = tokenizer.tokenize([negative_prompt] * batch_size).to(device)
|
| 140 |
with torch.inference_mode():
|
|
|
|
| 319 |
with gr.Group():
|
| 320 |
with gr.Box():
|
| 321 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
| 322 |
+
with gr.Column():
|
| 323 |
+
text = gr.Textbox(
|
| 324 |
+
label="Enter your prompt",
|
| 325 |
+
show_label=False,
|
| 326 |
+
max_lines=1,
|
| 327 |
+
placeholder="Enter your prompt",
|
| 328 |
+
elem_id="prompt-text-input",
|
| 329 |
+
).style(
|
| 330 |
+
border=(True, False, True, True),
|
| 331 |
+
rounded=(True, False, False, True),
|
| 332 |
+
container=False,
|
| 333 |
+
)
|
| 334 |
+
negative = gr.Textbox(
|
| 335 |
+
label="Enter your negative prompt",
|
| 336 |
+
show_label=False,
|
| 337 |
+
max_lines=1,
|
| 338 |
+
placeholder="Enter a negative prompt",
|
| 339 |
+
elem_id="negative-prompt-text-input",
|
| 340 |
+
).style(
|
| 341 |
+
border=(True, False, True, True),
|
| 342 |
+
rounded=(True, False, False, True),
|
| 343 |
+
container=False,
|
| 344 |
+
)
|
| 345 |
btn = gr.Button("Generate image").style(
|
| 346 |
margin=False,
|
| 347 |
rounded=(False, True, True, False),
|
|
|
|
| 352 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 353 |
).style(grid=[2], height="auto")
|
| 354 |
|
| 355 |
+
text.submit(infer, inputs=[text, negative], outputs=gallery)
|
| 356 |
+
btn.click(infer, inputs=[text, negative], outputs=gallery)
|
| 357 |
|
| 358 |
gr.HTML(
|
| 359 |
"""
|