| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| """ |
| Hugging Face Spaces App for Depth Anything 3 - Simplified Version. |
| |
| This version uses the simplified interface (ZIP in → ZIP out) with |
| the @spaces.GPU decorator for GPU resource management on HF Spaces. |
| """ |
|
|
| import os |
| import spaces |
| import torch |
|
|
| |
| from simple_app import SimpleDepthApp |
|
|
| |
| original_load_model = SimpleDepthApp.load_model |
|
|
| |
| @spaces.GPU(duration=180) |
| def gpu_load_model_wrapper(self): |
| """GPU-accelerated model loading with Spaces decorator.""" |
| return original_load_model(self) |
|
|
| |
| SimpleDepthApp.load_model = gpu_load_model_wrapper |
|
|
| |
| original_process_zip = SimpleDepthApp.process_zip |
|
|
| @spaces.GPU(duration=300) |
| def gpu_process_zip_wrapper(self, zip_file): |
| """GPU-accelerated ZIP processing with Spaces decorator.""" |
| return original_process_zip(self, zip_file) |
|
|
| |
| SimpleDepthApp.process_zip = gpu_process_zip_wrapper |
|
|
| if __name__ == "__main__": |
| |
| model_dir = os.environ.get("DA3_MODEL_DIR", "depth-anything/DA3NESTED-GIANT-LARGE") |
| |
| print("🚀 Starting Simplified Depth Anything 3 on HuggingFace Spaces...") |
| print(f"📦 Model: {model_dir}") |
| print(f"💾 GPU available: {torch.cuda.is_available()}") |
| |
| |
| app = SimpleDepthApp(model_dir=model_dir) |
| app.launch( |
| server_name="0.0.0.0", |
| server_port=7860, |
| share=False |
| ) |
|
|