Spaces:
Sleeping
Sleeping
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Metric3D vit_large β HuggingFace Space (Docker SDK) | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM python:3.10-slim | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libgomp1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # 1) Torch CPU-only | |
| RUN pip install --no-cache-dir \ | |
| torch==2.3.0+cpu \ | |
| torchvision==0.18.0+cpu \ | |
| --index-url https://download.pytorch.org/whl/cpu | |
| # 2) mmengine + mmcv-lite (pur Python, pas de compilation C++/CUDA) | |
| RUN pip install --no-cache-dir mmengine==0.10.4 mmcv-lite==2.1.0 | |
| # 3) Reste des dΓ©pendances | |
| RUN pip install --no-cache-dir \ | |
| fastapi==0.111.0 \ | |
| "uvicorn[standard]==0.29.0" \ | |
| python-multipart==0.0.9 \ | |
| numpy==1.26.4 \ | |
| opencv-python-headless==4.9.0.80 \ | |
| Pillow==10.3.0 \ | |
| timm==0.9.16 \ | |
| einops==0.8.0 \ | |
| huggingface_hub==0.23.0 | |
| # 4) Cloner Metric3D et patcher l'import mmcv.utils β mmengine | |
| # (mono/utils/comm.py importe encore l'ancien mmcv.utils) | |
| RUN git clone https://github.com/YvanYin/Metric3D.git /metric3d && \ | |
| # Remplacer "from mmcv.utils import collect_env as collect_base_env" | |
| # par un import neutre qui ne plante pas | |
| sed -i 's/from mmcv.utils import collect_env as collect_base_env/from mmengine.utils.dl_utils import collect_env as collect_base_env/g' \ | |
| /metric3d/mono/utils/comm.py && \ | |
| # Forcer torch.hub Γ utiliser le repo local dΓ©jΓ clonΓ© | |
| mkdir -p /root/.cache/torch/hub && \ | |
| cp -r /metric3d /root/.cache/torch/hub/yvanyin_metric3d_main | |
| # 5) PrΓ©-tΓ©lΓ©charger les poids (le repo est dΓ©jΓ en cache local) | |
| RUN python -c "\ | |
| import sys; sys.path.insert(0, '/metric3d'); \ | |
| import mmcv; import mmengine; import torch; \ | |
| print('mmcv:', mmcv.__version__, '| mmengine:', mmengine.__version__); \ | |
| torch.hub.DEFAULT_CACHE_DIR = '/root/.cache/torch/hub'; \ | |
| model = torch.hub.load('/root/.cache/torch/hub/yvanyin_metric3d_main', \ | |
| 'metric3d_vit_large', pretrain=True, source='local', trust_repo=True); \ | |
| print('Poids en cache OK.'); \ | |
| del model" | |
| COPY app.py . | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |