Two nodes: InfiniDepthModelLoader and InfiniDepthEstimate. Supports CUDA, MPS, and CPU via ComfyUI device management. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
"""ComfyUI custom node for InfiniDepth – arbitrary-resolution monocular depth estimation."""
|
||
|
||
import os
|
||
import sys
|
||
|
||
# Add the InfiniDepth repo root to sys.path so its modules can be imported.
|
||
# Supports three installation methods:
|
||
# 1. INFINIDEPTH_ROOT env var (explicit)
|
||
# 2. Symlink from ComfyUI/custom_nodes/ComfyUI-InfiniDepth -> <repo>/ComfyUI-InfiniDepth
|
||
# (realpath resolves to <repo>/ComfyUI-InfiniDepth, parent is repo root)
|
||
# 3. Cloned inside ComfyUI/custom_nodes/ with repo root elsewhere
|
||
|
||
_THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||
_CANDIDATE_ROOT = os.path.dirname(_THIS_DIR) # parent of ComfyUI-InfiniDepth/
|
||
|
||
if os.environ.get("INFINIDEPTH_ROOT"):
|
||
_INFINIDEPTH_ROOT = os.environ["INFINIDEPTH_ROOT"]
|
||
elif os.path.isdir(os.path.join(_CANDIDATE_ROOT, "InfiniDepth")):
|
||
# Symlinked or lives next to InfiniDepth/ package
|
||
_INFINIDEPTH_ROOT = _CANDIDATE_ROOT
|
||
else:
|
||
# Fallback: traverse from ComfyUI custom_nodes path
|
||
_INFINIDEPTH_ROOT = _CANDIDATE_ROOT
|
||
|
||
if _INFINIDEPTH_ROOT not in sys.path:
|
||
sys.path.insert(0, _INFINIDEPTH_ROOT)
|
||
|
||
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
||
|
||
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
|