Spaces:
Runtime error
Runtime error
change base model
Browse files
gui.py
CHANGED
@@ -1,18 +1,16 @@
|
|
1 |
import spaces
|
2 |
import os
|
3 |
-
from stablepy import Model_Diffusers
|
4 |
import torch
|
5 |
import logging
|
6 |
import random
|
7 |
import gradio as gr
|
8 |
-
|
9 |
from models.upscaler import upscaler_dict_gui
|
|
|
|
|
10 |
|
11 |
logging.getLogger("diffusers").setLevel(logging.ERROR)
|
12 |
-
import diffusers
|
13 |
-
|
14 |
diffusers.utils.logging.set_verbosity(40)
|
15 |
-
from utils.download_utils import download_things
|
16 |
|
17 |
hf_token: str = os.environ.get("HF_TOKEN")
|
18 |
|
@@ -28,7 +26,7 @@ class GuiSD:
|
|
28 |
|
29 |
print("Loading model...")
|
30 |
self.model = Model_Diffusers(
|
31 |
-
base_model_id="
|
32 |
task_name="txt2img",
|
33 |
vae_model=None,
|
34 |
type_model_precision=torch.float16,
|
@@ -60,7 +58,12 @@ class GuiSD:
|
|
60 |
model_is_xl = "xl" in model_name.lower()
|
61 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
62 |
model_type = "SDXL" if model_is_xl else "SD 1.5"
|
63 |
-
incompatible_vae = (
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
if incompatible_vae:
|
66 |
vae_model = None
|
@@ -210,7 +213,7 @@ class GuiSD:
|
|
210 |
print(la)
|
211 |
lora_type = ("animetarot" in la.lower() or "Hyper-SD15-8steps".lower() in la.lower())
|
212 |
if (model_is_xl and lora_type) or (not model_is_xl and not lora_type):
|
213 |
-
msg_inc_lora = f
|
214 |
gr.Info(msg_inc_lora)
|
215 |
msg_lora.append(msg_inc_lora)
|
216 |
|
@@ -223,8 +226,16 @@ class GuiSD:
|
|
223 |
params_ip_scale: list = []
|
224 |
|
225 |
all_adapters = [
|
226 |
-
(image_ip1,
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
]
|
229 |
|
230 |
for (imgip,
|
@@ -263,11 +274,18 @@ class GuiSD:
|
|
263 |
if task == "inpaint" and not image_mask:
|
264 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
265 |
|
266 |
-
if upscaler_model_path in [
|
|
|
|
|
|
|
|
|
267 |
upscaler_model = upscaler_model_path
|
268 |
else:
|
269 |
directory_upscalers = 'upscalers'
|
270 |
-
os.makedirs(
|
|
|
|
|
|
|
271 |
|
272 |
url_upscaler = upscaler_dict_gui[upscaler_model_path]
|
273 |
|
@@ -309,7 +327,6 @@ class GuiSD:
|
|
309 |
"inpaint_only": adetailer_inpaint_only,
|
310 |
"sampler": adetailer_sampler,
|
311 |
}
|
312 |
-
|
313 |
adetailer_params_B: dict = {
|
314 |
"face_detector_ad": face_detector_ad_b,
|
315 |
"person_detector_ad": person_detector_ad_b,
|
|
|
1 |
import spaces
|
2 |
import os
|
|
|
3 |
import torch
|
4 |
import logging
|
5 |
import random
|
6 |
import gradio as gr
|
7 |
+
import diffusers
|
8 |
from models.upscaler import upscaler_dict_gui
|
9 |
+
from stablepy import Model_Diffusers
|
10 |
+
from utils.download_utils import download_things
|
11 |
|
12 |
logging.getLogger("diffusers").setLevel(logging.ERROR)
|
|
|
|
|
13 |
diffusers.utils.logging.set_verbosity(40)
|
|
|
14 |
|
15 |
hf_token: str = os.environ.get("HF_TOKEN")
|
16 |
|
|
|
26 |
|
27 |
print("Loading model...")
|
28 |
self.model = Model_Diffusers(
|
29 |
+
base_model_id="models/animaPencilXL_v500.safetensors",
|
30 |
task_name="txt2img",
|
31 |
vae_model=None,
|
32 |
type_model_precision=torch.float16,
|
|
|
58 |
model_is_xl = "xl" in model_name.lower()
|
59 |
sdxl_in_vae = vae_model and "sdxl" in vae_model.lower()
|
60 |
model_type = "SDXL" if model_is_xl else "SD 1.5"
|
61 |
+
incompatible_vae = ((
|
62 |
+
model_is_xl and
|
63 |
+
vae_model and
|
64 |
+
not sdxl_in_vae) or
|
65 |
+
(not model_is_xl and
|
66 |
+
sdxl_in_vae))
|
67 |
|
68 |
if incompatible_vae:
|
69 |
vae_model = None
|
|
|
213 |
print(la)
|
214 |
lora_type = ("animetarot" in la.lower() or "Hyper-SD15-8steps".lower() in la.lower())
|
215 |
if (model_is_xl and lora_type) or (not model_is_xl and not lora_type):
|
216 |
+
msg_inc_lora = f'The LoRA {la} is for {'SD 1.5' if model_is_xl else 'SDXL'}, but you are using {model_type}.'
|
217 |
gr.Info(msg_inc_lora)
|
218 |
msg_lora.append(msg_inc_lora)
|
219 |
|
|
|
226 |
params_ip_scale: list = []
|
227 |
|
228 |
all_adapters = [
|
229 |
+
(image_ip1,
|
230 |
+
mask_ip1,
|
231 |
+
model_ip1,
|
232 |
+
mode_ip1,
|
233 |
+
scale_ip1),
|
234 |
+
(image_ip2,
|
235 |
+
mask_ip2,
|
236 |
+
model_ip2,
|
237 |
+
mode_ip2,
|
238 |
+
scale_ip2),
|
239 |
]
|
240 |
|
241 |
for (imgip,
|
|
|
274 |
if task == "inpaint" and not image_mask:
|
275 |
raise ValueError("No mask image found: Specify one in 'Image Mask'")
|
276 |
|
277 |
+
if upscaler_model_path in [
|
278 |
+
None,
|
279 |
+
"Lanczos",
|
280 |
+
"Nearest"
|
281 |
+
]:
|
282 |
upscaler_model = upscaler_model_path
|
283 |
else:
|
284 |
directory_upscalers = 'upscalers'
|
285 |
+
os.makedirs(
|
286 |
+
directory_upscalers,
|
287 |
+
exist_ok=True
|
288 |
+
)
|
289 |
|
290 |
url_upscaler = upscaler_dict_gui[upscaler_model_path]
|
291 |
|
|
|
327 |
"inpaint_only": adetailer_inpaint_only,
|
328 |
"sampler": adetailer_sampler,
|
329 |
}
|
|
|
330 |
adetailer_params_B: dict = {
|
331 |
"face_detector_ad": face_detector_ad_b,
|
332 |
"person_detector_ad": person_detector_ad_b,
|