Commit
·
27e3c58
1
Parent(s):
fa06727
Add application file
Browse files- __pycache__/config.cpython-310.pyc +0 -0
- __pycache__/tags.cpython-310.pyc +0 -0
- __pycache__/utils.cpython-310.pyc +0 -0
- app.py +48 -4
- tags.py +5 -1
__pycache__/config.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/config.cpython-310.pyc and b/__pycache__/config.cpython-310.pyc differ
|
|
|
__pycache__/tags.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/tags.cpython-310.pyc and b/__pycache__/tags.cpython-310.pyc differ
|
|
|
__pycache__/utils.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/utils.cpython-310.pyc and b/__pycache__/utils.cpython-310.pyc differ
|
|
|
app.py
CHANGED
|
@@ -84,6 +84,23 @@ def generate(
|
|
| 84 |
upscaler_strength: float = 0.55,
|
| 85 |
upscale_by: float = 1.5,
|
| 86 |
add_quality_tags: bool = True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
progress=gr.Progress(track_tqdm=True),
|
| 88 |
):
|
| 89 |
generator = utils.seed_everything(seed)
|
|
@@ -96,6 +113,11 @@ def generate(
|
|
| 96 |
|
| 97 |
prompt = utils.add_wildcard(prompt, wildcard_files)
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
prompt, negative_prompt = utils.preprocess_prompt(
|
| 100 |
quality_prompt, quality_selector, prompt, negative_prompt, add_quality_tags
|
| 101 |
)
|
|
@@ -138,7 +160,7 @@ def generate(
|
|
| 138 |
"Model": DESCRIPTION,
|
| 139 |
"Model hash": "e3c47aedb0",
|
| 140 |
}
|
| 141 |
-
|
| 142 |
logger.info(json.dumps(metadata, indent=4))
|
| 143 |
|
| 144 |
try:
|
|
@@ -185,7 +207,7 @@ def generate(
|
|
| 185 |
for image_path in image_paths:
|
| 186 |
logger.info(f"Image saved as {image_path} with metadata")
|
| 187 |
|
| 188 |
-
return image_paths, metadata
|
| 189 |
except Exception as e:
|
| 190 |
logger.exception(f"An error occurred: {e}")
|
| 191 |
raise
|
|
@@ -256,7 +278,7 @@ with gr.Blocks(css="style.css", theme="NoCrypt/[email protected]") as demo:
|
|
| 256 |
value="Standard v3.1",
|
| 257 |
)
|
| 258 |
add_danbooru_tags = gr.Checkbox(
|
| 259 |
-
label="Add
|
| 260 |
)
|
| 261 |
with gr.Tab("Advanced Settings"):
|
| 262 |
with gr.Group():
|
|
@@ -646,6 +668,11 @@ with gr.Blocks(css="style.css", theme="NoCrypt/[email protected]") as demo:
|
|
| 646 |
preview=True,
|
| 647 |
show_label=False
|
| 648 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 649 |
with gr.Accordion(label="Generation Parameters", open=False):
|
| 650 |
gr_metadata = gr.JSON(label="metadata", show_label=False)
|
| 651 |
gr.Examples(
|
|
@@ -699,8 +726,25 @@ with gr.Blocks(css="style.css", theme="NoCrypt/[email protected]") as demo:
|
|
| 699 |
upscaler_strength,
|
| 700 |
upscale_by,
|
| 701 |
add_quality_tags,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 702 |
],
|
| 703 |
-
outputs=[result, gr_metadata],
|
| 704 |
api_name="run",
|
| 705 |
)
|
| 706 |
|
|
|
|
| 84 |
upscaler_strength: float = 0.55,
|
| 85 |
upscale_by: float = 1.5,
|
| 86 |
add_quality_tags: bool = True,
|
| 87 |
+
add_danbooru_tags: bool = False,
|
| 88 |
+
rating_tags: str = "general",
|
| 89 |
+
copyright_tags_list: list[str] = [],
|
| 90 |
+
character_tags_list: list[str] = [],
|
| 91 |
+
general_tags: str = "",
|
| 92 |
+
ban_tags: str = "",
|
| 93 |
+
do_cfg: bool = False,
|
| 94 |
+
cfg_scale: float = 1.5,
|
| 95 |
+
negative_tags: str = "",
|
| 96 |
+
total_token_length: str = "long",
|
| 97 |
+
max_new_tokens: int = 128,
|
| 98 |
+
min_new_tokens: int = 0,
|
| 99 |
+
temperature: float = 1.0,
|
| 100 |
+
top_p: float = 1.0,
|
| 101 |
+
top_k: int = 20,
|
| 102 |
+
num_beams: int = 1,
|
| 103 |
+
# model_backend: str = "Default",
|
| 104 |
progress=gr.Progress(track_tqdm=True),
|
| 105 |
):
|
| 106 |
generator = utils.seed_everything(seed)
|
|
|
|
| 113 |
|
| 114 |
prompt = utils.add_wildcard(prompt, wildcard_files)
|
| 115 |
|
| 116 |
+
generated_tags_animagine = ""
|
| 117 |
+
if add_danbooru_tags:
|
| 118 |
+
generated_tags_animagine = tags.add_tags(prompt, rating_tags, copyright_tags_list, character_tags_list, general_tags, ban_tags, do_cfg, cfg_scale, negative_tags, total_token_length, max_new_tokens, min_new_tokens, temperature, top_p, top_k, num_beams)
|
| 119 |
+
prompt = generated_tags_animagine.strip()
|
| 120 |
+
|
| 121 |
prompt, negative_prompt = utils.preprocess_prompt(
|
| 122 |
quality_prompt, quality_selector, prompt, negative_prompt, add_quality_tags
|
| 123 |
)
|
|
|
|
| 160 |
"Model": DESCRIPTION,
|
| 161 |
"Model hash": "e3c47aedb0",
|
| 162 |
}
|
| 163 |
+
|
| 164 |
logger.info(json.dumps(metadata, indent=4))
|
| 165 |
|
| 166 |
try:
|
|
|
|
| 207 |
for image_path in image_paths:
|
| 208 |
logger.info(f"Image saved as {image_path} with metadata")
|
| 209 |
|
| 210 |
+
return image_paths, metadata, generated_tags_animagine
|
| 211 |
except Exception as e:
|
| 212 |
logger.exception(f"An error occurred: {e}")
|
| 213 |
raise
|
|
|
|
| 278 |
value="Standard v3.1",
|
| 279 |
)
|
| 280 |
add_danbooru_tags = gr.Checkbox(
|
| 281 |
+
label="Add Generated Tags", value=False
|
| 282 |
)
|
| 283 |
with gr.Tab("Advanced Settings"):
|
| 284 |
with gr.Group():
|
|
|
|
| 668 |
preview=True,
|
| 669 |
show_label=False
|
| 670 |
)
|
| 671 |
+
generated_tags_animagine = gr.Textbox(
|
| 672 |
+
label="Generated tags (AnimagineXL v3 style order)",
|
| 673 |
+
# placeholder="tags will be here in Animagine v3 style order",
|
| 674 |
+
interactive=False,
|
| 675 |
+
)
|
| 676 |
with gr.Accordion(label="Generation Parameters", open=False):
|
| 677 |
gr_metadata = gr.JSON(label="metadata", show_label=False)
|
| 678 |
gr.Examples(
|
|
|
|
| 726 |
upscaler_strength,
|
| 727 |
upscale_by,
|
| 728 |
add_quality_tags,
|
| 729 |
+
add_danbooru_tags,
|
| 730 |
+
rating_dropdown,
|
| 731 |
+
copyright_tags_dropdown,
|
| 732 |
+
character_tags_dropdown,
|
| 733 |
+
general_tags_textbox,
|
| 734 |
+
ban_tags_textbox,
|
| 735 |
+
do_cfg_check,
|
| 736 |
+
cfg_scale_slider,
|
| 737 |
+
negative_tags_textbox,
|
| 738 |
+
total_token_length_radio,
|
| 739 |
+
max_new_tokens_slider,
|
| 740 |
+
min_new_tokens_slider,
|
| 741 |
+
temperature_slider,
|
| 742 |
+
top_p_slider,
|
| 743 |
+
top_k_slider,
|
| 744 |
+
num_beams_slider,
|
| 745 |
+
# model_backend_radio,
|
| 746 |
],
|
| 747 |
+
outputs=[result, gr_metadata, generated_tags_animagine],
|
| 748 |
api_name="run",
|
| 749 |
)
|
| 750 |
|
tags.py
CHANGED
|
@@ -397,4 +397,8 @@ def get_copyright_tags_list():
|
|
| 397 |
return COPYRIGHT_TAGS_LIST
|
| 398 |
|
| 399 |
def get_character_tags_list():
|
| 400 |
-
return CHARACTER_TAGS_LIST
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
return COPYRIGHT_TAGS_LIST
|
| 398 |
|
| 399 |
def get_character_tags_list():
|
| 400 |
+
return CHARACTER_TAGS_LIST
|
| 401 |
+
|
| 402 |
+
def add_tags(prompt, rating_tags, copyright_tags_list, character_tags_list, general_tags, ban_tags, do_cfg, cfg_scale, negative_tags, total_token_length, max_new_tokens, min_new_tokens, temperature, top_p, top_k, num_beams):
|
| 403 |
+
prompt = handle_inputs(rating_tags, copyright_tags_list, character_tags_list, general_tags, ban_tags, do_cfg, cfg_scale, negative_tags, total_token_length, max_new_tokens, min_new_tokens, temperature, top_p, top_k, num_beams)[2]
|
| 404 |
+
return prompt
|