77# from basicsr.utils.download_util import load_file_from_url
88import shared
99from core .modellib import load_file_from_url
10- from paths import script_path , models_path
1110
1211
13- def load_models (model_path : str , model_url : str = None , command_path : str = None , ext_filter = None , download_name = None ) -> list :
12+ def load_models (model_dir : str , model_url : str = None , command_path : str = None , ext_filter = None , download_name = None ) -> list :
1413 """
1514 A one-and done loader to try finding the desired models in specified directories.
1615
1716 @param download_name: Specify to download from model_url immediately.
1817 @param model_url: If no other models are found, this will be downloaded on upscale.
19- @param model_path : The location to store/find models in.
18+ @param model_dir : The location to store/find models in.
2019 @param command_path: A command-line argument to search for models in first.
2120 @param ext_filter: An optional list of filename extensions to filter by
2221 @return: A list of paths containing the desired model(s)
@@ -29,15 +28,15 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
2928 try :
3029 places = []
3130
32- if command_path is not None and command_path != model_path :
31+ if command_path is not None and command_path != model_dir :
3332 pretrained_path = os .path .join (command_path , 'experiments/pretrained_models' )
3433 if os .path .exists (pretrained_path ):
3534 print (f"Appending path: { pretrained_path } " )
3635 places .append (pretrained_path )
3736 elif os .path .exists (command_path ):
3837 places .append (command_path )
3938
40- places .append (model_path )
39+ places .append (model_dir )
4140
4241 for place in places :
4342 if os .path .exists (place ):
@@ -54,7 +53,7 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
5453
5554 if model_url is not None and len (output ) == 0 :
5655 if download_name is not None :
57- dl = load_file_from_url (model_url , model_path , True , download_name )
56+ dl = load_file_from_url (model_url , model_dir , True , download_name )
5857 output .append (dl )
5958 else :
6059 output .append (model_url )
@@ -74,26 +73,26 @@ def friendly_name(file: str):
7473 return model_name
7574
7675
77- def cleanup_models ():
78- # This code could probably be more efficient if we used a tuple list or something to store the src/destinations
79- # and then enumerate that, but this works for now. In the future, it'd be nice to just have every "model" scaler
80- # somehow auto-register and just do these things...
81- root_path = script_path
82- src_path = models_path
83- dest_path = os .path .join (models_path , "Stable-diffusion" )
84- move_files (src_path , dest_path , ".ckpt" )
85- src_path = os .path .join (root_path , "ESRGAN" )
86- dest_path = os .path .join (models_path , "ESRGAN" )
87- move_files (src_path , dest_path )
88- src_path = os .path .join (root_path , "gfpgan" )
89- dest_path = os .path .join (models_path , "GFPGAN" )
90- move_files (src_path , dest_path )
91- src_path = os .path .join (root_path , "SwinIR" )
92- dest_path = os .path .join (models_path , "SwinIR" )
93- move_files (src_path , dest_path )
94- src_path = os .path .join (root_path , "repositories/latent-diffusion/experiments/pretrained_models/" )
95- dest_path = os .path .join (models_path , "LDSR" )
96- move_files (src_path , dest_path )
76+ # def cleanup_models():
77+ # # This code could probably be more efficient if we used a tuple list or something to store the src/destinations
78+ # # and then enumerate that, but this works for now. In the future, it'd be nice to just have every "model" scaler
79+ # # somehow auto-register and just do these things...
80+ # root_path = script_path
81+ # src_path = models_path
82+ # dest_path = os.path.join(models_path, "Stable-diffusion")
83+ # move_files(src_path, dest_path, ".ckpt")
84+ # src_path = os.path.join(root_path, "ESRGAN")
85+ # dest_path = os.path.join(models_path, "ESRGAN")
86+ # move_files(src_path, dest_path)
87+ # src_path = os.path.join(root_path, "gfpgan")
88+ # dest_path = os.path.join(models_path, "GFPGAN")
89+ # move_files(src_path, dest_path)
90+ # src_path = os.path.join(root_path, "SwinIR")
91+ # dest_path = os.path.join(models_path, "SwinIR")
92+ # move_files(src_path, dest_path)
93+ # src_path = os.path.join(root_path, "repositories/latent-diffusion/experiments/pretrained_models/")
94+ # dest_path = os.path.join(models_path, "LDSR")
95+ # move_files(src_path, dest_path)
9796
9897
9998def move_files (src_path : str , dest_path : str , ext_filter : str = None ):
0 commit comments