-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcomfy_utils.py
41 lines (29 loc) · 1.11 KB
/
comfy_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from pathlib import Path
import comfy.model_management as model_management
import folder_paths
# This is the 'comfyui-p2ldgan' folder
BASE_DIR = Path(__file__).absolute().parent
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
folder_paths.folder_names_and_paths["p2ldgan"] = (
[str(BASE_DIR / "checkpoints")],
{".pt"},
)
def register_node(identifier: str, display_name: str):
def decorator(cls):
NODE_CLASS_MAPPINGS[identifier] = cls
NODE_DISPLAY_NAME_MAPPINGS[identifier] = display_name
return cls
return decorator
def get_p2ldgan_model_path() -> Path:
search_paths = folder_paths.get_folder_paths("p2ldgan")
for search_path in search_paths:
model_path = Path(search_path) / "p2ldgan_generator_200.pth"
if model_path.is_symlink():
model_path = Path(os.path.join(model_path.parent, os.readlink(model_path)))
if model_path.exists():
return model_path
raise FileNotFoundError(
"Failed to find 'p2ldgan_generator_200.pth', please place it here: ComfyUI/custom_nodes/comfyui-p2ldgan/checkpoints"
)