Download postBuild from filapro/zoo3d: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/spaces/filapro/zoo3d/resolve/main/postBuild
- Command line
-
hf download hf://spaces/filapro/zoo3d/postBuild
-
curl -L -o postBuild https://huggingface.co/spaces/filapro/zoo3d/resolve/main/postBuild
2.2 kB
| set -euo pipefail | |
| echo "postBuild: starting detectron2 setup" | |
| python -V || true | |
| pip --version || true | |
| # Ensure torch is present and print environment info | |
| python - <<'PY' || true | |
| import torch, platform, sys | |
| print("Torch:", torch.__version__) | |
| print("CUDA available:", torch.cuda.is_available()) | |
| print("torch.version.cuda:", getattr(torch.version, "cuda", None)) | |
| print("Python:", sys.version.split()[0]) | |
| print("Platform:", platform.platform()) | |
| PY | |
| # Determine expected wheel index (CPU or CUDA) based on installed torch | |
| PYTORCH_MM="$(python - <<'PY' | |
| import torch | |
| v = torch.__version__.split('+')[0].split('.') | |
| print(f"{v[0]}.{v[1]}") | |
| PY | |
| )" | |
| CUDA_TAG="$(python - <<'PY' | |
| import torch | |
| cv = getattr(torch.version, "cuda", None) | |
| print(("cu"+cv.replace(".","")) if cv else "cpu") | |
| PY | |
| )" | |
| WHEEL_URL="https://dl.fbaipublicfiles.com/detectron2/wheels/${CUDA_TAG}/torch${PYTORCH_MM}/index.html" | |
| echo "Attempting detectron2 wheel from: ${WHEEL_URL}" | |
| if pip install --no-cache-dir "detectron2" -f "${WHEEL_URL}"; then | |
| echo "detectron2 installed from prebuilt wheel" | |
| else | |
| echo "Prebuilt wheel not available. Building detectron2 from source (CPU-only) ..." | |
| export FORCE_CUDA=0 | |
| pip install --no-cache-dir --no-build-isolation "git+https://github.com/facebookresearch/detectron2.git@fd27788985af0f4ca800bca563acdb700bb890e2" | |
| fi | |
| # Verify installation | |
| python - <<'PY' | |
| import importlib | |
| spec = importlib.util.find_spec("detectron2") | |
| if spec is None: | |
| raise SystemExit("detectron2 not found after installation") | |
| import detectron2 | |
| print("detectron2 installed. Version:", getattr(detectron2, "__version__", "unknown")) | |
| PY | |
| echo "postBuild: detectron2 setup completed" | |
| #!/bin/sh | |
| set -e | |
| echo "[postBuild] Prepare build tools..." | |
| python -m pip install -U pip setuptools wheel ninja | |
| echo "[postBuild] Installing vendored detectron2 from MaskClustering/third_party/detectron2 ..." | |
| # Torch уже установлен из requirements.txt к моменту postBuild. | |
| # Отключаем build isolation, чтобы сборка видела установленный torch. | |
| export MAX_JOBS=${MAX_JOBS:-1} | |
| python -m pip install --no-build-isolation -e MaskClustering/third_party/detectron2 | |