junaid-simamdigital commited on
Commit
6e4fb8b
·
verified ·
1 Parent(s): a290cfb

Test DA3 package layout compatibility

Browse files
Files changed (1) hide show
  1. da3_compat.py +20 -0
da3_compat.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Dependency-free resolver for known Depth Anything 3 package layouts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+
7
+
8
+ def resolve_da3_class(importer=importlib.import_module):
9
+ """Return ``(DepthAnything3, module_name)`` or a useful ImportError."""
10
+ errors = []
11
+ for location in ("depth_anything_3.api", "depth_anything_3"):
12
+ try:
13
+ module = importer(location)
14
+ candidate = getattr(module, "DepthAnything3", None)
15
+ if candidate is not None:
16
+ return candidate, location
17
+ errors.append(f"{location}: DepthAnything3 is missing")
18
+ except (ImportError, ModuleNotFoundError, AttributeError) as exc:
19
+ errors.append(f"{location}: {type(exc).__name__}: {exc}")
20
+ raise ImportError("; ".join(errors))