Upload 2 files
Browse files
dc.py
CHANGED
|
@@ -91,14 +91,27 @@ preprocessor_controlnet = {
|
|
| 91 |
"None",
|
| 92 |
],
|
| 93 |
"canny": [
|
| 94 |
-
"Canny"
|
|
|
|
| 95 |
],
|
| 96 |
"mlsd": [
|
| 97 |
-
"MLSD"
|
|
|
|
| 98 |
],
|
| 99 |
"ip2p": [
|
| 100 |
"ip2p"
|
| 101 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
|
| 104 |
task_stablepy = {
|
|
@@ -119,16 +132,16 @@ task_stablepy = {
|
|
| 119 |
'depth ControlNet': 'depth',
|
| 120 |
'normalbae ControlNet': 'normalbae',
|
| 121 |
'lineart ControlNet': 'lineart',
|
| 122 |
-
|
| 123 |
'shuffle ControlNet': 'shuffle',
|
| 124 |
'ip2p ControlNet': 'ip2p',
|
| 125 |
'optical pattern ControlNet': 'pattern',
|
| 126 |
-
'
|
|
|
|
| 127 |
}
|
| 128 |
|
| 129 |
task_model_list = list(task_stablepy.keys())
|
| 130 |
|
| 131 |
-
|
| 132 |
def download_things(directory, url, hf_token="", civitai_api_key=""):
|
| 133 |
url = url.strip()
|
| 134 |
|
|
@@ -146,7 +159,7 @@ def download_things(directory, url, hf_token="", civitai_api_key=""):
|
|
| 146 |
if hf_token:
|
| 147 |
os.system(f"aria2c --console-log-level=error --summary-interval=10 --header={user_header} -c -x 16 -k 1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
|
| 148 |
else:
|
| 149 |
-
os.system
|
| 150 |
elif "civitai.com" in url:
|
| 151 |
if "?" in url:
|
| 152 |
url = url.split("?")[0]
|
|
@@ -161,7 +174,7 @@ def download_things(directory, url, hf_token="", civitai_api_key=""):
|
|
| 161 |
|
| 162 |
def get_model_list(directory_path):
|
| 163 |
model_list = []
|
| 164 |
-
valid_extensions = {'.ckpt'
|
| 165 |
|
| 166 |
for filename in os.listdir(directory_path):
|
| 167 |
if os.path.splitext(filename)[1] in valid_extensions:
|
|
@@ -173,17 +186,6 @@ def get_model_list(directory_path):
|
|
| 173 |
return model_list
|
| 174 |
|
| 175 |
|
| 176 |
-
def process_string(input_string):
|
| 177 |
-
parts = input_string.split('/')
|
| 178 |
-
|
| 179 |
-
if len(parts) == 2:
|
| 180 |
-
first_element = parts[1]
|
| 181 |
-
complete_string = input_string
|
| 182 |
-
result = (first_element, complete_string)
|
| 183 |
-
return result
|
| 184 |
-
else:
|
| 185 |
-
return None
|
| 186 |
-
|
| 187 |
## BEGIN MOD
|
| 188 |
from modutils import (to_list, list_uniq, list_sub, get_model_id_list, get_tupled_embed_list,
|
| 189 |
get_tupled_model_list, get_lora_model_list, download_private_repo)
|
|
@@ -242,9 +244,15 @@ def get_embed_list(pipeline_name):
|
|
| 242 |
print('\033[33m๐ Download and listing of valid models completed.\033[0m')
|
| 243 |
|
| 244 |
upscaler_dict_gui = {
|
| 245 |
-
None
|
| 246 |
-
"Lanczos"
|
| 247 |
-
"Nearest"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
"RealESRGAN_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
|
| 249 |
"RealESRNet_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
|
| 250 |
"RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
|
|
@@ -261,6 +269,8 @@ upscaler_dict_gui = {
|
|
| 261 |
"NickelbackFS4x" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/NickelbackFS%204x.pth"
|
| 262 |
}
|
| 263 |
|
|
|
|
|
|
|
| 264 |
|
| 265 |
def extract_parameters(input_string):
|
| 266 |
parameters = {}
|
|
@@ -459,6 +469,7 @@ class GuiSD:
|
|
| 459 |
model_ip2,
|
| 460 |
mode_ip2,
|
| 461 |
scale_ip2,
|
|
|
|
| 462 |
progress=gr.Progress(track_tqdm=True),
|
| 463 |
):
|
| 464 |
progress(0, desc="Preparing inference...")
|
|
@@ -542,7 +553,7 @@ class GuiSD:
|
|
| 542 |
if task == "inpaint" and not image_mask:
|
| 543 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
| 544 |
|
| 545 |
-
if upscaler_model_path in [
|
| 546 |
upscaler_model = upscaler_model_path
|
| 547 |
else:
|
| 548 |
directory_upscalers = 'upscalers'
|
|
@@ -608,6 +619,7 @@ class GuiSD:
|
|
| 608 |
"num_steps": steps,
|
| 609 |
"guidance_scale": cfg,
|
| 610 |
"clip_skip": clip_skip,
|
|
|
|
| 611 |
"seed": seed,
|
| 612 |
"image": image_control,
|
| 613 |
"preprocessor_name": preprocessor_name,
|
|
@@ -738,7 +750,7 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 738 |
False, True, 1, True, False, False, False, False, "./images", False, False, False, True, 1, 0.55,
|
| 739 |
False, False, False, True, False, "Use same sampler", False, "", "", 0.35, True, True, False, 4, 4, 32,
|
| 740 |
False, "", "", 0.35, True, True, False, 4, 4, 32,
|
| 741 |
-
True, None, None, "plus_face", "original", 0.7, None, None, "base", "style", 0.7, progress
|
| 742 |
)
|
| 743 |
|
| 744 |
progress(1, desc="Inference completed.")
|
|
|
|
| 91 |
"None",
|
| 92 |
],
|
| 93 |
"canny": [
|
| 94 |
+
"Canny",
|
| 95 |
+
"None",
|
| 96 |
],
|
| 97 |
"mlsd": [
|
| 98 |
+
"MLSD",
|
| 99 |
+
"None",
|
| 100 |
],
|
| 101 |
"ip2p": [
|
| 102 |
"ip2p"
|
| 103 |
],
|
| 104 |
+
"recolor": [
|
| 105 |
+
"Recolor luminance",
|
| 106 |
+
"Recolor intensity",
|
| 107 |
+
"None",
|
| 108 |
+
],
|
| 109 |
+
"tile": [
|
| 110 |
+
"Mild Blur",
|
| 111 |
+
"Moderate Blur",
|
| 112 |
+
"Heavy Blur",
|
| 113 |
+
"None",
|
| 114 |
+
],
|
| 115 |
}
|
| 116 |
|
| 117 |
task_stablepy = {
|
|
|
|
| 132 |
'depth ControlNet': 'depth',
|
| 133 |
'normalbae ControlNet': 'normalbae',
|
| 134 |
'lineart ControlNet': 'lineart',
|
| 135 |
+
'lineart_anime ControlNet': 'lineart_anime',
|
| 136 |
'shuffle ControlNet': 'shuffle',
|
| 137 |
'ip2p ControlNet': 'ip2p',
|
| 138 |
'optical pattern ControlNet': 'pattern',
|
| 139 |
+
'recolor ControlNet': 'recolor',
|
| 140 |
+
'tile ControlNet': 'tile',
|
| 141 |
}
|
| 142 |
|
| 143 |
task_model_list = list(task_stablepy.keys())
|
| 144 |
|
|
|
|
| 145 |
def download_things(directory, url, hf_token="", civitai_api_key=""):
|
| 146 |
url = url.strip()
|
| 147 |
|
|
|
|
| 159 |
if hf_token:
|
| 160 |
os.system(f"aria2c --console-log-level=error --summary-interval=10 --header={user_header} -c -x 16 -k 1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
|
| 161 |
else:
|
| 162 |
+
os.system(f"aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
|
| 163 |
elif "civitai.com" in url:
|
| 164 |
if "?" in url:
|
| 165 |
url = url.split("?")[0]
|
|
|
|
| 174 |
|
| 175 |
def get_model_list(directory_path):
|
| 176 |
model_list = []
|
| 177 |
+
valid_extensions = {'.ckpt', '.pt', '.pth', '.safetensors', '.bin'}
|
| 178 |
|
| 179 |
for filename in os.listdir(directory_path):
|
| 180 |
if os.path.splitext(filename)[1] in valid_extensions:
|
|
|
|
| 186 |
return model_list
|
| 187 |
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
## BEGIN MOD
|
| 190 |
from modutils import (to_list, list_uniq, list_sub, get_model_id_list, get_tupled_embed_list,
|
| 191 |
get_tupled_model_list, get_lora_model_list, download_private_repo)
|
|
|
|
| 244 |
print('\033[33m๐ Download and listing of valid models completed.\033[0m')
|
| 245 |
|
| 246 |
upscaler_dict_gui = {
|
| 247 |
+
None: None,
|
| 248 |
+
"Lanczos": "Lanczos",
|
| 249 |
+
"Nearest": "Nearest",
|
| 250 |
+
'Latent': 'Latent',
|
| 251 |
+
'Latent (antialiased)': 'Latent (antialiased)',
|
| 252 |
+
'Latent (bicubic)': 'Latent (bicubic)',
|
| 253 |
+
'Latent (bicubic antialiased)': 'Latent (bicubic antialiased)',
|
| 254 |
+
'Latent (nearest)': 'Latent (nearest)',
|
| 255 |
+
'Latent (nearest-exact)': 'Latent (nearest-exact)',
|
| 256 |
"RealESRGAN_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
|
| 257 |
"RealESRNet_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
|
| 258 |
"RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
|
|
|
|
| 269 |
"NickelbackFS4x" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/NickelbackFS%204x.pth"
|
| 270 |
}
|
| 271 |
|
| 272 |
+
upscaler_keys = list(upscaler_dict_gui.keys())
|
| 273 |
+
|
| 274 |
|
| 275 |
def extract_parameters(input_string):
|
| 276 |
parameters = {}
|
|
|
|
| 469 |
model_ip2,
|
| 470 |
mode_ip2,
|
| 471 |
scale_ip2,
|
| 472 |
+
pag_scale,
|
| 473 |
progress=gr.Progress(track_tqdm=True),
|
| 474 |
):
|
| 475 |
progress(0, desc="Preparing inference...")
|
|
|
|
| 553 |
if task == "inpaint" and not image_mask:
|
| 554 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
| 555 |
|
| 556 |
+
if upscaler_model_path in upscaler_keys[:9]:
|
| 557 |
upscaler_model = upscaler_model_path
|
| 558 |
else:
|
| 559 |
directory_upscalers = 'upscalers'
|
|
|
|
| 619 |
"num_steps": steps,
|
| 620 |
"guidance_scale": cfg,
|
| 621 |
"clip_skip": clip_skip,
|
| 622 |
+
"pag_scale": float(pag_scale),
|
| 623 |
"seed": seed,
|
| 624 |
"image": image_control,
|
| 625 |
"preprocessor_name": preprocessor_name,
|
|
|
|
| 750 |
False, True, 1, True, False, False, False, False, "./images", False, False, False, True, 1, 0.55,
|
| 751 |
False, False, False, True, False, "Use same sampler", False, "", "", 0.35, True, True, False, 4, 4, 32,
|
| 752 |
False, "", "", 0.35, True, True, False, 4, 4, 32,
|
| 753 |
+
True, None, None, "plus_face", "original", 0.7, None, None, "base", "style", 0.7, 0.0, progress
|
| 754 |
)
|
| 755 |
|
| 756 |
progress(1, desc="Inference completed.")
|