Files
ahkimkoo-ComfyUI-VideoActor…/__init__.py
T
Cherokee ebad5ec8a2 fix: resolve namespace conflict with ComfyUI nodes module
- Rewrote __init__.py to use importlib for loading modules
- Avoids conflict between plugin's nodes/ dir and ComfyUI's nodes.py
- Tested in ComfyUI with 1080x1920 18.7s video
- Successfully detected 10 actors with green screen output
- actor_1 correctly shows 2 segments (appeared mid-video, left, returned)
- All actor_info.json and per-actor MP4s generated correctly
2026-04-21 17:34:14 +08:00

52 lines
2.0 KiB
Python

"""
ComfyUI-VideoActorExtract
Extract individual actors from video with green screen background.
"""
import os
import sys
# Add plugin directory to Python path
plugin_dir = os.path.dirname(os.path.abspath(__file__))
if plugin_dir not in sys.path:
sys.path.insert(0, plugin_dir)
# Use importlib to avoid namespace conflicts with ComfyUI's own 'nodes' module
import importlib.util
def _load_module(name, path):
spec = importlib.util.spec_from_file_location(name, path)
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
return module
# Load core modules first
core_config = _load_module("vae_core_config", os.path.join(plugin_dir, "core", "config.py"))
vae_video_reader = _load_module("vae_video_reader", os.path.join(plugin_dir, "core", "video_reader.py"))
# Load pipeline modules
vae_detector = _load_module("vae_detector", os.path.join(plugin_dir, "pipeline", "detector.py"))
vae_tracker = _load_module("vae_tracker", os.path.join(plugin_dir, "pipeline", "tracker.py"))
vae_identity = _load_module("vae_identity", os.path.join(plugin_dir, "pipeline", "identity.py"))
vae_cropper = _load_module("vae_cropper", os.path.join(plugin_dir, "pipeline", "cropper.py"))
vae_merger = _load_module("vae_merger", os.path.join(plugin_dir, "pipeline", "merger.py"))
# Load main node
vae_actor_extractor = _load_module("vae_actor_extractor", os.path.join(plugin_dir, "nodes", "actor_extractor.py"))
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
# Register nodes from the actor extractor module
if hasattr(vae_actor_extractor, "NODE_CLASS_MAPPINGS"):
NODE_CLASS_MAPPINGS.update(vae_actor_extractor.NODE_CLASS_MAPPINGS)
if hasattr(vae_actor_extractor, "NODE_DISPLAY_NAME_MAPPINGS"):
NODE_DISPLAY_NAME_MAPPINGS.update(vae_actor_extractor.NODE_DISPLAY_NAME_MAPPINGS)
WEB_DIRECTORY = "./js"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
print("[VideoActorExtract] Plugin loaded successfully!")