#3783 Extra Models Configuration with subfolders If you want to use web ui models in Comfy Ui and for structural reasons have structured the checkpoints, VAE etc in the Web Ui models folder in subfolders, these are not recognized by Comfy Ui. It would be desirable if ComfyUI would also recognize subfolders

f.e. Extra Models Folder -> Checkpoints -> SD 1.5, SD 2.1, SD 3 Medium
This commit is contained in:
parlt 2024-06-19 11:20:08 +02:00
parent 55f0dc124e
commit 0a9feb3f90
2 changed files with 13 additions and 1 deletions

View File

@ -126,10 +126,20 @@ def exists_annotated_filepath(name):
def add_model_folder_path(folder_name, full_folder_path):
global folder_names_and_paths
if folder_name in folder_names_and_paths:
folder_names_and_paths[folder_name][0].append(full_folder_path)
subdirs = list_files(full_folder_path)
if len(subdirs) == 0:
folder_names_and_paths[folder_name][0].append(full_folder_path)
else:
for subdir in subdirs:
folder_names_and_paths[folder_name][0].append(subdir)
else:
folder_names_and_paths[folder_name] = ([full_folder_path], set())
def list_files(dir):
r = []
return [x[0] for x in os.walk(dir)]
def get_folder_paths(folder_name):
return folder_names_and_paths[folder_name][0][:]

View File

@ -184,6 +184,8 @@ def load_extra_path_config(yaml_path):
if base_path is not None:
full_path = os.path.join(base_path, full_path)
logging.info("Adding extra search path {} {}".format(x, full_path))
full_path = full_path.replace("\\", "\\")
full_path = full_path.replace("\\", "/")
folder_paths.add_model_folder_path(x, full_path)