Spaces:
Running
on
Zero
Running
on
Zero
Upload 4 files
Browse files- app.py +58 -30
- constants.py +20 -15
- requirements.txt +1 -1
- utils.py +2 -2
app.py
CHANGED
|
@@ -6,8 +6,10 @@ from stablepy import (
|
|
| 6 |
SCHEDULE_PREDICTION_TYPE_OPTIONS,
|
| 7 |
check_scheduler_compatibility,
|
| 8 |
TASK_AND_PREPROCESSORS,
|
|
|
|
| 9 |
)
|
| 10 |
from constants import (
|
|
|
|
| 11 |
TASK_STABLEPY,
|
| 12 |
TASK_MODEL_LIST,
|
| 13 |
UPSCALER_DICT_GUI,
|
|
@@ -77,6 +79,10 @@ download_private_repo(HF_LORA_ESSENTIAL_PRIVATE_REPO, DIRECTORY_LORAS, True)
|
|
| 77 |
download_private_repo(HF_VAE_PRIVATE_REPO, DIRECTORY_VAES, False)
|
| 78 |
## END MOD
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
# - **Download Models**
|
| 81 |
DOWNLOAD_MODEL = ", ".join(DOWNLOAD_MODEL_LIST)
|
| 82 |
# - **Download VAEs**
|
|
@@ -129,6 +135,7 @@ flux_pipe = FluxPipeline.from_pretrained(
|
|
| 129 |
components = flux_pipe.components
|
| 130 |
components.pop("transformer", None)
|
| 131 |
delete_model(flux_repo)
|
|
|
|
| 132 |
|
| 133 |
#######################
|
| 134 |
# GUI
|
|
@@ -331,8 +338,8 @@ class GuiSD:
|
|
| 331 |
syntax_weights,
|
| 332 |
upscaler_model_path,
|
| 333 |
upscaler_increases_size,
|
| 334 |
-
|
| 335 |
-
|
| 336 |
hires_steps,
|
| 337 |
hires_denoising_strength,
|
| 338 |
hires_sampler,
|
|
@@ -396,6 +403,9 @@ class GuiSD:
|
|
| 396 |
mode_ip2,
|
| 397 |
scale_ip2,
|
| 398 |
pag_scale,
|
|
|
|
|
|
|
|
|
|
| 399 |
):
|
| 400 |
info_state = html_template_message("Navigating latent space...")
|
| 401 |
yield info_state, gr.update(), gr.update()
|
|
@@ -448,18 +458,15 @@ class GuiSD:
|
|
| 448 |
if task == "inpaint" and not image_mask:
|
| 449 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
| 450 |
|
| 451 |
-
if
|
| 452 |
upscaler_model = upscaler_model_path
|
| 453 |
else:
|
| 454 |
-
directory_upscalers = 'upscalers'
|
| 455 |
-
os.makedirs(directory_upscalers, exist_ok=True)
|
| 456 |
-
|
| 457 |
url_upscaler = UPSCALER_DICT_GUI[upscaler_model_path]
|
| 458 |
|
| 459 |
-
if not os.path.exists(f"./
|
| 460 |
-
download_things(
|
| 461 |
|
| 462 |
-
upscaler_model = f"./
|
| 463 |
|
| 464 |
logging.getLogger("ultralytics").setLevel(logging.INFO if adetailer_verbose else logging.ERROR)
|
| 465 |
|
|
@@ -563,8 +570,8 @@ class GuiSD:
|
|
| 563 |
"t2i_adapter_conditioning_factor": float(t2i_adapter_conditioning_factor),
|
| 564 |
"upscaler_model_path": upscaler_model,
|
| 565 |
"upscaler_increases_size": upscaler_increases_size,
|
| 566 |
-
"
|
| 567 |
-
"
|
| 568 |
"hires_steps": hires_steps,
|
| 569 |
"hires_denoising_strength": hires_denoising_strength,
|
| 570 |
"hires_prompt": hires_prompt,
|
|
@@ -579,6 +586,9 @@ class GuiSD:
|
|
| 579 |
"ip_adapter_model": params_ip_model,
|
| 580 |
"ip_adapter_mode": params_ip_mode,
|
| 581 |
"ip_adapter_scale": params_ip_scale,
|
|
|
|
|
|
|
|
|
|
| 582 |
}
|
| 583 |
|
| 584 |
# kwargs for diffusers pipeline
|
|
@@ -729,22 +739,26 @@ def sd_gen_generate_pipeline(*args):
|
|
| 729 |
|
| 730 |
|
| 731 |
@spaces.GPU(duration=15)
|
| 732 |
-
def
|
| 733 |
if image is None: return None
|
| 734 |
|
| 735 |
from stablepy.diffusers_vanilla.utils import save_pil_image_with_metadata
|
| 736 |
-
from stablepy import
|
| 737 |
|
|
|
|
| 738 |
exif_image = extract_exif_data(image)
|
| 739 |
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
if not os.path.exists(f"./upscalers/{url_upscaler.split('/')[-1]}"):
|
| 744 |
-
download_things(directory_upscalers, url_upscaler, HF_TOKEN)
|
| 745 |
|
| 746 |
-
|
| 747 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 748 |
|
| 749 |
image_path = save_pil_image_with_metadata(image_up, f'{os.getcwd()}/up_images', exif_image)
|
| 750 |
|
|
@@ -875,9 +889,8 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 875 |
actual_task_info = gr.HTML()
|
| 876 |
|
| 877 |
with gr.Accordion("History", open=False):
|
| 878 |
-
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", format="png", interactive=False, show_share_button=False,
|
| 879 |
-
show_download_button=True)
|
| 880 |
history_files = gr.Files(interactive=False, visible=False)
|
|
|
|
| 881 |
history_clear_button = gr.Button(value="Clear History", variant="secondary")
|
| 882 |
history_clear_button.click(lambda: ([], []), None, [history_gallery, history_files], queue=False, show_api=False)
|
| 883 |
|
|
@@ -1106,8 +1119,8 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 1106 |
upscaler_model_path_gui = gr.Dropdown(label="Upscaler", choices=UPSCALER_KEYS, value=UPSCALER_KEYS[0])
|
| 1107 |
with gr.Row():
|
| 1108 |
upscaler_increases_size_gui = gr.Slider(minimum=1.1, maximum=6., step=0.1, value=1.0, label="Upscale by")
|
| 1109 |
-
|
| 1110 |
-
|
| 1111 |
with gr.Row():
|
| 1112 |
hires_steps_gui = gr.Slider(minimum=0, value=30, maximum=100, step=1, label="Hires Steps")
|
| 1113 |
hires_denoising_strength_gui = gr.Slider(minimum=0.1, maximum=1.0, step=0.01, value=0.55, label="Hires Denoising Strength")
|
|
@@ -1159,7 +1172,16 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 1159 |
mask_dilation_b_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
|
| 1160 |
mask_blur_b_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
|
| 1161 |
mask_padding_b_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
|
| 1162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1163 |
with gr.Accordion("Textual inversion", open=False, visible=True) as menu_ti:
|
| 1164 |
active_textual_inversion_gui = gr.Checkbox(value=False, label="Active Textual Inversion in prompt")
|
| 1165 |
use_textual_inversion_gui = gr.CheckboxGroup(choices=get_embed_list(get_model_pipeline(model_name_gui.value)) if active_textual_inversion_gui.value else [], value=None, label="Use Textual Invertion in prompt")
|
|
@@ -1175,7 +1197,7 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 1175 |
with gr.Row():
|
| 1176 |
strength_gui = gr.Slider(
|
| 1177 |
minimum=0.01, maximum=1.0, step=0.01, value=0.55, label="Strength",
|
| 1178 |
-
info="This option adjusts the level of changes for img2img and
|
| 1179 |
)
|
| 1180 |
image_resolution_gui = gr.Slider(
|
| 1181 |
minimum=64, maximum=2048, step=64, value=1024, label="Image Resolution",
|
|
@@ -1395,8 +1417,11 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 1395 |
with gr.Tab("Upscaler"):
|
| 1396 |
with gr.Row():
|
| 1397 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
| 1398 |
image_up_tab = gr.Image(label="Image", type="pil", sources=["upload"])
|
| 1399 |
-
upscaler_tab = gr.Dropdown(label="Upscaler", choices=
|
| 1400 |
upscaler_size_tab = gr.Slider(minimum=1., maximum=4., step=0.1, value=1.1, label="Upscale by")
|
| 1401 |
generate_button_up_tab = gr.Button(value="START UPSCALE", variant="primary")
|
| 1402 |
|
|
@@ -1404,7 +1429,7 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 1404 |
result_up_tab = gr.Image(label="Result", type="pil", interactive=False, format="png")
|
| 1405 |
|
| 1406 |
generate_button_up_tab.click(
|
| 1407 |
-
fn=
|
| 1408 |
inputs=[image_up_tab, upscaler_tab, upscaler_size_tab],
|
| 1409 |
outputs=[result_up_tab],
|
| 1410 |
)
|
|
@@ -1586,8 +1611,8 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 1586 |
prompt_syntax_gui,
|
| 1587 |
upscaler_model_path_gui,
|
| 1588 |
upscaler_increases_size_gui,
|
| 1589 |
-
|
| 1590 |
-
|
| 1591 |
hires_steps_gui,
|
| 1592 |
hires_denoising_strength_gui,
|
| 1593 |
hires_sampler_gui,
|
|
@@ -1651,6 +1676,9 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', elem_id="main", fill_width=True, cs
|
|
| 1651 |
mode_ip2,
|
| 1652 |
scale_ip2,
|
| 1653 |
pag_scale_gui,
|
|
|
|
|
|
|
|
|
|
| 1654 |
load_lora_cpu_gui,
|
| 1655 |
verbose_info_gui,
|
| 1656 |
gpu_duration_gui,
|
|
|
|
| 6 |
SCHEDULE_PREDICTION_TYPE_OPTIONS,
|
| 7 |
check_scheduler_compatibility,
|
| 8 |
TASK_AND_PREPROCESSORS,
|
| 9 |
+
FACE_RESTORATION_MODELS,
|
| 10 |
)
|
| 11 |
from constants import (
|
| 12 |
+
DIRECTORY_UPSCALERS,
|
| 13 |
TASK_STABLEPY,
|
| 14 |
TASK_MODEL_LIST,
|
| 15 |
UPSCALER_DICT_GUI,
|
|
|
|
| 79 |
download_private_repo(HF_VAE_PRIVATE_REPO, DIRECTORY_VAES, False)
|
| 80 |
## END MOD
|
| 81 |
|
| 82 |
+
directories = [DIRECTORY_MODELS, DIRECTORY_LORAS, DIRECTORY_VAES, DIRECTORY_EMBEDS, DIRECTORY_UPSCALERS]
|
| 83 |
+
for directory in directories:
|
| 84 |
+
os.makedirs(directory, exist_ok=True)
|
| 85 |
+
|
| 86 |
# - **Download Models**
|
| 87 |
DOWNLOAD_MODEL = ", ".join(DOWNLOAD_MODEL_LIST)
|
| 88 |
# - **Download VAEs**
|
|
|
|
| 135 |
components = flux_pipe.components
|
| 136 |
components.pop("transformer", None)
|
| 137 |
delete_model(flux_repo)
|
| 138 |
+
# components = None
|
| 139 |
|
| 140 |
#######################
|
| 141 |
# GUI
|
|
|
|
| 338 |
syntax_weights,
|
| 339 |
upscaler_model_path,
|
| 340 |
upscaler_increases_size,
|
| 341 |
+
upscaler_tile_size,
|
| 342 |
+
upscaler_tile_overlap,
|
| 343 |
hires_steps,
|
| 344 |
hires_denoising_strength,
|
| 345 |
hires_sampler,
|
|
|
|
| 403 |
mode_ip2,
|
| 404 |
scale_ip2,
|
| 405 |
pag_scale,
|
| 406 |
+
face_restoration_model,
|
| 407 |
+
face_restoration_visibility,
|
| 408 |
+
face_restoration_weight,
|
| 409 |
):
|
| 410 |
info_state = html_template_message("Navigating latent space...")
|
| 411 |
yield info_state, gr.update(), gr.update()
|
|
|
|
| 458 |
if task == "inpaint" and not image_mask:
|
| 459 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
| 460 |
|
| 461 |
+
if "https://" not in str(UPSCALER_DICT_GUI[upscaler_model_path]):
|
| 462 |
upscaler_model = upscaler_model_path
|
| 463 |
else:
|
|
|
|
|
|
|
|
|
|
| 464 |
url_upscaler = UPSCALER_DICT_GUI[upscaler_model_path]
|
| 465 |
|
| 466 |
+
if not os.path.exists(f"./{DIRECTORY_UPSCALERS}/{url_upscaler.split('/')[-1]}"):
|
| 467 |
+
download_things(DIRECTORY_UPSCALERS, url_upscaler, HF_TOKEN)
|
| 468 |
|
| 469 |
+
upscaler_model = f"./{DIRECTORY_UPSCALERS}/{url_upscaler.split('/')[-1]}"
|
| 470 |
|
| 471 |
logging.getLogger("ultralytics").setLevel(logging.INFO if adetailer_verbose else logging.ERROR)
|
| 472 |
|
|
|
|
| 570 |
"t2i_adapter_conditioning_factor": float(t2i_adapter_conditioning_factor),
|
| 571 |
"upscaler_model_path": upscaler_model,
|
| 572 |
"upscaler_increases_size": upscaler_increases_size,
|
| 573 |
+
"upscaler_tile_size": upscaler_tile_size,
|
| 574 |
+
"upscaler_tile_overlap": upscaler_tile_overlap,
|
| 575 |
"hires_steps": hires_steps,
|
| 576 |
"hires_denoising_strength": hires_denoising_strength,
|
| 577 |
"hires_prompt": hires_prompt,
|
|
|
|
| 586 |
"ip_adapter_model": params_ip_model,
|
| 587 |
"ip_adapter_mode": params_ip_mode,
|
| 588 |
"ip_adapter_scale": params_ip_scale,
|
| 589 |
+
"face_restoration_model": face_restoration_model,
|
| 590 |
+
"face_restoration_visibility": face_restoration_visibility,
|
| 591 |
+
"face_restoration_weight": face_restoration_weight,
|
| 592 |
}
|
| 593 |
|
| 594 |
# kwargs for diffusers pipeline
|
|
|
|
| 739 |
|
| 740 |
|
| 741 |
@spaces.GPU(duration=15)
|
| 742 |
+
def process_upscale(image, upscaler_name, upscaler_size):
|
| 743 |
if image is None: return None
|
| 744 |
|
| 745 |
from stablepy.diffusers_vanilla.utils import save_pil_image_with_metadata
|
| 746 |
+
from stablepy import load_upscaler_model
|
| 747 |
|
| 748 |
+
image = image.convert("RGB")
|
| 749 |
exif_image = extract_exif_data(image)
|
| 750 |
|
| 751 |
+
name_upscaler = UPSCALER_DICT_GUI[upscaler_name]
|
| 752 |
+
|
| 753 |
+
if "https://" in str(name_upscaler):
|
|
|
|
|
|
|
| 754 |
|
| 755 |
+
if not os.path.exists(f"./{DIRECTORY_UPSCALERS}/{name_upscaler.split('/')[-1]}"):
|
| 756 |
+
download_things(DIRECTORY_UPSCALERS, name_upscaler, HF_TOKEN)
|
| 757 |
+
|
| 758 |
+
name_upscaler = f"./{DIRECTORY_UPSCALERS}/{name_upscaler.split('/')[-1]}"
|
| 759 |
+
|
| 760 |
+
scaler_beta = load_upscaler_model(model=name_upscaler, tile=0, tile_overlap=8, device="cuda", half=True)
|
| 761 |
+
image_up = scaler_beta.upscale(image, upscaler_size, True)
|
| 762 |
|
| 763 |
image_path = save_pil_image_with_metadata(image_up, f'{os.getcwd()}/up_images', exif_image)
|
| 764 |
|
|
|
|
| 889 |
actual_task_info = gr.HTML()
|
| 890 |
|
| 891 |
with gr.Accordion("History", open=False):
|
|
|
|
|
|
|
| 892 |
history_files = gr.Files(interactive=False, visible=False)
|
| 893 |
+
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", format="png", interactive=False, show_share_button=False, show_download_button=True)
|
| 894 |
history_clear_button = gr.Button(value="Clear History", variant="secondary")
|
| 895 |
history_clear_button.click(lambda: ([], []), None, [history_gallery, history_files], queue=False, show_api=False)
|
| 896 |
|
|
|
|
| 1119 |
upscaler_model_path_gui = gr.Dropdown(label="Upscaler", choices=UPSCALER_KEYS, value=UPSCALER_KEYS[0])
|
| 1120 |
with gr.Row():
|
| 1121 |
upscaler_increases_size_gui = gr.Slider(minimum=1.1, maximum=6., step=0.1, value=1.0, label="Upscale by")
|
| 1122 |
+
upscaler_tile_size_gui = gr.Slider(minimum=0, maximum=512, step=16, value=0, label="Upscaler Tile Size", info="0 = no tiling")
|
| 1123 |
+
upscaler_tile_overlap_gui = gr.Slider(minimum=0, maximum=48, step=1, value=8, label="Upscaler Tile Overlap")
|
| 1124 |
with gr.Row():
|
| 1125 |
hires_steps_gui = gr.Slider(minimum=0, value=30, maximum=100, step=1, label="Hires Steps")
|
| 1126 |
hires_denoising_strength_gui = gr.Slider(minimum=0.1, maximum=1.0, step=0.01, value=0.55, label="Hires Denoising Strength")
|
|
|
|
| 1172 |
mask_dilation_b_gui = gr.Number(label="Mask dilation:", value=4, minimum=1)
|
| 1173 |
mask_blur_b_gui = gr.Number(label="Mask blur:", value=4, minimum=1)
|
| 1174 |
mask_padding_b_gui = gr.Number(label="Mask padding:", value=32, minimum=1)
|
| 1175 |
+
|
| 1176 |
+
with gr.Accordion("Face restoration", open=False, visible=True):
|
| 1177 |
+
|
| 1178 |
+
face_rest_options = [None] + FACE_RESTORATION_MODELS
|
| 1179 |
+
|
| 1180 |
+
face_restoration_model_gui = gr.Dropdown(label="Face restoration model", choices=face_rest_options, value=face_rest_options[0])
|
| 1181 |
+
with gr.Row():
|
| 1182 |
+
face_restoration_visibility_gui = gr.Slider(minimum=0., maximum=1., step=0.001, value=1., label="Visibility")
|
| 1183 |
+
face_restoration_weight_gui = gr.Slider(minimum=0., maximum=1., step=0.001, value=.5, label="Weight", info="(0 = maximum effect, 1 = minimum effect)")
|
| 1184 |
+
|
| 1185 |
with gr.Accordion("Textual inversion", open=False, visible=True) as menu_ti:
|
| 1186 |
active_textual_inversion_gui = gr.Checkbox(value=False, label="Active Textual Inversion in prompt")
|
| 1187 |
use_textual_inversion_gui = gr.CheckboxGroup(choices=get_embed_list(get_model_pipeline(model_name_gui.value)) if active_textual_inversion_gui.value else [], value=None, label="Use Textual Invertion in prompt")
|
|
|
|
| 1197 |
with gr.Row():
|
| 1198 |
strength_gui = gr.Slider(
|
| 1199 |
minimum=0.01, maximum=1.0, step=0.01, value=0.55, label="Strength",
|
| 1200 |
+
info="This option adjusts the level of changes for img2img, repaint and inpaint."
|
| 1201 |
)
|
| 1202 |
image_resolution_gui = gr.Slider(
|
| 1203 |
minimum=64, maximum=2048, step=64, value=1024, label="Image Resolution",
|
|
|
|
| 1417 |
with gr.Tab("Upscaler"):
|
| 1418 |
with gr.Row():
|
| 1419 |
with gr.Column():
|
| 1420 |
+
|
| 1421 |
+
USCALER_TAB_KEYS = [name for name in UPSCALER_KEYS[9:]]
|
| 1422 |
+
|
| 1423 |
image_up_tab = gr.Image(label="Image", type="pil", sources=["upload"])
|
| 1424 |
+
upscaler_tab = gr.Dropdown(label="Upscaler", choices=USCALER_TAB_KEYS, value=USCALER_TAB_KEYS[5])
|
| 1425 |
upscaler_size_tab = gr.Slider(minimum=1., maximum=4., step=0.1, value=1.1, label="Upscale by")
|
| 1426 |
generate_button_up_tab = gr.Button(value="START UPSCALE", variant="primary")
|
| 1427 |
|
|
|
|
| 1429 |
result_up_tab = gr.Image(label="Result", type="pil", interactive=False, format="png")
|
| 1430 |
|
| 1431 |
generate_button_up_tab.click(
|
| 1432 |
+
fn=process_upscale,
|
| 1433 |
inputs=[image_up_tab, upscaler_tab, upscaler_size_tab],
|
| 1434 |
outputs=[result_up_tab],
|
| 1435 |
)
|
|
|
|
| 1611 |
prompt_syntax_gui,
|
| 1612 |
upscaler_model_path_gui,
|
| 1613 |
upscaler_increases_size_gui,
|
| 1614 |
+
upscaler_tile_size_gui,
|
| 1615 |
+
upscaler_tile_overlap_gui,
|
| 1616 |
hires_steps_gui,
|
| 1617 |
hires_denoising_strength_gui,
|
| 1618 |
hires_sampler_gui,
|
|
|
|
| 1676 |
mode_ip2,
|
| 1677 |
scale_ip2,
|
| 1678 |
pag_scale_gui,
|
| 1679 |
+
face_restoration_model_gui,
|
| 1680 |
+
face_restoration_visibility_gui,
|
| 1681 |
+
face_restoration_weight_gui,
|
| 1682 |
load_lora_cpu_gui,
|
| 1683 |
verbose_info_gui,
|
| 1684 |
gpu_duration_gui,
|
constants.py
CHANGED
|
@@ -4,6 +4,7 @@ from stablepy import (
|
|
| 4 |
scheduler_names,
|
| 5 |
SD15_TASKS,
|
| 6 |
SDXL_TASKS,
|
|
|
|
| 7 |
)
|
| 8 |
|
| 9 |
# - **Download Models**
|
|
@@ -43,12 +44,19 @@ LOAD_DIFFUSERS_FORMAT_MODEL = [
|
|
| 43 |
'John6666/ntr-mix-illustrious-xl-noob-xl-ntrmix35-sdxl',
|
| 44 |
'John6666/ntr-mix-illustrious-xl-noob-xl-v777-sdxl',
|
| 45 |
'John6666/ntr-mix-illustrious-xl-noob-xl-v777forlora-sdxl',
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
'John6666/haruki-mix-illustrious-v10-sdxl',
|
| 47 |
'John6666/noobreal-v10-sdxl',
|
| 48 |
'John6666/complicated-noobai-merge-vprediction-sdxl',
|
|
|
|
|
|
|
| 49 |
'Laxhar/noobai-XL-Vpred-0.65s',
|
| 50 |
'Laxhar/noobai-XL-Vpred-0.65',
|
| 51 |
'Laxhar/noobai-XL-Vpred-0.6',
|
|
|
|
| 52 |
'John6666/noobai-xl-nai-xl-vpred05version-sdxl',
|
| 53 |
'John6666/noobai-fusion2-vpred-itercomp-v1-sdxl',
|
| 54 |
'John6666/noobai-xl-nai-xl-vpredtestversion-sdxl',
|
|
@@ -58,6 +66,7 @@ LOAD_DIFFUSERS_FORMAT_MODEL = [
|
|
| 58 |
'John6666/illustrious-pencil-xl-v200-sdxl',
|
| 59 |
'John6666/obsession-illustriousxl-v21-sdxl',
|
| 60 |
'John6666/obsession-illustriousxl-v30-sdxl',
|
|
|
|
| 61 |
'John6666/wai-nsfw-illustrious-v70-sdxl',
|
| 62 |
'John6666/illustrious-pony-mix-v3-sdxl',
|
| 63 |
'John6666/nova-anime-xl-illustriousv10-sdxl',
|
|
@@ -81,6 +90,7 @@ LOAD_DIFFUSERS_FORMAT_MODEL = [
|
|
| 81 |
'John6666/ras-real-anime-screencap-v1-sdxl',
|
| 82 |
'John6666/duchaiten-pony-xl-no-score-v60-sdxl',
|
| 83 |
'John6666/mistoon-anime-ponyalpha-sdxl',
|
|
|
|
| 84 |
'John6666/ebara-mfcg-pony-mix-v12-sdxl',
|
| 85 |
'John6666/t-ponynai3-v51-sdxl',
|
| 86 |
'John6666/t-ponynai3-v65-sdxl',
|
|
@@ -156,6 +166,7 @@ DIRECTORY_MODELS = 'models'
|
|
| 156 |
DIRECTORY_LORAS = 'loras'
|
| 157 |
DIRECTORY_VAES = 'vaes'
|
| 158 |
DIRECTORY_EMBEDS = 'embedings'
|
|
|
|
| 159 |
|
| 160 |
CACHE_HF = "/home/user/.cache/huggingface/hub/"
|
| 161 |
STORAGE_ROOT = "/home/user/"
|
|
@@ -184,27 +195,21 @@ TASK_STABLEPY = {
|
|
| 184 |
'optical pattern ControlNet': 'pattern',
|
| 185 |
'recolor ControlNet': 'recolor',
|
| 186 |
'tile ControlNet': 'tile',
|
|
|
|
| 187 |
}
|
| 188 |
|
| 189 |
TASK_MODEL_LIST = list(TASK_STABLEPY.keys())
|
| 190 |
|
| 191 |
UPSCALER_DICT_GUI = {
|
| 192 |
None: None,
|
| 193 |
-
"
|
| 194 |
-
"
|
| 195 |
-
'Latent': 'Latent',
|
| 196 |
-
'Latent (antialiased)': 'Latent (antialiased)',
|
| 197 |
-
'Latent (bicubic)': 'Latent (bicubic)',
|
| 198 |
-
'Latent (bicubic antialiased)': 'Latent (bicubic antialiased)',
|
| 199 |
-
'Latent (nearest)': 'Latent (nearest)',
|
| 200 |
-
'Latent (nearest-exact)': 'Latent (nearest-exact)',
|
| 201 |
-
"RealESRGAN_x4plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
|
| 202 |
"RealESRNet_x4plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
|
| 203 |
-
"RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
|
| 204 |
-
"RealESRGAN_x2plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth",
|
| 205 |
-
"realesr-animevideov3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth",
|
| 206 |
-
"realesr-general-x4v3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth",
|
| 207 |
-
"realesr-general-wdn-x4v3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth",
|
| 208 |
"4x-UltraSharp": "https://huggingface.co/Shandypur/ESRGAN-4x-UltraSharp/resolve/main/4x-UltraSharp.pth",
|
| 209 |
"4x_foolhardy_Remacri": "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth",
|
| 210 |
"Remacri4xExtraSmoother": "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/Remacri%204x%20ExtraSmoother.pth",
|
|
@@ -219,6 +224,7 @@ UPSCALER_KEYS = list(UPSCALER_DICT_GUI.keys())
|
|
| 219 |
DIFFUSERS_CONTROLNET_MODEL = [
|
| 220 |
"Automatic",
|
| 221 |
|
|
|
|
| 222 |
"xinsir/controlnet-union-sdxl-1.0",
|
| 223 |
"xinsir/anime-painter",
|
| 224 |
"Eugeoter/noob-sdxl-controlnet-canny",
|
|
@@ -241,7 +247,6 @@ DIFFUSERS_CONTROLNET_MODEL = [
|
|
| 241 |
"r3gm/controlnet-recolor-sdxl-fp16",
|
| 242 |
"r3gm/controlnet-openpose-twins-sdxl-1.0-fp16",
|
| 243 |
"r3gm/controlnet-qr-pattern-sdxl-fp16",
|
| 244 |
-
"brad-twinkl/controlnet-union-sdxl-1.0-promax",
|
| 245 |
"Yakonrus/SDXL_Controlnet_Tile_Realistic_v2",
|
| 246 |
"TheMistoAI/MistoLine",
|
| 247 |
"briaai/BRIA-2.3-ControlNet-Recoloring",
|
|
|
|
| 4 |
scheduler_names,
|
| 5 |
SD15_TASKS,
|
| 6 |
SDXL_TASKS,
|
| 7 |
+
ALL_BUILTIN_UPSCALERS,
|
| 8 |
)
|
| 9 |
|
| 10 |
# - **Download Models**
|
|
|
|
| 44 |
'John6666/ntr-mix-illustrious-xl-noob-xl-ntrmix35-sdxl',
|
| 45 |
'John6666/ntr-mix-illustrious-xl-noob-xl-v777-sdxl',
|
| 46 |
'John6666/ntr-mix-illustrious-xl-noob-xl-v777forlora-sdxl',
|
| 47 |
+
'John6666/ntr-mix-illustrious-xl-noob-xl-xi-sdxl',
|
| 48 |
+
'John6666/mistoon-anime-v10illustrious-sdxl',
|
| 49 |
+
'John6666/hassaku-xl-illustrious-v10-sdxl',
|
| 50 |
+
'John6666/hassaku-xl-illustrious-v10style-sdxl',
|
| 51 |
'John6666/haruki-mix-illustrious-v10-sdxl',
|
| 52 |
'John6666/noobreal-v10-sdxl',
|
| 53 |
'John6666/complicated-noobai-merge-vprediction-sdxl',
|
| 54 |
+
'Laxhar/noobai-XL-Vpred-0.75s',
|
| 55 |
+
'Laxhar/noobai-XL-Vpred-0.75',
|
| 56 |
'Laxhar/noobai-XL-Vpred-0.65s',
|
| 57 |
'Laxhar/noobai-XL-Vpred-0.65',
|
| 58 |
'Laxhar/noobai-XL-Vpred-0.6',
|
| 59 |
+
'John6666/cat-tower-noobai-xl-checkpoint-v14vpred-sdxl',
|
| 60 |
'John6666/noobai-xl-nai-xl-vpred05version-sdxl',
|
| 61 |
'John6666/noobai-fusion2-vpred-itercomp-v1-sdxl',
|
| 62 |
'John6666/noobai-xl-nai-xl-vpredtestversion-sdxl',
|
|
|
|
| 66 |
'John6666/illustrious-pencil-xl-v200-sdxl',
|
| 67 |
'John6666/obsession-illustriousxl-v21-sdxl',
|
| 68 |
'John6666/obsession-illustriousxl-v30-sdxl',
|
| 69 |
+
'John6666/obsession-illustriousxl-v31-sdxl',
|
| 70 |
'John6666/wai-nsfw-illustrious-v70-sdxl',
|
| 71 |
'John6666/illustrious-pony-mix-v3-sdxl',
|
| 72 |
'John6666/nova-anime-xl-illustriousv10-sdxl',
|
|
|
|
| 90 |
'John6666/ras-real-anime-screencap-v1-sdxl',
|
| 91 |
'John6666/duchaiten-pony-xl-no-score-v60-sdxl',
|
| 92 |
'John6666/mistoon-anime-ponyalpha-sdxl',
|
| 93 |
+
'John6666/mistoon-xl-copper-v20fast-sdxl',
|
| 94 |
'John6666/ebara-mfcg-pony-mix-v12-sdxl',
|
| 95 |
'John6666/t-ponynai3-v51-sdxl',
|
| 96 |
'John6666/t-ponynai3-v65-sdxl',
|
|
|
|
| 166 |
DIRECTORY_LORAS = 'loras'
|
| 167 |
DIRECTORY_VAES = 'vaes'
|
| 168 |
DIRECTORY_EMBEDS = 'embedings'
|
| 169 |
+
DIRECTORY_UPSCALERS = 'upscalers'
|
| 170 |
|
| 171 |
CACHE_HF = "/home/user/.cache/huggingface/hub/"
|
| 172 |
STORAGE_ROOT = "/home/user/"
|
|
|
|
| 195 |
'optical pattern ControlNet': 'pattern',
|
| 196 |
'recolor ControlNet': 'recolor',
|
| 197 |
'tile ControlNet': 'tile',
|
| 198 |
+
'repaint ControlNet': 'repaint',
|
| 199 |
}
|
| 200 |
|
| 201 |
TASK_MODEL_LIST = list(TASK_STABLEPY.keys())
|
| 202 |
|
| 203 |
UPSCALER_DICT_GUI = {
|
| 204 |
None: None,
|
| 205 |
+
**{bu: bu for bu in ALL_BUILTIN_UPSCALERS if bu not in ["HAT x4", "DAT x4", "DAT x3", "DAT x2", "SwinIR 4x"]},
|
| 206 |
+
# "RealESRGAN_x4plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
"RealESRNet_x4plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
|
| 208 |
+
# "RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
|
| 209 |
+
# "RealESRGAN_x2plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth",
|
| 210 |
+
# "realesr-animevideov3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth",
|
| 211 |
+
# "realesr-general-x4v3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth",
|
| 212 |
+
# "realesr-general-wdn-x4v3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth",
|
| 213 |
"4x-UltraSharp": "https://huggingface.co/Shandypur/ESRGAN-4x-UltraSharp/resolve/main/4x-UltraSharp.pth",
|
| 214 |
"4x_foolhardy_Remacri": "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth",
|
| 215 |
"Remacri4xExtraSmoother": "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/Remacri%204x%20ExtraSmoother.pth",
|
|
|
|
| 224 |
DIFFUSERS_CONTROLNET_MODEL = [
|
| 225 |
"Automatic",
|
| 226 |
|
| 227 |
+
"brad-twinkl/controlnet-union-sdxl-1.0-promax",
|
| 228 |
"xinsir/controlnet-union-sdxl-1.0",
|
| 229 |
"xinsir/anime-painter",
|
| 230 |
"Eugeoter/noob-sdxl-controlnet-canny",
|
|
|
|
| 247 |
"r3gm/controlnet-recolor-sdxl-fp16",
|
| 248 |
"r3gm/controlnet-openpose-twins-sdxl-1.0-fp16",
|
| 249 |
"r3gm/controlnet-qr-pattern-sdxl-fp16",
|
|
|
|
| 250 |
"Yakonrus/SDXL_Controlnet_Tile_Realistic_v2",
|
| 251 |
"TheMistoAI/MistoLine",
|
| 252 |
"briaai/BRIA-2.3-ControlNet-Recoloring",
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
git+https://github.com/R3gm/stablepy.git@
|
| 2 |
torch==2.2.0
|
| 3 |
numpy<2
|
| 4 |
gdown
|
|
|
|
| 1 |
+
git+https://github.com/R3gm/stablepy.git@5e66972 # -b refactor_sampler_fix
|
| 2 |
torch==2.2.0
|
| 3 |
numpy<2
|
| 4 |
gdown
|
utils.py
CHANGED
|
@@ -62,7 +62,7 @@ class ModelInformation:
|
|
| 62 |
self.download_url = json_data.get("downloadUrl", "")
|
| 63 |
self.model_url = f"https://civitai.com/models/{self.model_id}?modelVersionId={self.model_version_id}"
|
| 64 |
self.filename_url = next(
|
| 65 |
-
(v.get("name", "") for v in json_data.get("files", []) if str(self.model_version_id) in v.get("downloadUrl", "")), ""
|
| 66 |
)
|
| 67 |
self.filename_url = self.filename_url if self.filename_url else ""
|
| 68 |
self.description = json_data.get("description", "")
|
|
@@ -300,7 +300,7 @@ def get_model_type(repo_id: str):
|
|
| 300 |
default = "SD 1.5"
|
| 301 |
try:
|
| 302 |
if os.path.exists(repo_id):
|
| 303 |
-
tag = checkpoint_model_type(repo_id)
|
| 304 |
return DIFFUSECRAFT_CHECKPOINT_NAME[tag]
|
| 305 |
else:
|
| 306 |
model = api.model_info(repo_id=repo_id, timeout=5.0)
|
|
|
|
| 62 |
self.download_url = json_data.get("downloadUrl", "")
|
| 63 |
self.model_url = f"https://civitai.com/models/{self.model_id}?modelVersionId={self.model_version_id}"
|
| 64 |
self.filename_url = next(
|
| 65 |
+
(v.get("name", "") for v in reversed(json_data.get("files", [])) if str(self.model_version_id) in v.get("downloadUrl", "")), ""
|
| 66 |
)
|
| 67 |
self.filename_url = self.filename_url if self.filename_url else ""
|
| 68 |
self.description = json_data.get("description", "")
|
|
|
|
| 300 |
default = "SD 1.5"
|
| 301 |
try:
|
| 302 |
if os.path.exists(repo_id):
|
| 303 |
+
tag, _, _ = checkpoint_model_type(repo_id)
|
| 304 |
return DIFFUSECRAFT_CHECKPOINT_NAME[tag]
|
| 305 |
else:
|
| 306 |
model = api.model_info(repo_id=repo_id, timeout=5.0)
|