fix: Improve DA3 import robustness for RunPod/nightly PyTorch environments

- Fix scoping bug in __init__.py where module_version was undefined after
  ImportError, causing incorrect DA3_AVAILABLE check
- Add defensive try/except guard around depth_anything_3 import in
  depth_estimation_node.py to handle edge cases
- Move logger initialization before DA3 import to prevent NameError
- Bump version to 1.3.6

Resolves node loading failures on RunPod with PyTorch nightly builds
where the error node "Depth Estimation (Error)" was incorrectly shown
even when DA3 was intentionally not installed.
This commit is contained in:
limbicnation
2025-12-08 22:23:36 +01:00
parent 4f44cd2694
commit 2b3f0c9033
3 changed files with 17 additions and 11 deletions
+10 -5
View File
@@ -30,16 +30,21 @@ except ImportError:
TIMM_AVAILABLE = False
print("Warning: timm not available. Direct loading of Depth Anything models may not work.")
# Get logger instance (basicConfig is called in __init__.py)
logger = logging.getLogger("DepthEstimation")
# Import DA3 availability status from the package's __init__
from . import DA3_AVAILABLE
# Conditionally import Depth Anything V3 if available
# Use defensive import guard to handle edge cases where DA3_AVAILABLE check passes
# but the actual import still fails (e.g., corrupted install, version mismatch)
if DA3_AVAILABLE:
from depth_anything_3.api import DepthAnything3
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("DepthEstimation")
try:
from depth_anything_3.api import DepthAnything3
except ImportError as e:
DA3_AVAILABLE = False
logger.warning(f"DA3 import failed despite availability check: {e}. DA3 models disabled.")
# Depth Anything V2 Implementation
class DepthAnythingV2(nn.Module):