Spaces:
Sleeping
Add negative prompt support to both pipelines and settings
Browse filesAdd customizable negative prompt parameter to control unwanted elements:
- Add negative_prompt parameter to both standard and artistic pipelines
- Add negative prompt UI component in "Change Settings Manually" accordion
- Include negative_prompt in settings JSON export/import for both pipelines
- Update all warmup calls to include negative_prompt parameter
- Convert pipeline calls to keyword arguments to prevent parameter misalignment
- Update event handlers to include negative_prompt in inputs/outputs
- Default: "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
@@ -425,6 +425,7 @@ def compile_models_with_aoti():
|
|
| 425 |
list(
|
| 426 |
_pipeline_standard(
|
| 427 |
prompt=TEST_PROMPT,
|
|
|
|
| 428 |
qr_text=TEST_TEXT,
|
| 429 |
input_type="URL",
|
| 430 |
image_size=512,
|
|
@@ -460,6 +461,7 @@ def compile_models_with_aoti():
|
|
| 460 |
list(
|
| 461 |
_pipeline_artistic(
|
| 462 |
prompt=TEST_PROMPT,
|
|
|
|
| 463 |
qr_text=TEST_TEXT,
|
| 464 |
input_type="URL",
|
| 465 |
image_size=640,
|
|
@@ -513,6 +515,7 @@ def compile_models_with_aoti():
|
|
| 513 |
list(
|
| 514 |
_pipeline_standard(
|
| 515 |
prompt=TEST_PROMPT,
|
|
|
|
| 516 |
qr_text=TEST_TEXT,
|
| 517 |
input_type="URL",
|
| 518 |
image_size=512,
|
|
@@ -533,6 +536,7 @@ def compile_models_with_aoti():
|
|
| 533 |
list(
|
| 534 |
_pipeline_artistic(
|
| 535 |
prompt=TEST_PROMPT,
|
|
|
|
| 536 |
qr_text=TEST_TEXT,
|
| 537 |
input_type="URL",
|
| 538 |
image_size=640,
|
|
@@ -569,7 +573,8 @@ def compile_models_with_aoti():
|
|
| 569 |
@spaces.GPU(duration=60) # Reduced from 720s - AOTI compilation speeds up inference
|
| 570 |
def generate_qr_code_unified(
|
| 571 |
prompt: str,
|
| 572 |
-
|
|
|
|
| 573 |
input_type: str = "URL",
|
| 574 |
image_size: int = 512,
|
| 575 |
border_size: int = 4,
|
|
@@ -616,60 +621,62 @@ def generate_qr_code_unified(
|
|
| 616 |
with torch.inference_mode():
|
| 617 |
if pipeline == "standard":
|
| 618 |
yield from _pipeline_standard(
|
| 619 |
-
prompt,
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
|
|
|
| 641 |
)
|
| 642 |
else: # artistic
|
| 643 |
yield from _pipeline_artistic(
|
| 644 |
-
prompt,
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
|
|
|
| 673 |
)
|
| 674 |
|
| 675 |
|
|
@@ -864,7 +871,8 @@ def apply_color_quantization(
|
|
| 864 |
|
| 865 |
def generate_standard_qr(
|
| 866 |
prompt: str,
|
| 867 |
-
|
|
|
|
| 868 |
input_type: str = "URL",
|
| 869 |
image_size: int = 512,
|
| 870 |
border_size: int = 4,
|
|
@@ -896,6 +904,7 @@ def generate_standard_qr(
|
|
| 896 |
settings_dict = {
|
| 897 |
"pipeline": "standard",
|
| 898 |
"prompt": prompt,
|
|
|
|
| 899 |
"text_input": text_input,
|
| 900 |
"input_type": input_type,
|
| 901 |
"image_size": image_size,
|
|
@@ -924,6 +933,7 @@ def generate_standard_qr(
|
|
| 924 |
# Generate QR and yield progressive results
|
| 925 |
generator = generate_qr_code_unified(
|
| 926 |
prompt,
|
|
|
|
| 927 |
text_input,
|
| 928 |
input_type,
|
| 929 |
image_size,
|
|
@@ -970,7 +980,8 @@ def generate_standard_qr(
|
|
| 970 |
|
| 971 |
def generate_artistic_qr(
|
| 972 |
prompt: str,
|
| 973 |
-
|
|
|
|
| 974 |
input_type: str = "URL",
|
| 975 |
image_size: int = 512,
|
| 976 |
border_size: int = 4,
|
|
@@ -1009,6 +1020,7 @@ def generate_artistic_qr(
|
|
| 1009 |
settings_dict = {
|
| 1010 |
"pipeline": "artistic",
|
| 1011 |
"prompt": prompt,
|
|
|
|
| 1012 |
"text_input": text_input,
|
| 1013 |
"input_type": input_type,
|
| 1014 |
"image_size": image_size,
|
|
@@ -1044,6 +1056,7 @@ def generate_artistic_qr(
|
|
| 1044 |
# Generate QR and yield progressive results
|
| 1045 |
generator = generate_qr_code_unified(
|
| 1046 |
prompt,
|
|
|
|
| 1047 |
text_input,
|
| 1048 |
input_type,
|
| 1049 |
image_size,
|
|
@@ -1159,11 +1172,16 @@ def load_settings_from_json_standard(json_string: str):
|
|
| 1159 |
gr.update(),
|
| 1160 |
gr.update(),
|
| 1161 |
gr.update(),
|
|
|
|
| 1162 |
gr.update(value=error_msg, visible=True),
|
| 1163 |
)
|
| 1164 |
|
| 1165 |
# Extract parameters with defaults
|
| 1166 |
prompt = params.get("prompt", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1167 |
text_input = params.get("text_input", "")
|
| 1168 |
input_type = params.get("input_type", "URL")
|
| 1169 |
image_size = params.get("image_size", 512)
|
|
@@ -1194,6 +1212,7 @@ def load_settings_from_json_standard(json_string: str):
|
|
| 1194 |
success_msg = "✅ Settings loaded successfully!"
|
| 1195 |
return (
|
| 1196 |
prompt,
|
|
|
|
| 1197 |
text_input,
|
| 1198 |
input_type,
|
| 1199 |
image_size,
|
|
@@ -1245,6 +1264,7 @@ def load_settings_from_json_standard(json_string: str):
|
|
| 1245 |
gr.update(),
|
| 1246 |
gr.update(),
|
| 1247 |
gr.update(),
|
|
|
|
| 1248 |
gr.update(value=error_msg, visible=True),
|
| 1249 |
)
|
| 1250 |
except Exception as e:
|
|
@@ -1273,6 +1293,7 @@ def load_settings_from_json_standard(json_string: str):
|
|
| 1273 |
gr.update(),
|
| 1274 |
gr.update(),
|
| 1275 |
gr.update(),
|
|
|
|
| 1276 |
gr.update(value=error_msg, visible=True),
|
| 1277 |
)
|
| 1278 |
|
|
@@ -1320,11 +1341,16 @@ def load_settings_from_json_artistic(json_string: str):
|
|
| 1320 |
gr.update(),
|
| 1321 |
gr.update(),
|
| 1322 |
gr.update(),
|
|
|
|
| 1323 |
gr.update(value=error_msg, visible=True),
|
| 1324 |
)
|
| 1325 |
|
| 1326 |
# Extract parameters with defaults
|
| 1327 |
prompt = params.get("prompt", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1328 |
text_input = params.get("text_input", "")
|
| 1329 |
input_type = params.get("input_type", "URL")
|
| 1330 |
image_size = params.get("image_size", 704)
|
|
@@ -1358,6 +1384,7 @@ def load_settings_from_json_artistic(json_string: str):
|
|
| 1358 |
success_msg = "✅ Settings loaded successfully!"
|
| 1359 |
return (
|
| 1360 |
prompt,
|
|
|
|
| 1361 |
text_input,
|
| 1362 |
input_type,
|
| 1363 |
image_size,
|
|
@@ -1423,6 +1450,7 @@ def load_settings_from_json_artistic(json_string: str):
|
|
| 1423 |
gr.update(),
|
| 1424 |
gr.update(),
|
| 1425 |
gr.update(),
|
|
|
|
| 1426 |
gr.update(value=error_msg, visible=True),
|
| 1427 |
)
|
| 1428 |
except Exception as e:
|
|
@@ -1458,6 +1486,7 @@ def load_settings_from_json_artistic(json_string: str):
|
|
| 1458 |
gr.update(),
|
| 1459 |
gr.update(),
|
| 1460 |
gr.update(),
|
|
|
|
| 1461 |
gr.update(value=error_msg, visible=True),
|
| 1462 |
)
|
| 1463 |
|
|
@@ -1554,14 +1583,15 @@ def add_noise_to_border_only(
|
|
| 1554 |
|
| 1555 |
def _pipeline_standard(
|
| 1556 |
prompt: str,
|
| 1557 |
-
|
| 1558 |
-
|
| 1559 |
-
|
| 1560 |
-
|
| 1561 |
-
|
| 1562 |
-
|
| 1563 |
-
|
| 1564 |
-
|
|
|
|
| 1565 |
enable_upscale: bool = False,
|
| 1566 |
controlnet_strength_first: float = 0.45,
|
| 1567 |
controlnet_strength_final: float = 1.0,
|
|
@@ -1586,7 +1616,7 @@ def _pipeline_standard(
|
|
| 1586 |
)
|
| 1587 |
|
| 1588 |
cliptextencode_7 = cliptextencode.encode(
|
| 1589 |
-
text=
|
| 1590 |
clip=get_value_at_index(checkpointloadersimple_4, 1),
|
| 1591 |
)
|
| 1592 |
|
|
@@ -1829,14 +1859,15 @@ def _pipeline_standard(
|
|
| 1829 |
|
| 1830 |
def _pipeline_artistic(
|
| 1831 |
prompt: str,
|
| 1832 |
-
|
| 1833 |
-
|
| 1834 |
-
|
| 1835 |
-
|
| 1836 |
-
|
| 1837 |
-
|
| 1838 |
-
|
| 1839 |
-
|
|
|
|
| 1840 |
enable_upscale: bool = True,
|
| 1841 |
freeu_b1: float = 1.4,
|
| 1842 |
freeu_b2: float = 1.3,
|
|
@@ -1942,8 +1973,8 @@ def _pipeline_artistic(
|
|
| 1942 |
clip=get_value_at_index(checkpointloadersimple_artistic, 1),
|
| 1943 |
)
|
| 1944 |
|
| 1945 |
-
|
| 1946 |
-
text=
|
| 1947 |
clip=get_value_at_index(checkpointloadersimple_artistic, 1),
|
| 1948 |
)
|
| 1949 |
|
|
@@ -1962,7 +1993,7 @@ def _pipeline_artistic(
|
|
| 1962 |
start_percent=0,
|
| 1963 |
end_percent=1,
|
| 1964 |
positive=get_value_at_index(positive_prompt, 0),
|
| 1965 |
-
negative=get_value_at_index(
|
| 1966 |
control_net=get_value_at_index(brightness_controlnet, 0),
|
| 1967 |
image=qr_with_border_noise,
|
| 1968 |
vae=get_value_at_index(checkpointloadersimple_artistic, 2),
|
|
@@ -2058,7 +2089,7 @@ def _pipeline_artistic(
|
|
| 2058 |
start_percent=0,
|
| 2059 |
end_percent=1,
|
| 2060 |
positive=get_value_at_index(positive_prompt, 0),
|
| 2061 |
-
negative=get_value_at_index(
|
| 2062 |
control_net=get_value_at_index(tile_controlnet, 0),
|
| 2063 |
image=get_value_at_index(decoded, 0),
|
| 2064 |
vae=get_value_at_index(checkpointloadersimple_artistic, 2),
|
|
@@ -2263,6 +2294,15 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 2263 |
|
| 2264 |
# Change Settings Manually - separate accordion
|
| 2265 |
with gr.Accordion("Change Settings Manually", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2266 |
# Add image size slider for artistic QR
|
| 2267 |
artistic_image_size = gr.Slider(
|
| 2268 |
minimum=512,
|
|
@@ -2627,6 +2667,7 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 2627 |
fn=generate_artistic_qr,
|
| 2628 |
inputs=[
|
| 2629 |
artistic_prompt_input,
|
|
|
|
| 2630 |
artistic_text_input,
|
| 2631 |
artistic_input_type,
|
| 2632 |
artistic_image_size,
|
|
@@ -2671,6 +2712,7 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 2671 |
inputs=[import_json_input_artistic],
|
| 2672 |
outputs=[
|
| 2673 |
artistic_prompt_input,
|
|
|
|
| 2674 |
artistic_text_input,
|
| 2675 |
artistic_input_type,
|
| 2676 |
artistic_image_size,
|
|
@@ -3171,6 +3213,15 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 3171 |
|
| 3172 |
# Change Settings Manually - separate accordion
|
| 3173 |
with gr.Accordion("Change Settings Manually", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3174 |
# Add image size slider
|
| 3175 |
image_size = gr.Slider(
|
| 3176 |
minimum=512,
|
|
@@ -3472,6 +3523,7 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 3472 |
fn=generate_standard_qr,
|
| 3473 |
inputs=[
|
| 3474 |
prompt_input,
|
|
|
|
| 3475 |
text_input,
|
| 3476 |
input_type,
|
| 3477 |
image_size,
|
|
@@ -3509,6 +3561,7 @@ if __name__ == "__main__" and not os.environ.get("QR_TESTING_MODE"):
|
|
| 3509 |
inputs=[import_json_input_standard],
|
| 3510 |
outputs=[
|
| 3511 |
prompt_input,
|
|
|
|
| 3512 |
text_input,
|
| 3513 |
input_type,
|
| 3514 |
image_size,
|
|
|
|
| 425 |
list(
|
| 426 |
_pipeline_standard(
|
| 427 |
prompt=TEST_PROMPT,
|
| 428 |
+
negative_prompt="ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 429 |
qr_text=TEST_TEXT,
|
| 430 |
input_type="URL",
|
| 431 |
image_size=512,
|
|
|
|
| 461 |
list(
|
| 462 |
_pipeline_artistic(
|
| 463 |
prompt=TEST_PROMPT,
|
| 464 |
+
negative_prompt="ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 465 |
qr_text=TEST_TEXT,
|
| 466 |
input_type="URL",
|
| 467 |
image_size=640,
|
|
|
|
| 515 |
list(
|
| 516 |
_pipeline_standard(
|
| 517 |
prompt=TEST_PROMPT,
|
| 518 |
+
negative_prompt="ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 519 |
qr_text=TEST_TEXT,
|
| 520 |
input_type="URL",
|
| 521 |
image_size=512,
|
|
|
|
| 536 |
list(
|
| 537 |
_pipeline_artistic(
|
| 538 |
prompt=TEST_PROMPT,
|
| 539 |
+
negative_prompt="ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 540 |
qr_text=TEST_TEXT,
|
| 541 |
input_type="URL",
|
| 542 |
image_size=640,
|
|
|
|
| 573 |
@spaces.GPU(duration=60) # Reduced from 720s - AOTI compilation speeds up inference
|
| 574 |
def generate_qr_code_unified(
|
| 575 |
prompt: str,
|
| 576 |
+
negative_prompt: str = "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 577 |
+
text_input: str = "",
|
| 578 |
input_type: str = "URL",
|
| 579 |
image_size: int = 512,
|
| 580 |
border_size: int = 4,
|
|
|
|
| 621 |
with torch.inference_mode():
|
| 622 |
if pipeline == "standard":
|
| 623 |
yield from _pipeline_standard(
|
| 624 |
+
prompt=prompt,
|
| 625 |
+
negative_prompt=negative_prompt,
|
| 626 |
+
qr_text=qr_text,
|
| 627 |
+
input_type=input_type,
|
| 628 |
+
image_size=image_size,
|
| 629 |
+
border_size=border_size,
|
| 630 |
+
error_correction=error_correction,
|
| 631 |
+
module_size=module_size,
|
| 632 |
+
module_drawer=module_drawer,
|
| 633 |
+
seed=actual_seed,
|
| 634 |
+
enable_upscale=enable_upscale,
|
| 635 |
+
controlnet_strength_first=controlnet_strength_standard_first,
|
| 636 |
+
controlnet_strength_final=controlnet_strength_standard_final,
|
| 637 |
+
enable_color_quantization=enable_color_quantization,
|
| 638 |
+
num_colors=num_colors,
|
| 639 |
+
color_1=color_1,
|
| 640 |
+
color_2=color_2,
|
| 641 |
+
color_3=color_3,
|
| 642 |
+
color_4=color_4,
|
| 643 |
+
apply_gradient_filter=apply_gradient_filter,
|
| 644 |
+
gradient_strength=gradient_strength,
|
| 645 |
+
variation_steps=variation_steps,
|
| 646 |
+
gr_progress=progress,
|
| 647 |
)
|
| 648 |
else: # artistic
|
| 649 |
yield from _pipeline_artistic(
|
| 650 |
+
prompt=prompt,
|
| 651 |
+
negative_prompt=negative_prompt,
|
| 652 |
+
qr_text=qr_text,
|
| 653 |
+
input_type=input_type,
|
| 654 |
+
image_size=image_size,
|
| 655 |
+
border_size=border_size,
|
| 656 |
+
error_correction=error_correction,
|
| 657 |
+
module_size=module_size,
|
| 658 |
+
module_drawer=module_drawer,
|
| 659 |
+
seed=actual_seed,
|
| 660 |
+
enable_upscale=enable_upscale,
|
| 661 |
+
freeu_b1=freeu_b1,
|
| 662 |
+
freeu_b2=freeu_b2,
|
| 663 |
+
freeu_s1=freeu_s1,
|
| 664 |
+
freeu_s2=freeu_s2,
|
| 665 |
+
enable_sag=enable_sag,
|
| 666 |
+
sag_scale=sag_scale,
|
| 667 |
+
sag_blur_sigma=sag_blur_sigma,
|
| 668 |
+
controlnet_strength_first=controlnet_strength_first,
|
| 669 |
+
controlnet_strength_final=controlnet_strength_final,
|
| 670 |
+
enable_color_quantization=enable_color_quantization,
|
| 671 |
+
num_colors=num_colors,
|
| 672 |
+
color_1=color_1,
|
| 673 |
+
color_2=color_2,
|
| 674 |
+
color_3=color_3,
|
| 675 |
+
color_4=color_4,
|
| 676 |
+
apply_gradient_filter=apply_gradient_filter,
|
| 677 |
+
gradient_strength=gradient_strength,
|
| 678 |
+
variation_steps=variation_steps,
|
| 679 |
+
gr_progress=progress,
|
| 680 |
)
|
| 681 |
|
| 682 |
|
|
|
|
| 871 |
|
| 872 |
def generate_standard_qr(
|
| 873 |
prompt: str,
|
| 874 |
+
negative_prompt: str = "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 875 |
+
text_input: str = "",
|
| 876 |
input_type: str = "URL",
|
| 877 |
image_size: int = 512,
|
| 878 |
border_size: int = 4,
|
|
|
|
| 904 |
settings_dict = {
|
| 905 |
"pipeline": "standard",
|
| 906 |
"prompt": prompt,
|
| 907 |
+
"negative_prompt": negative_prompt,
|
| 908 |
"text_input": text_input,
|
| 909 |
"input_type": input_type,
|
| 910 |
"image_size": image_size,
|
|
|
|
| 933 |
# Generate QR and yield progressive results
|
| 934 |
generator = generate_qr_code_unified(
|
| 935 |
prompt,
|
| 936 |
+
negative_prompt,
|
| 937 |
text_input,
|
| 938 |
input_type,
|
| 939 |
image_size,
|
|
|
|
| 980 |
|
| 981 |
def generate_artistic_qr(
|
| 982 |
prompt: str,
|
| 983 |
+
negative_prompt: str = "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 984 |
+
text_input: str = "",
|
| 985 |
input_type: str = "URL",
|
| 986 |
image_size: int = 512,
|
| 987 |
border_size: int = 4,
|
|
|
|
| 1020 |
settings_dict = {
|
| 1021 |
"pipeline": "artistic",
|
| 1022 |
"prompt": prompt,
|
| 1023 |
+
"negative_prompt": negative_prompt,
|
| 1024 |
"text_input": text_input,
|
| 1025 |
"input_type": input_type,
|
| 1026 |
"image_size": image_size,
|
|
|
|
| 1056 |
# Generate QR and yield progressive results
|
| 1057 |
generator = generate_qr_code_unified(
|
| 1058 |
prompt,
|
| 1059 |
+
negative_prompt,
|
| 1060 |
text_input,
|
| 1061 |
input_type,
|
| 1062 |
image_size,
|
|
|
|
| 1172 |
gr.update(),
|
| 1173 |
gr.update(),
|
| 1174 |
gr.update(),
|
| 1175 |
+
gr.update(),
|
| 1176 |
gr.update(value=error_msg, visible=True),
|
| 1177 |
)
|
| 1178 |
|
| 1179 |
# Extract parameters with defaults
|
| 1180 |
prompt = params.get("prompt", "")
|
| 1181 |
+
negative_prompt = params.get(
|
| 1182 |
+
"negative_prompt",
|
| 1183 |
+
"ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 1184 |
+
)
|
| 1185 |
text_input = params.get("text_input", "")
|
| 1186 |
input_type = params.get("input_type", "URL")
|
| 1187 |
image_size = params.get("image_size", 512)
|
|
|
|
| 1212 |
success_msg = "✅ Settings loaded successfully!"
|
| 1213 |
return (
|
| 1214 |
prompt,
|
| 1215 |
+
negative_prompt,
|
| 1216 |
text_input,
|
| 1217 |
input_type,
|
| 1218 |
image_size,
|
|
|
|
| 1264 |
gr.update(),
|
| 1265 |
gr.update(),
|
| 1266 |
gr.update(),
|
| 1267 |
+
gr.update(),
|
| 1268 |
gr.update(value=error_msg, visible=True),
|
| 1269 |
)
|
| 1270 |
except Exception as e:
|
|
|
|
| 1293 |
gr.update(),
|
| 1294 |
gr.update(),
|
| 1295 |
gr.update(),
|
| 1296 |
+
gr.update(),
|
| 1297 |
gr.update(value=error_msg, visible=True),
|
| 1298 |
)
|
| 1299 |
|
|
|
|
| 1341 |
gr.update(),
|
| 1342 |
gr.update(),
|
| 1343 |
gr.update(),
|
| 1344 |
+
gr.update(),
|
| 1345 |
gr.update(value=error_msg, visible=True),
|
| 1346 |
)
|
| 1347 |
|
| 1348 |
# Extract parameters with defaults
|
| 1349 |
prompt = params.get("prompt", "")
|
| 1350 |
+
negative_prompt = params.get(
|
| 1351 |
+
"negative_prompt",
|
| 1352 |
+
"ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 1353 |
+
)
|
| 1354 |
text_input = params.get("text_input", "")
|
| 1355 |
input_type = params.get("input_type", "URL")
|
| 1356 |
image_size = params.get("image_size", 704)
|
|
|
|
| 1384 |
success_msg = "✅ Settings loaded successfully!"
|
| 1385 |
return (
|
| 1386 |
prompt,
|
| 1387 |
+
negative_prompt,
|
| 1388 |
text_input,
|
| 1389 |
input_type,
|
| 1390 |
image_size,
|
|
|
|
| 1450 |
gr.update(),
|
| 1451 |
gr.update(),
|
| 1452 |
gr.update(),
|
| 1453 |
+
gr.update(),
|
| 1454 |
gr.update(value=error_msg, visible=True),
|
| 1455 |
)
|
| 1456 |
except Exception as e:
|
|
|
|
| 1486 |
gr.update(),
|
| 1487 |
gr.update(),
|
| 1488 |
gr.update(),
|
| 1489 |
+
gr.update(),
|
| 1490 |
gr.update(value=error_msg, visible=True),
|
| 1491 |
)
|
| 1492 |
|
|
|
|
| 1583 |
|
| 1584 |
def _pipeline_standard(
|
| 1585 |
prompt: str,
|
| 1586 |
+
negative_prompt: str = "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 1587 |
+
qr_text: str = "",
|
| 1588 |
+
input_type: str = "URL",
|
| 1589 |
+
image_size: int = 512,
|
| 1590 |
+
border_size: int = 4,
|
| 1591 |
+
error_correction: str = "Medium (15%)",
|
| 1592 |
+
module_size: int = 12,
|
| 1593 |
+
module_drawer: str = "Square",
|
| 1594 |
+
seed: int = 0,
|
| 1595 |
enable_upscale: bool = False,
|
| 1596 |
controlnet_strength_first: float = 0.45,
|
| 1597 |
controlnet_strength_final: float = 1.0,
|
|
|
|
| 1616 |
)
|
| 1617 |
|
| 1618 |
cliptextencode_7 = cliptextencode.encode(
|
| 1619 |
+
text=negative_prompt,
|
| 1620 |
clip=get_value_at_index(checkpointloadersimple_4, 1),
|
| 1621 |
)
|
| 1622 |
|
|
|
|
| 1859 |
|
| 1860 |
def _pipeline_artistic(
|
| 1861 |
prompt: str,
|
| 1862 |
+
negative_prompt: str = "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 1863 |
+
qr_text: str = "",
|
| 1864 |
+
input_type: str = "URL",
|
| 1865 |
+
image_size: int = 640,
|
| 1866 |
+
border_size: int = 4,
|
| 1867 |
+
error_correction: str = "Medium (15%)",
|
| 1868 |
+
module_size: int = 12,
|
| 1869 |
+
module_drawer: str = "Square",
|
| 1870 |
+
seed: int = 0,
|
| 1871 |
enable_upscale: bool = True,
|
| 1872 |
freeu_b1: float = 1.4,
|
| 1873 |
freeu_b2: float = 1.3,
|
|
|
|
| 1973 |
clip=get_value_at_index(checkpointloadersimple_artistic, 1),
|
| 1974 |
)
|
| 1975 |
|
| 1976 |
+
negative_prompt_encoded = cliptextencode.encode(
|
| 1977 |
+
text=negative_prompt,
|
| 1978 |
clip=get_value_at_index(checkpointloadersimple_artistic, 1),
|
| 1979 |
)
|
| 1980 |
|
|
|
|
| 1993 |
start_percent=0,
|
| 1994 |
end_percent=1,
|
| 1995 |
positive=get_value_at_index(positive_prompt, 0),
|
| 1996 |
+
negative=get_value_at_index(negative_prompt_encoded, 0),
|
| 1997 |
control_net=get_value_at_index(brightness_controlnet, 0),
|
| 1998 |
image=qr_with_border_noise,
|
| 1999 |
vae=get_value_at_index(checkpointloadersimple_artistic, 2),
|
|
|
|
| 2089 |
start_percent=0,
|
| 2090 |
end_percent=1,
|
| 2091 |
positive=get_value_at_index(positive_prompt, 0),
|
| 2092 |
+
negative=get_value_at_index(negative_prompt_encoded, 0),
|
| 2093 |
control_net=get_value_at_index(tile_controlnet, 0),
|
| 2094 |
image=get_value_at_index(decoded, 0),
|
| 2095 |
vae=get_value_at_index(checkpointloadersimple_artistic, 2),
|
|
|
|
| 2294 |
|
| 2295 |
# Change Settings Manually - separate accordion
|
| 2296 |
with gr.Accordion("Change Settings Manually", open=False):
|
| 2297 |
+
# Negative Prompt
|
| 2298 |
+
negative_prompt_artistic = gr.Textbox(
|
| 2299 |
+
label="Negative Prompt",
|
| 2300 |
+
placeholder="Describe what you don't want in the image",
|
| 2301 |
+
value="ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 2302 |
+
lines=2,
|
| 2303 |
+
info="Keywords to avoid in the generated image",
|
| 2304 |
+
)
|
| 2305 |
+
|
| 2306 |
# Add image size slider for artistic QR
|
| 2307 |
artistic_image_size = gr.Slider(
|
| 2308 |
minimum=512,
|
|
|
|
| 2667 |
fn=generate_artistic_qr,
|
| 2668 |
inputs=[
|
| 2669 |
artistic_prompt_input,
|
| 2670 |
+
negative_prompt_artistic,
|
| 2671 |
artistic_text_input,
|
| 2672 |
artistic_input_type,
|
| 2673 |
artistic_image_size,
|
|
|
|
| 2712 |
inputs=[import_json_input_artistic],
|
| 2713 |
outputs=[
|
| 2714 |
artistic_prompt_input,
|
| 2715 |
+
negative_prompt_artistic,
|
| 2716 |
artistic_text_input,
|
| 2717 |
artistic_input_type,
|
| 2718 |
artistic_image_size,
|
|
|
|
| 3213 |
|
| 3214 |
# Change Settings Manually - separate accordion
|
| 3215 |
with gr.Accordion("Change Settings Manually", open=False):
|
| 3216 |
+
# Negative Prompt
|
| 3217 |
+
negative_prompt_standard = gr.Textbox(
|
| 3218 |
+
label="Negative Prompt",
|
| 3219 |
+
placeholder="Describe what you don't want in the image",
|
| 3220 |
+
value="ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, closed eyes, text, logo",
|
| 3221 |
+
lines=2,
|
| 3222 |
+
info="Keywords to avoid in the generated image",
|
| 3223 |
+
)
|
| 3224 |
+
|
| 3225 |
# Add image size slider
|
| 3226 |
image_size = gr.Slider(
|
| 3227 |
minimum=512,
|
|
|
|
| 3523 |
fn=generate_standard_qr,
|
| 3524 |
inputs=[
|
| 3525 |
prompt_input,
|
| 3526 |
+
negative_prompt_standard,
|
| 3527 |
text_input,
|
| 3528 |
input_type,
|
| 3529 |
image_size,
|
|
|
|
| 3561 |
inputs=[import_json_input_standard],
|
| 3562 |
outputs=[
|
| 3563 |
prompt_input,
|
| 3564 |
+
negative_prompt_standard,
|
| 3565 |
text_input,
|
| 3566 |
input_type,
|
| 3567 |
image_size,
|