Spaces:
Sleeping
Sleeping
| #!/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() | |