DimensioDepth / backend /test_model.py
wwieerrz's picture
🎨 Launch DimensioDepth - Advanced AI Depth Estimation
463afdd
raw
history blame
1.03 kB
#!/usr/bin/env python3
"""
Quick test script to verify ONNX models work
"""
import cv2
import numpy as np
from utils.model_loader import DepthAnythingV2
from pathlib import Path
print("Testing ONNX Depth-Anything V2 models...")
# Create a test image
test_image = np.random.randint(0, 255, (480, 640, 3), dtype=np.uint8)
print(f"Test image shape: {test_image.shape}")
# Test small model
small_model_path = Path("models/cache/depth_anything_v2_vits.onnx")
print(f"\nTesting small model: {small_model_path}")
print(f"Model exists: {small_model_path.exists()}")
try:
model = DepthAnythingV2(str(small_model_path), use_gpu=False)
print("βœ“ Model loaded successfully")
print("Running inference...")
depth = model.predict(test_image)
print(f"βœ“ Inference successful!")
print(f" Output shape: {depth.shape}")
print(f" Output range: {depth.min():.3f} to {depth.max():.3f}")
except Exception as e:
print(f"❌ Error: {type(e).__name__}: {str(e)}")
import traceback
traceback.print_exc()