4
4
from os .path import exists
5
5
from modules .model_loader import load_file_from_url
6
6
7
- def load_paths ():
7
+ def load_paths (paths_filename ):
8
8
paths_dict = {
9
9
'modelfile_path' : '../models/checkpoints/' ,
10
10
'lorafile_path' : '../models/loras/' ,
@@ -13,13 +13,15 @@ def load_paths():
13
13
'controlnet_path' : '../models/controlnet/' ,
14
14
'vae_approx_path' : '../models/vae_approx/' ,
15
15
'fooocus_expansion_path' : '../models/prompt_expansion/fooocus_expansion/' ,
16
+ 'upscale_models_path' : '../models/upscale_models/' ,
17
+ 'inpaint_models_path' : '../models/inpaint/' ,
16
18
'styles_path' : '../sdxl_styles/' ,
17
19
'wildcards_path' : '../wildcards/' ,
18
20
'temp_outputs_path' : '../outputs/'
19
21
}
20
22
21
- if exists ('paths.json' ):
22
- with open ('paths.json' , encoding = 'utf-8' ) as paths_file :
23
+ if exists (paths_filename ):
24
+ with open (paths_filename , encoding = 'utf-8' ) as paths_file :
23
25
try :
24
26
paths_obj = json .load (paths_file )
25
27
if 'path_checkpoints' in paths_obj :
@@ -36,6 +38,10 @@ def load_paths():
36
38
paths_dict ['vae_approx_path' ] = paths_obj ['path_vae_approx' ]
37
39
if 'path_fooocus_expansion' in paths_obj :
38
40
paths_dict ['fooocus_expansion_path' ] = paths_obj ['path_fooocus_expansion' ]
41
+ if 'path_upscale_models' in paths_obj :
42
+ paths_dict ['upscale_models_path' ] = paths_obj ['path_upscale_models' ]
43
+ if 'path_inpaint_models' in paths_obj :
44
+ paths_dict ['inpaint_models_path' ] = paths_obj ['path_inpaint_models' ]
39
45
if 'path_styles' in paths_obj :
40
46
paths_dict ['styles_path' ] = paths_obj ['path_styles' ]
41
47
if 'path_wildcards' in paths_obj :
@@ -71,13 +77,13 @@ def load_paths():
71
77
def get_config_or_set_default (key , default ):
72
78
global config_dict
73
79
v = config_dict .get (key , None )
74
- if isinstance (v , str ) and os . path . exists ( v ) and os . path . isdir ( v ):
75
- return v
76
- else :
77
- dp = os .path .abspath ( os .path .join ( os . path . dirname ( __file__ ), default ))
80
+ if not isinstance (v , str ):
81
+ v = default
82
+ dp = v if os . path . isabs ( v ) else os . path . abspath ( os . path . join ( os . path . dirname ( __file__ ), v ))
83
+ if not os .path .exists ( dp ) or not os .path .isdir ( dp ):
78
84
os .makedirs (dp , exist_ok = True )
79
85
config_dict [key ] = dp
80
- return dp
86
+ return dp
81
87
82
88
83
89
modelfile_path = get_config_or_set_default ('modelfile_path' , '../models/checkpoints/' )
0 commit comments