Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -66,14 +66,28 @@ preprocessor_controlnet = {
|
|
66 |
"None",
|
67 |
],
|
68 |
"canny": [
|
69 |
-
"Canny"
|
|
|
70 |
],
|
71 |
"mlsd": [
|
72 |
-
"MLSD"
|
|
|
73 |
],
|
74 |
"ip2p": [
|
75 |
"ip2p"
|
76 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
|
79 |
task_stablepy = {
|
@@ -94,11 +108,12 @@ task_stablepy = {
|
|
94 |
'depth ControlNet': 'depth',
|
95 |
'normalbae ControlNet': 'normalbae',
|
96 |
'lineart ControlNet': 'lineart',
|
97 |
-
|
98 |
'shuffle ControlNet': 'shuffle',
|
99 |
'ip2p ControlNet': 'ip2p',
|
100 |
'optical pattern ControlNet': 'pattern',
|
101 |
-
'
|
|
|
102 |
}
|
103 |
|
104 |
task_model_list = list(task_stablepy.keys())
|
@@ -106,7 +121,7 @@ task_model_list = list(task_stablepy.keys())
|
|
106 |
|
107 |
def download_things(directory, url, hf_token="", civitai_api_key=""):
|
108 |
url = url.strip()
|
109 |
-
|
110 |
if "drive.google.com" in url:
|
111 |
original_dir = os.getcwd()
|
112 |
os.chdir(directory)
|
@@ -121,7 +136,7 @@ def download_things(directory, url, hf_token="", civitai_api_key=""):
|
|
121 |
if hf_token:
|
122 |
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]}")
|
123 |
else:
|
124 |
-
os.system
|
125 |
elif "civitai.com" in url:
|
126 |
if "?" in url:
|
127 |
url = url.split("?")[0]
|
@@ -136,7 +151,7 @@ def download_things(directory, url, hf_token="", civitai_api_key=""):
|
|
136 |
|
137 |
def get_model_list(directory_path):
|
138 |
model_list = []
|
139 |
-
valid_extensions = {'.ckpt'
|
140 |
|
141 |
for filename in os.listdir(directory_path):
|
142 |
if os.path.splitext(filename)[1] in valid_extensions:
|
@@ -148,18 +163,6 @@ def get_model_list(directory_path):
|
|
148 |
return model_list
|
149 |
|
150 |
|
151 |
-
def process_string(input_string):
|
152 |
-
parts = input_string.split('/')
|
153 |
-
|
154 |
-
if len(parts) == 2:
|
155 |
-
first_element = parts[1]
|
156 |
-
complete_string = input_string
|
157 |
-
result = (first_element, complete_string)
|
158 |
-
return result
|
159 |
-
else:
|
160 |
-
return None
|
161 |
-
|
162 |
-
|
163 |
directory_models = 'models'
|
164 |
os.makedirs(directory_models, exist_ok=True)
|
165 |
directory_loras = 'loras'
|
@@ -172,23 +175,36 @@ download_model = "https://civitai.com/api/download/models/574369, https://huggin
|
|
172 |
# - **Download VAEs**
|
173 |
download_vae = "https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-c-1.1-b-0.5.safetensors?download=true, https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-blessed.safetensors?download=true, https://huggingface.co/digiplay/VAE/resolve/main/vividReal_v20.safetensors?download=true, https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/vae-ft-mse-840000-ema-pruned_fp16.safetensors?download=true"
|
174 |
# - **Download LoRAs**
|
175 |
-
download_lora = "https://huggingface.co/Leopain/color/resolve/main/Coloring_book_-_LineArt.safetensors, https://civitai.com/api/download/models/135867, https://civitai.com/api/download/models/145907, https://huggingface.co/Linaqruf/anime-detailer-xl-lora/resolve/main/anime-detailer-xl.safetensors?download=true, https://huggingface.co/Linaqruf/style-enhancer-xl-lora/resolve/main/style-enhancer-xl.safetensors?download=true, https://civitai.com/api/download/models/28609, https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SD15-8steps-CFG-lora.safetensors?download=true, https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-8steps-CFG-lora.safetensors?download=true"
|
176 |
load_diffusers_format_model = [
|
177 |
'stabilityai/stable-diffusion-xl-base-1.0',
|
178 |
'cagliostrolab/animagine-xl-3.1',
|
|
|
179 |
'misri/epicrealismXL_v7FinalDestination',
|
180 |
'misri/juggernautXL_juggernautX',
|
181 |
'misri/zavychromaxl_v80',
|
182 |
'SG161222/RealVisXL_V4.0',
|
|
|
183 |
'misri/newrealityxlAllInOne_Newreality40',
|
184 |
'eienmojiki/Anything-XL',
|
185 |
'eienmojiki/Starry-XL-v5.2',
|
186 |
'gsdf/CounterfeitXL',
|
|
|
187 |
'kitty7779/ponyDiffusionV6XL',
|
|
|
|
|
|
|
188 |
'John6666/ebara-mfcg-pony-mix-v12-sdxl',
|
189 |
'John6666/t-ponynai3-v51-sdxl',
|
|
|
|
|
|
|
|
|
|
|
190 |
'yodayo-ai/kivotos-xl-2.0',
|
191 |
'yodayo-ai/holodayo-xl-2.1',
|
|
|
|
|
192 |
'digiplay/majicMIX_sombre_v2',
|
193 |
'digiplay/majicMIX_realistic_v6',
|
194 |
'digiplay/majicMIX_realistic_v7',
|
@@ -197,14 +213,21 @@ load_diffusers_format_model = [
|
|
197 |
'digiplay/DarkSushi2.5D_v1',
|
198 |
'digiplay/darkphoenix3D_v1.1',
|
199 |
'digiplay/BeenYouLiteL11_diffusers',
|
200 |
-
'
|
201 |
'youknownothing/cyberrealistic_v50',
|
|
|
|
|
|
|
|
|
|
|
202 |
'votepurchase/counterfeitV30_v30',
|
|
|
203 |
'Meina/MeinaMix_V11',
|
204 |
'Meina/MeinaUnreal_V5',
|
205 |
'Meina/MeinaPastel_V7',
|
206 |
-
'
|
207 |
-
'
|
|
|
208 |
]
|
209 |
|
210 |
CIVITAI_API_KEY = os.environ.get("CIVITAI_API_KEY")
|
@@ -249,7 +272,7 @@ def get_my_lora(link_url):
|
|
249 |
download_things(directory_loras, url, hf_token, CIVITAI_API_KEY)
|
250 |
new_lora_model_list = get_model_list(directory_loras)
|
251 |
new_lora_model_list.insert(0, "None")
|
252 |
-
|
253 |
return gr.update(
|
254 |
choices=new_lora_model_list
|
255 |
), gr.update(
|
@@ -262,12 +285,19 @@ def get_my_lora(link_url):
|
|
262 |
choices=new_lora_model_list
|
263 |
),
|
264 |
|
|
|
265 |
print('\033[33m🏁 Download and listing of valid models completed.\033[0m')
|
266 |
|
267 |
upscaler_dict_gui = {
|
268 |
-
None
|
269 |
-
"Lanczos"
|
270 |
-
"Nearest"
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
"RealESRGAN_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
|
272 |
"RealESRNet_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
|
273 |
"RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
|
@@ -284,6 +314,7 @@ upscaler_dict_gui = {
|
|
284 |
"NickelbackFS4x" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/NickelbackFS%204x.pth"
|
285 |
}
|
286 |
|
|
|
287 |
|
288 |
def extract_parameters(input_string):
|
289 |
parameters = {}
|
@@ -359,7 +390,7 @@ def info_html(json_data, title, subtitle):
|
|
359 |
class GuiSD:
|
360 |
def __init__(self, stream=True):
|
361 |
self.model = None
|
362 |
-
|
363 |
print("Loading model...")
|
364 |
self.model = Model_Diffusers(
|
365 |
base_model_id="cagliostrolab/animagine-xl-3.1",
|
@@ -373,7 +404,7 @@ class GuiSD:
|
|
373 |
def load_new_model(self, model_name, vae_model, task, progress=gr.Progress(track_tqdm=True)):
|
374 |
|
375 |
yield f"Loading model: {model_name}"
|
376 |
-
|
377 |
vae_model = vae_model if vae_model != "None" else None
|
378 |
|
379 |
if model_name in model_list:
|
@@ -395,7 +426,7 @@ class GuiSD:
|
|
395 |
retain_task_model_in_cache=False,
|
396 |
)
|
397 |
yield f"Model loaded: {model_name}"
|
398 |
-
|
399 |
@spaces.GPU
|
400 |
def generate_pipeline(
|
401 |
self,
|
@@ -500,14 +531,14 @@ class GuiSD:
|
|
500 |
model_ip2,
|
501 |
mode_ip2,
|
502 |
scale_ip2,
|
|
|
503 |
):
|
504 |
-
|
505 |
vae_model = vae_model if vae_model != "None" else None
|
506 |
loras_list = [lora1, lora2, lora3, lora4, lora5]
|
507 |
vae_msg = f"VAE: {vae_model}" if vae_model else ""
|
508 |
msg_lora = []
|
509 |
|
510 |
-
|
511 |
if model_name in model_list:
|
512 |
model_is_xl = "xl" in model_name.lower()
|
513 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
@@ -570,14 +601,14 @@ class GuiSD:
|
|
570 |
retain_task_model_in_cache=retain_task_cache_gui,
|
571 |
)
|
572 |
self.model.stream_config(concurrency=5, latent_resize_by=1, vae_decoding=False)
|
573 |
-
|
574 |
if task != "txt2img" and not image_control:
|
575 |
raise ValueError("No control image found: To use this function, you have to upload an image in 'Image ControlNet/Inpaint/Img2img'")
|
576 |
|
577 |
if task == "inpaint" and not image_mask:
|
578 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
579 |
|
580 |
-
if upscaler_model_path in [
|
581 |
upscaler_model = upscaler_model_path
|
582 |
else:
|
583 |
directory_upscalers = 'upscalers'
|
@@ -641,6 +672,7 @@ class GuiSD:
|
|
641 |
"num_steps": steps,
|
642 |
"guidance_scale": cfg,
|
643 |
"clip_skip": clip_skip,
|
|
|
644 |
"seed": seed,
|
645 |
"image": image_control,
|
646 |
"preprocessor_name": preprocessor_name,
|
@@ -716,7 +748,7 @@ class GuiSD:
|
|
716 |
pipe_params["num_images"] = num_images
|
717 |
gr.Info("Num images x 2 🎉")
|
718 |
|
719 |
-
info_state =
|
720 |
for img, seed, image_path, metadata in self.model(**pipe_params):
|
721 |
info_state += ">"
|
722 |
if image_path:
|
@@ -727,7 +759,7 @@ class GuiSD:
|
|
727 |
info_state = info_state + "<br>" + "<br>".join(msg_lora)
|
728 |
|
729 |
info_state = info_state + "<br>" + "GENERATION DATA:<br>" + "<br>-------<br>".join(metadata).replace("\n", "<br>")
|
730 |
-
|
731 |
yield img, info_state
|
732 |
|
733 |
|
@@ -799,7 +831,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
799 |
)
|
800 |
|
801 |
actual_task_info = gr.HTML()
|
802 |
-
|
803 |
with gr.Column(scale=1):
|
804 |
steps_gui = gr.Slider(minimum=1, maximum=100, step=1, value=30, label="Steps")
|
805 |
cfg_gui = gr.Slider(minimum=0, maximum=30, step=0.5, value=7.5, label="CFG")
|
@@ -807,13 +839,12 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
807 |
img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
|
808 |
img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
|
809 |
seed_gui = gr.Number(minimum=-1, maximum=9999999999, value=-1, label="Seed")
|
|
|
810 |
with gr.Row():
|
811 |
clip_skip_gui = gr.Checkbox(value=True, label="Layer 2 Clip Skip")
|
812 |
free_u_gui = gr.Checkbox(value=True, label="FreeU")
|
813 |
|
814 |
with gr.Row(equal_height=False):
|
815 |
-
|
816 |
-
|
817 |
|
818 |
def run_set_params_gui(base_prompt):
|
819 |
valid_receptors = { # default values
|
@@ -869,8 +900,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
869 |
clip_skip_gui,
|
870 |
],
|
871 |
)
|
872 |
-
|
873 |
-
|
874 |
def run_clear_prompt_gui():
|
875 |
return gr.update(value=""), gr.update(value="")
|
876 |
clear_prompt_gui.click(
|
@@ -897,8 +927,6 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
897 |
|
898 |
with gr.Accordion("Hires fix", open=False, visible=True):
|
899 |
|
900 |
-
upscaler_keys = list(upscaler_dict_gui.keys())
|
901 |
-
|
902 |
upscaler_model_path_gui = gr.Dropdown(label="Upscaler", choices=upscaler_keys, value=upscaler_keys[0])
|
903 |
upscaler_increases_size_gui = gr.Slider(minimum=1.1, maximum=6., step=0.1, value=1.4, label="Upscale by")
|
904 |
esrgan_tile_gui = gr.Slider(minimum=0, value=100, maximum=500, step=1, label="ESRGAN Tile")
|
@@ -1579,6 +1607,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1579 |
model_ip2,
|
1580 |
mode_ip2,
|
1581 |
scale_ip2,
|
|
|
1582 |
],
|
1583 |
outputs=[result_images, actual_task_info],
|
1584 |
queue=True,
|
|
|
66 |
"None",
|
67 |
],
|
68 |
"canny": [
|
69 |
+
"Canny",
|
70 |
+
"None",
|
71 |
],
|
72 |
"mlsd": [
|
73 |
+
"MLSD",
|
74 |
+
"None",
|
75 |
],
|
76 |
"ip2p": [
|
77 |
"ip2p"
|
78 |
+
],
|
79 |
+
"recolor": [
|
80 |
+
"Recolor luminance",
|
81 |
+
"Recolor intensity",
|
82 |
+
"None",
|
83 |
+
],
|
84 |
+
"tile": [
|
85 |
+
"Mild Blur",
|
86 |
+
"Moderate Blur",
|
87 |
+
"Heavy Blur",
|
88 |
+
"None",
|
89 |
+
],
|
90 |
+
|
91 |
}
|
92 |
|
93 |
task_stablepy = {
|
|
|
108 |
'depth ControlNet': 'depth',
|
109 |
'normalbae ControlNet': 'normalbae',
|
110 |
'lineart ControlNet': 'lineart',
|
111 |
+
'lineart_anime ControlNet': 'lineart_anime',
|
112 |
'shuffle ControlNet': 'shuffle',
|
113 |
'ip2p ControlNet': 'ip2p',
|
114 |
'optical pattern ControlNet': 'pattern',
|
115 |
+
'recolor ControlNet': 'recolor',
|
116 |
+
'tile ControlNet': 'tile',
|
117 |
}
|
118 |
|
119 |
task_model_list = list(task_stablepy.keys())
|
|
|
121 |
|
122 |
def download_things(directory, url, hf_token="", civitai_api_key=""):
|
123 |
url = url.strip()
|
124 |
+
|
125 |
if "drive.google.com" in url:
|
126 |
original_dir = os.getcwd()
|
127 |
os.chdir(directory)
|
|
|
136 |
if hf_token:
|
137 |
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]}")
|
138 |
else:
|
139 |
+
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]}")
|
140 |
elif "civitai.com" in url:
|
141 |
if "?" in url:
|
142 |
url = url.split("?")[0]
|
|
|
151 |
|
152 |
def get_model_list(directory_path):
|
153 |
model_list = []
|
154 |
+
valid_extensions = {'.ckpt', '.pt', '.pth', '.safetensors', '.bin'}
|
155 |
|
156 |
for filename in os.listdir(directory_path):
|
157 |
if os.path.splitext(filename)[1] in valid_extensions:
|
|
|
163 |
return model_list
|
164 |
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
directory_models = 'models'
|
167 |
os.makedirs(directory_models, exist_ok=True)
|
168 |
directory_loras = 'loras'
|
|
|
175 |
# - **Download VAEs**
|
176 |
download_vae = "https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-c-1.1-b-0.5.safetensors?download=true, https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-blessed.safetensors?download=true, https://huggingface.co/digiplay/VAE/resolve/main/vividReal_v20.safetensors?download=true, https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/vae-ft-mse-840000-ema-pruned_fp16.safetensors?download=true"
|
177 |
# - **Download LoRAs**
|
178 |
+
download_lora = "https://civitai.com/api/download/models/28907, https://huggingface.co/Leopain/color/resolve/main/Coloring_book_-_LineArt.safetensors, https://civitai.com/api/download/models/135867, https://civitai.com/api/download/models/145907, https://huggingface.co/Linaqruf/anime-detailer-xl-lora/resolve/main/anime-detailer-xl.safetensors?download=true, https://huggingface.co/Linaqruf/style-enhancer-xl-lora/resolve/main/style-enhancer-xl.safetensors?download=true, https://civitai.com/api/download/models/28609, https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SD15-8steps-CFG-lora.safetensors?download=true, https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-8steps-CFG-lora.safetensors?download=true"
|
179 |
load_diffusers_format_model = [
|
180 |
'stabilityai/stable-diffusion-xl-base-1.0',
|
181 |
'cagliostrolab/animagine-xl-3.1',
|
182 |
+
'John6666/epicrealism-xl-v8kiss-sdxl',
|
183 |
'misri/epicrealismXL_v7FinalDestination',
|
184 |
'misri/juggernautXL_juggernautX',
|
185 |
'misri/zavychromaxl_v80',
|
186 |
'SG161222/RealVisXL_V4.0',
|
187 |
+
'SG161222/RealVisXL_V5.0',
|
188 |
'misri/newrealityxlAllInOne_Newreality40',
|
189 |
'eienmojiki/Anything-XL',
|
190 |
'eienmojiki/Starry-XL-v5.2',
|
191 |
'gsdf/CounterfeitXL',
|
192 |
+
'KBlueLeaf/Kohaku-XL-Zeta',
|
193 |
'kitty7779/ponyDiffusionV6XL',
|
194 |
+
'WhiteAiZ/autismmixSDXL_autismmixConfetti_diffusers',
|
195 |
+
'GraydientPlatformAPI/aniverse-pony',
|
196 |
+
'John6666/mistoon-anime-ponyalpha-sdxl',
|
197 |
'John6666/ebara-mfcg-pony-mix-v12-sdxl',
|
198 |
'John6666/t-ponynai3-v51-sdxl',
|
199 |
+
'John6666/mala-anime-mix-nsfw-pony-xl-v5-sdxl',
|
200 |
+
'John6666/wai-real-mix-v11-sdxl',
|
201 |
+
'John6666/cyberrealistic-pony-v63-sdxl',
|
202 |
+
'GraydientPlatformAPI/realcartoon-pony-diffusion',
|
203 |
+
'John6666/nova-anime-xl-pony-v5-sdxl',
|
204 |
'yodayo-ai/kivotos-xl-2.0',
|
205 |
'yodayo-ai/holodayo-xl-2.1',
|
206 |
+
'yodayo-ai/clandestine-xl-1.0',
|
207 |
+
'John6666/silvermoon-mix-01xl-v11-sdxl',
|
208 |
'digiplay/majicMIX_sombre_v2',
|
209 |
'digiplay/majicMIX_realistic_v6',
|
210 |
'digiplay/majicMIX_realistic_v7',
|
|
|
213 |
'digiplay/DarkSushi2.5D_v1',
|
214 |
'digiplay/darkphoenix3D_v1.1',
|
215 |
'digiplay/BeenYouLiteL11_diffusers',
|
216 |
+
'Yntec/RevAnimatedV2Rebirth',
|
217 |
'youknownothing/cyberrealistic_v50',
|
218 |
+
'youknownothing/deliberate-v6',
|
219 |
+
'GraydientPlatformAPI/deliberate-cyber3',
|
220 |
+
'GraydientPlatformAPI/picx-real',
|
221 |
+
'GraydientPlatformAPI/perfectworld6',
|
222 |
+
'emilianJR/epiCRealism',
|
223 |
'votepurchase/counterfeitV30_v30',
|
224 |
+
'votepurchase/ChilloutMix',
|
225 |
'Meina/MeinaMix_V11',
|
226 |
'Meina/MeinaUnreal_V5',
|
227 |
'Meina/MeinaPastel_V7',
|
228 |
+
'GraydientPlatformAPI/realcartoon3d-17',
|
229 |
+
'GraydientPlatformAPI/realcartoon-pixar11',
|
230 |
+
'GraydientPlatformAPI/realcartoon-real17',
|
231 |
]
|
232 |
|
233 |
CIVITAI_API_KEY = os.environ.get("CIVITAI_API_KEY")
|
|
|
272 |
download_things(directory_loras, url, hf_token, CIVITAI_API_KEY)
|
273 |
new_lora_model_list = get_model_list(directory_loras)
|
274 |
new_lora_model_list.insert(0, "None")
|
275 |
+
|
276 |
return gr.update(
|
277 |
choices=new_lora_model_list
|
278 |
), gr.update(
|
|
|
285 |
choices=new_lora_model_list
|
286 |
),
|
287 |
|
288 |
+
|
289 |
print('\033[33m🏁 Download and listing of valid models completed.\033[0m')
|
290 |
|
291 |
upscaler_dict_gui = {
|
292 |
+
None: None,
|
293 |
+
"Lanczos": "Lanczos",
|
294 |
+
"Nearest": "Nearest",
|
295 |
+
'Latent': 'Latent',
|
296 |
+
'Latent (antialiased)': 'Latent (antialiased)',
|
297 |
+
'Latent (bicubic)': 'Latent (bicubic)',
|
298 |
+
'Latent (bicubic antialiased)': 'Latent (bicubic antialiased)',
|
299 |
+
'Latent (nearest)': 'Latent (nearest)',
|
300 |
+
'Latent (nearest-exact)': 'Latent (nearest-exact)',
|
301 |
"RealESRGAN_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
|
302 |
"RealESRNet_x4plus" : "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
|
303 |
"RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
|
|
|
314 |
"NickelbackFS4x" : "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/NickelbackFS%204x.pth"
|
315 |
}
|
316 |
|
317 |
+
upscaler_keys = list(upscaler_dict_gui.keys())
|
318 |
|
319 |
def extract_parameters(input_string):
|
320 |
parameters = {}
|
|
|
390 |
class GuiSD:
|
391 |
def __init__(self, stream=True):
|
392 |
self.model = None
|
393 |
+
|
394 |
print("Loading model...")
|
395 |
self.model = Model_Diffusers(
|
396 |
base_model_id="cagliostrolab/animagine-xl-3.1",
|
|
|
404 |
def load_new_model(self, model_name, vae_model, task, progress=gr.Progress(track_tqdm=True)):
|
405 |
|
406 |
yield f"Loading model: {model_name}"
|
407 |
+
|
408 |
vae_model = vae_model if vae_model != "None" else None
|
409 |
|
410 |
if model_name in model_list:
|
|
|
426 |
retain_task_model_in_cache=False,
|
427 |
)
|
428 |
yield f"Model loaded: {model_name}"
|
429 |
+
|
430 |
@spaces.GPU
|
431 |
def generate_pipeline(
|
432 |
self,
|
|
|
531 |
model_ip2,
|
532 |
mode_ip2,
|
533 |
scale_ip2,
|
534 |
+
pag_scale,
|
535 |
):
|
536 |
+
|
537 |
vae_model = vae_model if vae_model != "None" else None
|
538 |
loras_list = [lora1, lora2, lora3, lora4, lora5]
|
539 |
vae_msg = f"VAE: {vae_model}" if vae_model else ""
|
540 |
msg_lora = []
|
541 |
|
|
|
542 |
if model_name in model_list:
|
543 |
model_is_xl = "xl" in model_name.lower()
|
544 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
|
|
601 |
retain_task_model_in_cache=retain_task_cache_gui,
|
602 |
)
|
603 |
self.model.stream_config(concurrency=5, latent_resize_by=1, vae_decoding=False)
|
604 |
+
|
605 |
if task != "txt2img" and not image_control:
|
606 |
raise ValueError("No control image found: To use this function, you have to upload an image in 'Image ControlNet/Inpaint/Img2img'")
|
607 |
|
608 |
if task == "inpaint" and not image_mask:
|
609 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
610 |
|
611 |
+
if upscaler_model_path in upscaler_keys[:9]:
|
612 |
upscaler_model = upscaler_model_path
|
613 |
else:
|
614 |
directory_upscalers = 'upscalers'
|
|
|
672 |
"num_steps": steps,
|
673 |
"guidance_scale": cfg,
|
674 |
"clip_skip": clip_skip,
|
675 |
+
"pag_scale": float(pag_scale),
|
676 |
"seed": seed,
|
677 |
"image": image_control,
|
678 |
"preprocessor_name": preprocessor_name,
|
|
|
748 |
pipe_params["num_images"] = num_images
|
749 |
gr.Info("Num images x 2 🎉")
|
750 |
|
751 |
+
info_state = "PROCESSING "
|
752 |
for img, seed, image_path, metadata in self.model(**pipe_params):
|
753 |
info_state += ">"
|
754 |
if image_path:
|
|
|
759 |
info_state = info_state + "<br>" + "<br>".join(msg_lora)
|
760 |
|
761 |
info_state = info_state + "<br>" + "GENERATION DATA:<br>" + "<br>-------<br>".join(metadata).replace("\n", "<br>")
|
762 |
+
|
763 |
yield img, info_state
|
764 |
|
765 |
|
|
|
831 |
)
|
832 |
|
833 |
actual_task_info = gr.HTML()
|
834 |
+
|
835 |
with gr.Column(scale=1):
|
836 |
steps_gui = gr.Slider(minimum=1, maximum=100, step=1, value=30, label="Steps")
|
837 |
cfg_gui = gr.Slider(minimum=0, maximum=30, step=0.5, value=7.5, label="CFG")
|
|
|
839 |
img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
|
840 |
img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
|
841 |
seed_gui = gr.Number(minimum=-1, maximum=9999999999, value=-1, label="Seed")
|
842 |
+
pag_scale_gui = gr.Slider(minimum=0.0, maximum=10.0, step=0.1, value=0.0, label="PAG Scale")
|
843 |
with gr.Row():
|
844 |
clip_skip_gui = gr.Checkbox(value=True, label="Layer 2 Clip Skip")
|
845 |
free_u_gui = gr.Checkbox(value=True, label="FreeU")
|
846 |
|
847 |
with gr.Row(equal_height=False):
|
|
|
|
|
848 |
|
849 |
def run_set_params_gui(base_prompt):
|
850 |
valid_receptors = { # default values
|
|
|
900 |
clip_skip_gui,
|
901 |
],
|
902 |
)
|
903 |
+
|
|
|
904 |
def run_clear_prompt_gui():
|
905 |
return gr.update(value=""), gr.update(value="")
|
906 |
clear_prompt_gui.click(
|
|
|
927 |
|
928 |
with gr.Accordion("Hires fix", open=False, visible=True):
|
929 |
|
|
|
|
|
930 |
upscaler_model_path_gui = gr.Dropdown(label="Upscaler", choices=upscaler_keys, value=upscaler_keys[0])
|
931 |
upscaler_increases_size_gui = gr.Slider(minimum=1.1, maximum=6., step=0.1, value=1.4, label="Upscale by")
|
932 |
esrgan_tile_gui = gr.Slider(minimum=0, value=100, maximum=500, step=1, label="ESRGAN Tile")
|
|
|
1607 |
model_ip2,
|
1608 |
mode_ip2,
|
1609 |
scale_ip2,
|
1610 |
+
pag_scale_gui,
|
1611 |
],
|
1612 |
outputs=[result_images, actual_task_info],
|
1613 |
queue=True,
|