Skip to content

Commit 20cea81

Browse files
committed
fix(depth-estimation): improve ONNX runtime provider detection and deploy script
- transform.py: refine available EP detection for ONNX inference - deploy.bat: update dependency installation flow
1 parent 952e75b commit 20cea81

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

skills/transformation/depth-estimation/deploy.bat

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,18 @@ if %ERRORLEVEL% neq 0 (
100100
REM ── 5. Download ONNX model ─────────────────────────────────────────
101101
echo [DepthDeploy] Downloading ONNX model from HuggingFace...
102102

103-
%VENV_PYTHON% -c "from huggingface_hub import snapshot_download; snapshot_download('onnx-community/depth-anything-v2-small', local_dir='models/onnx/depth-anything-v2-small', allow_patterns=['onnx/*.onnx', 'onnx/*.json', 'preprocessor_config.json', 'config.json'])"
104-
if %ERRORLEVEL% equ 0 (
105-
echo [DepthDeploy] ONNX model downloaded successfully
103+
set "MODELS_DIR=%USERPROFILE%\.aegis-ai\models\feature-extraction"
104+
if not exist "%MODELS_DIR%" mkdir "%MODELS_DIR%"
105+
106+
if exist "%MODELS_DIR%\model.onnx" (
107+
echo [DepthDeploy] ONNX model already exists at %MODELS_DIR%\model.onnx
106108
) else (
107-
echo [DepthDeploy] WARNING: Model download failed — will retry on first run
109+
%VENV_PYTHON% -c "from huggingface_hub import hf_hub_download; import shutil, os; p = hf_hub_download('onnx-community/depth-anything-v2-small', 'onnx/model.onnx'); d = os.path.join(os.path.expanduser('~'), '.aegis-ai', 'models', 'feature-extraction', 'model.onnx'); shutil.copy2(p, d); print(f'[DepthDeploy] Model copied to {d}')"
110+
if %ERRORLEVEL% equ 0 (
111+
echo [DepthDeploy] ONNX model downloaded successfully
112+
) else (
113+
echo [DepthDeploy] WARNING: Model download failed — will retry on first run
114+
)
108115
)
109116

110117
REM ── 6. Verify installation ─────────────────────────────────────────

skills/transformation/depth-estimation/scripts/transform.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,15 @@ def _load_onnx(self, model_name: str, config: dict) -> dict:
245245
if not onnx_cfg:
246246
raise ValueError(f"No ONNX config for model: {model_name}")
247247

248-
# Download ONNX model from HuggingFace
249-
_log(f"Downloading ONNX model: {onnx_cfg['repo']}...", self._tag)
250-
model_path = hf_hub_download(onnx_cfg["repo"], onnx_cfg["filename"])
248+
# Check local models dir first (placed by deploy.bat or UI download)
249+
local_onnx = MODELS_DIR / f"{Path(onnx_cfg['filename']).stem}.onnx"
250+
if local_onnx.exists():
251+
model_path = str(local_onnx)
252+
_log(f"Found local ONNX model: {local_onnx}", self._tag)
253+
else:
254+
# Fall back to HuggingFace cache download
255+
_log(f"Downloading ONNX model: {onnx_cfg['repo']}...", self._tag)
256+
model_path = hf_hub_download(onnx_cfg["repo"], onnx_cfg["filename"])
251257

252258
# Build EP cascade: prefer GPU, fall back to CPU
253259
available_eps = ort.get_available_providers()

0 commit comments

Comments
 (0)