mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-10 22:07:19 +08:00
Revert folder_paths.py changes.
This commit is contained in:
parent
87dcae08d9
commit
9ffa089474
116
folder_paths.py
116
folder_paths.py
@ -10,84 +10,42 @@ from collections.abc import Collection
|
|||||||
supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.bin', '.pth', '.safetensors', '.pkl', '.sft'}
|
supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.bin', '.pth', '.safetensors', '.pkl', '.sft'}
|
||||||
|
|
||||||
folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {}
|
folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {}
|
||||||
|
|
||||||
|
base_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
models_dir = os.path.join(base_path, "models")
|
||||||
|
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
|
||||||
|
|
||||||
|
folder_names_and_paths["loras"] = ([os.path.join(models_dir, "loras")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["vae"] = ([os.path.join(models_dir, "vae")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["text_encoders"] = ([os.path.join(models_dir, "text_encoders"), os.path.join(models_dir, "clip")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["diffusion_models"] = ([os.path.join(models_dir, "unet"), os.path.join(models_dir, "diffusion_models")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["clip_vision"] = ([os.path.join(models_dir, "clip_vision")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["style_models"] = ([os.path.join(models_dir, "style_models")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["embeddings"] = ([os.path.join(models_dir, "embeddings")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["diffusers"] = ([os.path.join(models_dir, "diffusers")], ["folder"])
|
||||||
|
folder_names_and_paths["vae_approx"] = ([os.path.join(models_dir, "vae_approx")], supported_pt_extensions)
|
||||||
|
|
||||||
|
folder_names_and_paths["controlnet"] = ([os.path.join(models_dir, "controlnet"), os.path.join(models_dir, "t2i_adapter")], supported_pt_extensions)
|
||||||
|
folder_names_and_paths["gligen"] = ([os.path.join(models_dir, "gligen")], supported_pt_extensions)
|
||||||
|
|
||||||
|
folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions)
|
||||||
|
|
||||||
|
folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], set())
|
||||||
|
|
||||||
|
folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions)
|
||||||
|
|
||||||
|
folder_names_and_paths["photomaker"] = ([os.path.join(models_dir, "photomaker")], supported_pt_extensions)
|
||||||
|
|
||||||
|
folder_names_and_paths["classifiers"] = ([os.path.join(models_dir, "classifiers")], {""})
|
||||||
|
|
||||||
|
output_directory = os.path.join(base_path, "output")
|
||||||
|
temp_directory = os.path.join(base_path, "temp")
|
||||||
|
input_directory = os.path.join(base_path, "input")
|
||||||
|
user_directory = os.path.join(base_path, "user")
|
||||||
|
|
||||||
filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
|
filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
|
||||||
|
|
||||||
|
|
||||||
def reset_all_paths(new_base_path: str) -> None:
|
|
||||||
"""
|
|
||||||
Internal use only. Designed for use immediately after startup.
|
|
||||||
|
|
||||||
Removes all existing known paths, clears the filename cache, and creates the defaults under a new base path.
|
|
||||||
|
|
||||||
Paths:
|
|
||||||
- All default model paths
|
|
||||||
- input
|
|
||||||
- output
|
|
||||||
- temp
|
|
||||||
- user
|
|
||||||
- custom_nodes
|
|
||||||
|
|
||||||
Also creates the input directory if missing.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
new_base_path: The base path to prepend to all default relative paths.
|
|
||||||
"""
|
|
||||||
|
|
||||||
global base_path
|
|
||||||
global models_dir
|
|
||||||
global output_directory
|
|
||||||
global temp_directory
|
|
||||||
global input_directory
|
|
||||||
global user_directory
|
|
||||||
|
|
||||||
filename_list_cache.clear()
|
|
||||||
folder_names_and_paths.clear()
|
|
||||||
|
|
||||||
base_path = new_base_path
|
|
||||||
models_dir = os.path.join(base_path, "models")
|
|
||||||
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
|
|
||||||
|
|
||||||
folder_names_and_paths["loras"] = ([os.path.join(models_dir, "loras")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["vae"] = ([os.path.join(models_dir, "vae")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["text_encoders"] = ([os.path.join(models_dir, "text_encoders"), os.path.join(models_dir, "clip")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["diffusion_models"] = ([os.path.join(models_dir, "unet"), os.path.join(models_dir, "diffusion_models")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["clip_vision"] = ([os.path.join(models_dir, "clip_vision")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["style_models"] = ([os.path.join(models_dir, "style_models")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["embeddings"] = ([os.path.join(models_dir, "embeddings")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["diffusers"] = ([os.path.join(models_dir, "diffusers")], ["folder"])
|
|
||||||
folder_names_and_paths["vae_approx"] = ([os.path.join(models_dir, "vae_approx")], supported_pt_extensions)
|
|
||||||
|
|
||||||
folder_names_and_paths["controlnet"] = ([os.path.join(models_dir, "controlnet"), os.path.join(models_dir, "t2i_adapter")], supported_pt_extensions)
|
|
||||||
folder_names_and_paths["gligen"] = ([os.path.join(models_dir, "gligen")], supported_pt_extensions)
|
|
||||||
|
|
||||||
folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions)
|
|
||||||
|
|
||||||
folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], set())
|
|
||||||
|
|
||||||
folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions)
|
|
||||||
|
|
||||||
folder_names_and_paths["photomaker"] = ([os.path.join(models_dir, "photomaker")], supported_pt_extensions)
|
|
||||||
|
|
||||||
folder_names_and_paths["classifiers"] = ([os.path.join(models_dir, "classifiers")], {""})
|
|
||||||
|
|
||||||
output_directory = os.path.join(base_path, "output")
|
|
||||||
temp_directory = os.path.join(base_path, "temp")
|
|
||||||
input_directory = os.path.join(base_path, "input")
|
|
||||||
user_directory = os.path.join(base_path, "user")
|
|
||||||
|
|
||||||
# Create input dir if it does not already exist.
|
|
||||||
if not os.path.exists(input_directory):
|
|
||||||
try:
|
|
||||||
os.makedirs(input_directory)
|
|
||||||
except:
|
|
||||||
logging.error("Failed to create input directory")
|
|
||||||
|
|
||||||
|
|
||||||
# Default configuration: add all paths relative to this file.
|
|
||||||
reset_all_paths(os.path.dirname(os.path.realpath(__file__)))
|
|
||||||
|
|
||||||
|
|
||||||
class CacheHelper:
|
class CacheHelper:
|
||||||
"""
|
"""
|
||||||
Helper class for managing file list cache data.
|
Helper class for managing file list cache data.
|
||||||
@ -127,6 +85,12 @@ def map_legacy(folder_name: str) -> str:
|
|||||||
"clip": "text_encoders"}
|
"clip": "text_encoders"}
|
||||||
return legacy.get(folder_name, folder_name)
|
return legacy.get(folder_name, folder_name)
|
||||||
|
|
||||||
|
if not os.path.exists(input_directory):
|
||||||
|
try:
|
||||||
|
os.makedirs(input_directory)
|
||||||
|
except:
|
||||||
|
logging.error("Failed to create input directory")
|
||||||
|
|
||||||
def set_output_directory(output_dir: str) -> None:
|
def set_output_directory(output_dir: str) -> None:
|
||||||
global output_directory
|
global output_directory
|
||||||
output_directory = output_dir
|
output_directory = output_dir
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user