Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,3 @@
|
|
1 |
-
#######################
|
2 |
-
# UTILS
|
3 |
-
#######################
|
4 |
import spaces
|
5 |
import os
|
6 |
from stablepy import Model_Diffusers
|
@@ -25,6 +22,7 @@ from stablepy import (
|
|
25 |
SD15_TASKS,
|
26 |
SDXL_TASKS,
|
27 |
)
|
|
|
28 |
|
29 |
preprocessor_controlnet = {
|
30 |
"openpose": [
|
@@ -59,7 +57,7 @@ preprocessor_controlnet = {
|
|
59 |
"lineart": [
|
60 |
"Lineart",
|
61 |
"Lineart coarse",
|
62 |
-
"
|
63 |
"None",
|
64 |
"None (anime)",
|
65 |
],
|
@@ -96,7 +94,7 @@ task_stablepy = {
|
|
96 |
'depth ControlNet': 'depth',
|
97 |
'normalbae ControlNet': 'normalbae',
|
98 |
'lineart ControlNet': 'lineart',
|
99 |
-
'lineart_anime ControlNet': 'lineart_anime',
|
100 |
'shuffle ControlNet': 'shuffle',
|
101 |
'ip2p ControlNet': 'ip2p',
|
102 |
'optical pattern ControlNet': 'pattern',
|
@@ -108,7 +106,7 @@ task_model_list = list(task_stablepy.keys())
|
|
108 |
|
109 |
def download_things(directory, url, hf_token="", civitai_api_key=""):
|
110 |
url = url.strip()
|
111 |
-
|
112 |
if "drive.google.com" in url:
|
113 |
original_dir = os.getcwd()
|
114 |
os.chdir(directory)
|
@@ -116,6 +114,7 @@ def download_things(directory, url, hf_token="", civitai_api_key=""):
|
|
116 |
os.chdir(original_dir)
|
117 |
elif "huggingface.co" in url:
|
118 |
url = url.replace("?download=true", "")
|
|
|
119 |
if "/blob/" in url:
|
120 |
url = url.replace("/blob/", "/resolve/")
|
121 |
user_header = f'"Authorization: Bearer {hf_token}"'
|
@@ -169,24 +168,43 @@ directory_vaes = 'vaes'
|
|
169 |
os.makedirs(directory_vaes, exist_ok=True)
|
170 |
|
171 |
# - **Download SD 1.5 Models**
|
172 |
-
download_model = "https://huggingface.co/
|
173 |
# - **Download VAEs**
|
174 |
-
download_vae = "https://huggingface.co/
|
175 |
# - **Download LoRAs**
|
176 |
-
download_lora = "https://civitai.com/api/download/models/
|
177 |
load_diffusers_format_model = [
|
178 |
'stabilityai/stable-diffusion-xl-base-1.0',
|
|
|
179 |
'misri/epicrealismXL_v7FinalDestination',
|
180 |
'misri/juggernautXL_juggernautX',
|
181 |
-
'misri/
|
182 |
-
'
|
183 |
-
'misri/
|
|
|
|
|
|
|
184 |
'kitty7779/ponyDiffusionV6XL',
|
|
|
|
|
|
|
|
|
|
|
185 |
'digiplay/majicMIX_realistic_v6',
|
186 |
'digiplay/majicMIX_realistic_v7',
|
187 |
'digiplay/DreamShaper_8',
|
188 |
'digiplay/BeautifulArt_v1',
|
189 |
'digiplay/DarkSushi2.5D_v1',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
]
|
191 |
|
192 |
CIVITAI_API_KEY = os.environ.get("CIVITAI_API_KEY")
|
@@ -225,6 +243,25 @@ lora_model_list.insert(0, "None")
|
|
225 |
vae_model_list = get_model_list(directory_vaes)
|
226 |
vae_model_list.insert(0, "None")
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
print('\033[33m🏁 Download and listing of valid models completed.\033[0m')
|
229 |
|
230 |
upscaler_dict_gui = {
|
@@ -308,6 +345,17 @@ warnings.filterwarnings(action="ignore", category=FutureWarning, module="transfo
|
|
308 |
from stablepy import logger
|
309 |
logger.setLevel(logging.DEBUG)
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
class GuiSD:
|
312 |
def __init__(self, stream=True):
|
313 |
self.model = None
|
@@ -321,18 +369,12 @@ class GuiSD:
|
|
321 |
retain_task_model_in_cache=False,
|
322 |
)
|
323 |
|
324 |
-
@spaces.GPU(duration=120)
|
325 |
-
def infer(self, model, pipe_params):
|
326 |
-
images, image_list = model(**pipe_params)
|
327 |
-
return images
|
328 |
-
|
329 |
def load_new_model(self, model_name, vae_model, task, progress=gr.Progress(track_tqdm=True)):
|
330 |
|
331 |
yield f"Loading model: {model_name}"
|
332 |
|
333 |
vae_model = vae_model if vae_model != "None" else None
|
334 |
|
335 |
-
|
336 |
if model_name in model_list:
|
337 |
model_is_xl = "xl" in model_name.lower()
|
338 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
@@ -350,7 +392,7 @@ class GuiSD:
|
|
350 |
type_model_precision=torch.float16,
|
351 |
retain_task_model_in_cache=False,
|
352 |
)
|
353 |
-
yield f"Model loaded: {model_name}
|
354 |
|
355 |
@spaces.GPU
|
356 |
def generate_pipeline(
|
@@ -456,15 +498,14 @@ class GuiSD:
|
|
456 |
model_ip2,
|
457 |
mode_ip2,
|
458 |
scale_ip2,
|
459 |
-
# progress=gr.Progress(track_tqdm=True),
|
460 |
-
# progress=gr.Progress()
|
461 |
):
|
462 |
-
|
463 |
-
# progress(0.01, desc="Loading model...")
|
464 |
|
465 |
vae_model = vae_model if vae_model != "None" else None
|
466 |
loras_list = [lora1, lora2, lora3, lora4, lora5]
|
|
|
|
|
467 |
|
|
|
468 |
if model_name in model_list:
|
469 |
model_is_xl = "xl" in model_name.lower()
|
470 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
@@ -472,19 +513,23 @@ class GuiSD:
|
|
472 |
incompatible_vae = (model_is_xl and vae_model and not sdxl_in_vae) or (not model_is_xl and sdxl_in_vae)
|
473 |
|
474 |
if incompatible_vae:
|
475 |
-
|
476 |
f"The selected VAE is for a { 'SD 1.5' if model_is_xl else 'SDXL' } model, but you"
|
477 |
f" are using a { model_type } model. The default VAE "
|
478 |
"will be used."
|
479 |
)
|
|
|
|
|
480 |
vae_model = None
|
481 |
|
482 |
for la in loras_list:
|
483 |
-
if la is not None and la != "None":
|
484 |
print(la)
|
485 |
lora_type = ("animetarot" in la.lower() or "Hyper-SD15-8steps".lower() in la.lower())
|
486 |
if (model_is_xl and lora_type) or (not model_is_xl and not lora_type):
|
487 |
-
|
|
|
|
|
488 |
|
489 |
task = task_stablepy[task]
|
490 |
|
@@ -669,12 +714,18 @@ class GuiSD:
|
|
669 |
pipe_params["num_images"] = num_images
|
670 |
gr.Info("Num images x 2 🎉")
|
671 |
|
672 |
-
#
|
673 |
-
|
|
|
|
|
674 |
for img, seed, data in self.model(**pipe_params):
|
675 |
-
info_state
|
676 |
if data:
|
677 |
-
info_state = f"
|
|
|
|
|
|
|
|
|
678 |
yield img, info_state
|
679 |
|
680 |
|
@@ -868,6 +919,15 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
868 |
lora5_gui = gr.Dropdown(label="Lora5", choices=lora_model_list)
|
869 |
lora_scale_5_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=0.33, label="Lora Scale 5")
|
870 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
871 |
with gr.Accordion("IP-Adapter", open=False, visible=True):##############
|
872 |
|
873 |
IP_MODELS = sorted(list(set(IP_ADAPTERS_SD + IP_ADAPTERS_SDXL)))
|
@@ -1011,7 +1071,26 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1011 |
retain_hires_model_previous_load_gui = gr.Checkbox(value=False, label="Retain Hires Model Previous Load")
|
1012 |
xformers_memory_efficient_attention_gui = gr.Checkbox(value=False, label="Xformers Memory Efficient Attention")
|
1013 |
|
1014 |
-
with gr.Accordion("Examples", open=False, visible=True):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1015 |
gr.Examples(
|
1016 |
examples=[
|
1017 |
[
|
@@ -1022,7 +1101,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1022 |
7.5,
|
1023 |
True,
|
1024 |
-1,
|
1025 |
-
None,
|
1026 |
1.0,
|
1027 |
None,
|
1028 |
1.0,
|
@@ -1065,7 +1144,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1065 |
5.,
|
1066 |
True,
|
1067 |
-1,
|
1068 |
-
None,
|
1069 |
1.0,
|
1070 |
None,
|
1071 |
1.0,
|
@@ -1108,7 +1187,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1108 |
3.5,
|
1109 |
True,
|
1110 |
-1,
|
1111 |
-
None,
|
1112 |
1.0,
|
1113 |
None,
|
1114 |
1.0,
|
@@ -1144,14 +1223,14 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1144 |
None,
|
1145 |
],
|
1146 |
[
|
1147 |
-
"
|
1148 |
-
"(
|
1149 |
1,
|
1150 |
50,
|
1151 |
4.,
|
1152 |
True,
|
1153 |
-1,
|
1154 |
-
None,
|
1155 |
1.0,
|
1156 |
None,
|
1157 |
1.0,
|
@@ -1161,13 +1240,13 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1161 |
1.0,
|
1162 |
None,
|
1163 |
1.0,
|
1164 |
-
"
|
1165 |
1024,
|
1166 |
1024,
|
1167 |
"misri/juggernautXL_juggernautX",
|
1168 |
None, # vae
|
1169 |
-
"
|
1170 |
-
|
1171 |
"Canny", # preprocessor
|
1172 |
512, # preproc resolution
|
1173 |
1024, # img resolution
|
@@ -1180,21 +1259,21 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1180 |
0.1, # value mstd
|
1181 |
0.1, # distance mstd
|
1182 |
1.0, # cn scale
|
1183 |
-
0
|
1184 |
-
|
1185 |
False, # ti
|
1186 |
"Classic",
|
1187 |
None,
|
1188 |
],
|
1189 |
[
|
1190 |
-
"
|
1191 |
-
"
|
1192 |
1,
|
1193 |
-
|
1194 |
4.,
|
1195 |
True,
|
1196 |
-1,
|
1197 |
-
|
1198 |
1.0,
|
1199 |
None,
|
1200 |
1.0,
|
@@ -1204,16 +1283,16 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1204 |
1.0,
|
1205 |
None,
|
1206 |
1.0,
|
1207 |
-
"DPM++ 2M Karras",
|
1208 |
-
|
1209 |
-
|
1210 |
-
"
|
1211 |
None, # vae
|
1212 |
-
"
|
1213 |
-
|
1214 |
-
"
|
1215 |
512, # preproc resolution
|
1216 |
-
|
1217 |
None, # Style prompt
|
1218 |
None, # Style json
|
1219 |
None, # img Mask
|
@@ -1226,7 +1305,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1226 |
0., # cn start
|
1227 |
1., # cn end
|
1228 |
False, # ti
|
1229 |
-
"
|
1230 |
None,
|
1231 |
],
|
1232 |
[
|
@@ -1237,7 +1316,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1237 |
5.,
|
1238 |
True,
|
1239 |
-1,
|
1240 |
-
None,
|
1241 |
1.0,
|
1242 |
None,
|
1243 |
1.0,
|
@@ -1267,7 +1346,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1267 |
0.1, # distance mstd
|
1268 |
1.0, # cn scale
|
1269 |
0., # cn start
|
1270 |
-
|
1271 |
False, # ti
|
1272 |
"Compel",
|
1273 |
"Nearest",
|
|
|
|
|
|
|
|
|
1 |
import spaces
|
2 |
import os
|
3 |
from stablepy import Model_Diffusers
|
|
|
22 |
SD15_TASKS,
|
23 |
SDXL_TASKS,
|
24 |
)
|
25 |
+
import urllib.parse
|
26 |
|
27 |
preprocessor_controlnet = {
|
28 |
"openpose": [
|
|
|
57 |
"lineart": [
|
58 |
"Lineart",
|
59 |
"Lineart coarse",
|
60 |
+
"Lineart (anime)",
|
61 |
"None",
|
62 |
"None (anime)",
|
63 |
],
|
|
|
94 |
'depth ControlNet': 'depth',
|
95 |
'normalbae ControlNet': 'normalbae',
|
96 |
'lineart ControlNet': 'lineart',
|
97 |
+
# 'lineart_anime ControlNet': 'lineart_anime',
|
98 |
'shuffle ControlNet': 'shuffle',
|
99 |
'ip2p ControlNet': 'ip2p',
|
100 |
'optical pattern ControlNet': 'pattern',
|
|
|
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)
|
|
|
114 |
os.chdir(original_dir)
|
115 |
elif "huggingface.co" in url:
|
116 |
url = url.replace("?download=true", "")
|
117 |
+
# url = urllib.parse.quote(url, safe=':/') # fix encoding
|
118 |
if "/blob/" in url:
|
119 |
url = url.replace("/blob/", "/resolve/")
|
120 |
user_header = f'"Authorization: Bearer {hf_token}"'
|
|
|
168 |
os.makedirs(directory_vaes, exist_ok=True)
|
169 |
|
170 |
# - **Download SD 1.5 Models**
|
171 |
+
download_model = "https://civitai.com/api/download/models/574369, https://huggingface.co/TechnoByte/MilkyWonderland/resolve/main/milkyWonderland_v40.safetensors"
|
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://civitai.com/api/download/models/311558, 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',
|
195 |
'digiplay/DreamShaper_8',
|
196 |
'digiplay/BeautifulArt_v1',
|
197 |
'digiplay/DarkSushi2.5D_v1',
|
198 |
+
'digiplay/darkphoenix3D_v1.1',
|
199 |
+
'digiplay/BeenYouLiteL11_diffusers',
|
200 |
+
'rubbrband/revAnimated_v2Rebirth',
|
201 |
+
'youknownothing/cyberrealistic_v50',
|
202 |
+
'votepurchase/counterfeitV30_v30',
|
203 |
+
'Meina/MeinaMix_V11',
|
204 |
+
'Meina/MeinaUnreal_V5',
|
205 |
+
'Meina/MeinaPastel_V7',
|
206 |
+
'rubbrband/realcartoon3d_v16',
|
207 |
+
'rubbrband/realcartoonRealistic_v14',
|
208 |
]
|
209 |
|
210 |
CIVITAI_API_KEY = os.environ.get("CIVITAI_API_KEY")
|
|
|
243 |
vae_model_list = get_model_list(directory_vaes)
|
244 |
vae_model_list.insert(0, "None")
|
245 |
|
246 |
+
def get_my_lora(link_url):
|
247 |
+
for url in [url.strip() for url in link_url.split(',')]:
|
248 |
+
if not os.path.exists(f"./loras/{url.split('/')[-1]}"):
|
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(
|
256 |
+
choices=new_lora_model_list
|
257 |
+
), gr.update(
|
258 |
+
choices=new_lora_model_list
|
259 |
+
), gr.update(
|
260 |
+
choices=new_lora_model_list
|
261 |
+
), gr.update(
|
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 = {
|
|
|
345 |
from stablepy import logger
|
346 |
logger.setLevel(logging.DEBUG)
|
347 |
|
348 |
+
def info_html(json_data, title, subtitle):
|
349 |
+
return f"""
|
350 |
+
<div style='padding: 0; border-radius: 10px;'>
|
351 |
+
<p style='margin: 0; font-weight: bold;'>{title}</p>
|
352 |
+
<details>
|
353 |
+
<summary>Details</summary>
|
354 |
+
<p style='margin: 0; font-weight: bold;'>{subtitle}</p>
|
355 |
+
</details>
|
356 |
+
</div>
|
357 |
+
"""
|
358 |
+
|
359 |
class GuiSD:
|
360 |
def __init__(self, stream=True):
|
361 |
self.model = None
|
|
|
369 |
retain_task_model_in_cache=False,
|
370 |
)
|
371 |
|
|
|
|
|
|
|
|
|
|
|
372 |
def load_new_model(self, model_name, vae_model, task, progress=gr.Progress(track_tqdm=True)):
|
373 |
|
374 |
yield f"Loading model: {model_name}"
|
375 |
|
376 |
vae_model = vae_model if vae_model != "None" else None
|
377 |
|
|
|
378 |
if model_name in model_list:
|
379 |
model_is_xl = "xl" in model_name.lower()
|
380 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
|
|
392 |
type_model_precision=torch.float16,
|
393 |
retain_task_model_in_cache=False,
|
394 |
)
|
395 |
+
yield f"Model loaded: {model_name}"
|
396 |
|
397 |
@spaces.GPU
|
398 |
def generate_pipeline(
|
|
|
498 |
model_ip2,
|
499 |
mode_ip2,
|
500 |
scale_ip2,
|
|
|
|
|
501 |
):
|
|
|
|
|
502 |
|
503 |
vae_model = vae_model if vae_model != "None" else None
|
504 |
loras_list = [lora1, lora2, lora3, lora4, lora5]
|
505 |
+
vae_msg = f"VAE: {vae_model}" if vae_model else ""
|
506 |
+
msg_lora = []
|
507 |
|
508 |
+
|
509 |
if model_name in model_list:
|
510 |
model_is_xl = "xl" in model_name.lower()
|
511 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
|
|
513 |
incompatible_vae = (model_is_xl and vae_model and not sdxl_in_vae) or (not model_is_xl and sdxl_in_vae)
|
514 |
|
515 |
if incompatible_vae:
|
516 |
+
msg_inc_vae = (
|
517 |
f"The selected VAE is for a { 'SD 1.5' if model_is_xl else 'SDXL' } model, but you"
|
518 |
f" are using a { model_type } model. The default VAE "
|
519 |
"will be used."
|
520 |
)
|
521 |
+
gr.Info(msg_inc_vae)
|
522 |
+
vae_msg = msg_inc_vae
|
523 |
vae_model = None
|
524 |
|
525 |
for la in loras_list:
|
526 |
+
if la is not None and la != "None" and la in lora_model_list:
|
527 |
print(la)
|
528 |
lora_type = ("animetarot" in la.lower() or "Hyper-SD15-8steps".lower() in la.lower())
|
529 |
if (model_is_xl and lora_type) or (not model_is_xl and not lora_type):
|
530 |
+
msg_inc_lora = f"The LoRA {la} is for { 'SD 1.5' if model_is_xl else 'SDXL' }, but you are using { model_type }."
|
531 |
+
gr.Info(msg_inc_lora)
|
532 |
+
msg_lora.append(msg_inc_lora)
|
533 |
|
534 |
task = task_stablepy[task]
|
535 |
|
|
|
714 |
pipe_params["num_images"] = num_images
|
715 |
gr.Info("Num images x 2 🎉")
|
716 |
|
717 |
+
# Maybe fix lora issue: 'Cannot copy out of meta tensor; no data!''
|
718 |
+
self.model.pipe.to("cuda:0" if torch.cuda.is_available() else "cpu")
|
719 |
+
|
720 |
+
info_state = f"PROCESSING "
|
721 |
for img, seed, data in self.model(**pipe_params):
|
722 |
+
info_state += ">"
|
723 |
if data:
|
724 |
+
info_state = f"COMPLETED. Seeds: {str(seed)}"
|
725 |
+
if vae_msg:
|
726 |
+
info_state = info_state + "<br>" + vae_msg
|
727 |
+
if msg_lora:
|
728 |
+
info_state = info_state + "<br>" + "<br>".join(msg_lora)
|
729 |
yield img, info_state
|
730 |
|
731 |
|
|
|
919 |
lora5_gui = gr.Dropdown(label="Lora5", choices=lora_model_list)
|
920 |
lora_scale_5_gui = gr.Slider(minimum=-2, maximum=2, step=0.01, value=0.33, label="Lora Scale 5")
|
921 |
|
922 |
+
with gr.Accordion("From URL", open=False, visible=True):
|
923 |
+
text_lora = gr.Textbox(label="URL", placeholder="http://...my_lora_url.safetensors", lines=1)
|
924 |
+
button_lora = gr.Button("Get and update lists of LoRAs")
|
925 |
+
button_lora.click(
|
926 |
+
get_my_lora,
|
927 |
+
[text_lora],
|
928 |
+
[lora1_gui, lora2_gui, lora3_gui, lora4_gui, lora5_gui]
|
929 |
+
)
|
930 |
+
|
931 |
with gr.Accordion("IP-Adapter", open=False, visible=True):##############
|
932 |
|
933 |
IP_MODELS = sorted(list(set(IP_ADAPTERS_SD + IP_ADAPTERS_SDXL)))
|
|
|
1071 |
retain_hires_model_previous_load_gui = gr.Checkbox(value=False, label="Retain Hires Model Previous Load")
|
1072 |
xformers_memory_efficient_attention_gui = gr.Checkbox(value=False, label="Xformers Memory Efficient Attention")
|
1073 |
|
1074 |
+
with gr.Accordion("Examples and help", open=False, visible=True):
|
1075 |
+
gr.Markdown(
|
1076 |
+
"""### Help:
|
1077 |
+
- The current space runs on a ZERO GPU which is assigned for approximately 60 seconds; Therefore, if you submit expensive tasks, the operation may be canceled upon reaching the maximum allowed time with 'GPU TASK ABORTED'.
|
1078 |
+
- Distorted or strange images often result from high prompt weights, so it's best to use low weights and scales, and consider using Classic variants like 'Classic-original'.
|
1079 |
+
- For better results with Pony Diffusion, try using sampler DPM++ 1s or DPM2 with Compel or Classic prompt weights.
|
1080 |
+
"""
|
1081 |
+
)
|
1082 |
+
gr.Markdown(
|
1083 |
+
"""### The following examples perform specific tasks:
|
1084 |
+
1. Generation with SDXL and upscale
|
1085 |
+
2. Generation with SDXL
|
1086 |
+
3. ControlNet Canny SDXL
|
1087 |
+
4. Optical pattern (Optical illusion) SDXL
|
1088 |
+
5. Convert an image to a coloring drawing
|
1089 |
+
6. ControlNet OpenPose SD 1.5
|
1090 |
+
|
1091 |
+
- Different tasks can be performed, such as img2img or using the IP adapter, to preserve a person's appearance or a specific style based on an image.
|
1092 |
+
"""
|
1093 |
+
)
|
1094 |
gr.Examples(
|
1095 |
examples=[
|
1096 |
[
|
|
|
1101 |
7.5,
|
1102 |
True,
|
1103 |
-1,
|
1104 |
+
"None",
|
1105 |
1.0,
|
1106 |
None,
|
1107 |
1.0,
|
|
|
1144 |
5.,
|
1145 |
True,
|
1146 |
-1,
|
1147 |
+
"None",
|
1148 |
1.0,
|
1149 |
None,
|
1150 |
1.0,
|
|
|
1187 |
3.5,
|
1188 |
True,
|
1189 |
-1,
|
1190 |
+
"None",
|
1191 |
1.0,
|
1192 |
None,
|
1193 |
1.0,
|
|
|
1223 |
None,
|
1224 |
],
|
1225 |
[
|
1226 |
+
"cinematic scenery old city ruins",
|
1227 |
+
"(worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), (illustration, 3d, 2d, painting, cartoons, sketch, blurry, film grain, noise), (low quality, worst quality:1.2)",
|
1228 |
1,
|
1229 |
50,
|
1230 |
4.,
|
1231 |
True,
|
1232 |
-1,
|
1233 |
+
"None",
|
1234 |
1.0,
|
1235 |
None,
|
1236 |
1.0,
|
|
|
1240 |
1.0,
|
1241 |
None,
|
1242 |
1.0,
|
1243 |
+
"Euler a",
|
1244 |
1024,
|
1245 |
1024,
|
1246 |
"misri/juggernautXL_juggernautX",
|
1247 |
None, # vae
|
1248 |
+
"optical pattern ControlNet",
|
1249 |
+
"spiral_no_transparent.png", # img conttol
|
1250 |
"Canny", # preprocessor
|
1251 |
512, # preproc resolution
|
1252 |
1024, # img resolution
|
|
|
1259 |
0.1, # value mstd
|
1260 |
0.1, # distance mstd
|
1261 |
1.0, # cn scale
|
1262 |
+
0.05, # cn start
|
1263 |
+
0.75, # cn end
|
1264 |
False, # ti
|
1265 |
"Classic",
|
1266 |
None,
|
1267 |
],
|
1268 |
[
|
1269 |
+
"black and white, line art, coloring drawing, clean line art, black strokes, no background, white, black, free lines, black scribbles, on paper, A blend of comic book art and lineart full of black and white color, masterpiece, high-resolution, trending on Pixiv fan box, palette knife, brush strokes, two-dimensional, planar vector, T-shirt design, stickers, and T-shirt design, vector art, fantasy art, Adobe Illustrator, hand-painted, digital painting, low polygon, soft lighting, aerial view, isometric style, retro aesthetics, 8K resolution, black sketch lines, monochrome, invert color",
|
1270 |
+
"color, red, green, yellow, colored, duplicate, blurry, abstract, disfigured, deformed, animated, toy, figure, framed, 3d, bad art, poorly drawn, extra limbs, close up, b&w, weird colors, blurry, watermark, blur haze, 2 heads, long neck, watermark, elongated body, cropped image, out of frame, draft, deformed hands, twisted fingers, double image, malformed hands, multiple heads, extra limb, ugly, poorly drawn hands, missing limb, cut-off, over satured, grain, lowères, bad anatomy, poorly drawn face, mutation, mutated, floating limbs, disconnected limbs, out of focus, long body, disgusting, extra fingers, groos proportions, missing arms, mutated hands, cloned face, missing legs, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, deformed, blurry, bad anatomy, disfigured, poorly drawn face, mutation, bluelish, blue",
|
1271 |
1,
|
1272 |
+
20,
|
1273 |
4.,
|
1274 |
True,
|
1275 |
-1,
|
1276 |
+
"loras/Coloring_book_-_LineArt.safetensors",
|
1277 |
1.0,
|
1278 |
None,
|
1279 |
1.0,
|
|
|
1283 |
1.0,
|
1284 |
None,
|
1285 |
1.0,
|
1286 |
+
"DPM++ 2M SDE Karras",
|
1287 |
+
1024,
|
1288 |
+
1024,
|
1289 |
+
"cagliostrolab/animagine-xl-3.1",
|
1290 |
None, # vae
|
1291 |
+
"lineart ControlNet",
|
1292 |
+
"color_image.png", # img conttol
|
1293 |
+
"Lineart", # preprocessor
|
1294 |
512, # preproc resolution
|
1295 |
+
896, # img resolution
|
1296 |
None, # Style prompt
|
1297 |
None, # Style json
|
1298 |
None, # img Mask
|
|
|
1305 |
0., # cn start
|
1306 |
1., # cn end
|
1307 |
False, # ti
|
1308 |
+
"Compel",
|
1309 |
None,
|
1310 |
],
|
1311 |
[
|
|
|
1316 |
5.,
|
1317 |
True,
|
1318 |
-1,
|
1319 |
+
"None",
|
1320 |
1.0,
|
1321 |
None,
|
1322 |
1.0,
|
|
|
1346 |
0.1, # distance mstd
|
1347 |
1.0, # cn scale
|
1348 |
0., # cn start
|
1349 |
+
0.9, # cn end
|
1350 |
False, # ti
|
1351 |
"Compel",
|
1352 |
"Nearest",
|