Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Merge branch 'comfyanonymous:master' into master

Fannovel16fa66ece26b10
diff --cc nodes.py
index 65f64e8af,547e6fbc8..d2fd3ff49
--- a/nodes.py
+++ b/nodes.py
@@@ -15,11 -15,12 +15,13 @@@ sys.path.insert(0, os.path.join(sys.pat
import comfy.samplers
import comfy.sd
+ import comfy.utils
+
import model_management
+import importlib
- supported_ckpt_extensions = ['.ckpt']
- supported_pt_extensions = ['.ckpt', '.pt', '.bin']
+ supported_ckpt_extensions = ['.ckpt', '.pth']
+ supported_pt_extensions = ['.ckpt', '.pt', '.bin', '.pth']
try:
import safetensors.torch
supported_ckpt_extensions += ['.safetensors']
@@@ -596,34 -743,8 +744,36 @@@ NODE_CLASS_MAPPINGS =
"LatentCrop": LatentCrop,
"LoraLoader": LoraLoader,
"CLIPLoader": CLIPLoader,
+ "ControlNetApply": ControlNetApply,
+ "ControlNetLoader": ControlNetLoader,
}
-
+CUSTOM_NODE_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "custom_nodes")
+def load_custom_nodes():
+ possible_modules = os.listdir(CUSTOM_NODE_PATH)
+ try:
+ #Comment out these two lines if you want to test
+ possible_modules.remove("example.py")
+ possible_modules.remove("example_folder")
+ possible_modules.remove("__pycache__")
+ except ValueError: pass
+ for possible_module in possible_modules:
+ module_path = os.path.join(CUSTOM_NODE_PATH, possible_module)
+ if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
+
+ try:
+ if os.path.isfile(module_path):
+ module_spec = importlib.util.spec_from_file_location(os.path.basename(module_path), module_path)
+ else:
+ module_spec = importlib.util.spec_from_file_location(module_path, "main.py")
+ module = importlib.util.module_from_spec(module_spec)
+ module_spec.loader.exec_module(module)
+ if getattr(module, "NODE_CLASS_MAPPINGS") is not None:
+ NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS)
+ else:
+ print(f"Skip {possible_module} module for custom nodes due to the lack of NODE_CLASS_MAPPINGS.")
+ except ImportError as e:
+ print(f"Cannot import {possible_module} module for custom nodes.")
+ print(e)
+
+load_custom_nodes()