Add prefetch-models.sh to download AI models on host when container DNS is blocked

Lets SAM, U2Net, BEN2, and BiRefNet-HR (optionally SDXL via --sdxl) be
downloaded outside Docker into ./data/, which is already bind-mounted
into the GPU container — so a blocked container network no longer blocks
first-run setup. Reuses the existing dual-mode download_sam_model.py and
download_u2net_model.py as-is. For the HuggingFace Hub models, sets
HF_HOME (rather than --cache-dir) so the host-side cache layout matches
the container's default ~/.cache/huggingface resolution exactly, avoiding
a path-nesting mismatch between the two.

Wired into install-local-gpu.sh's completion banner and
bring-up-local-gpu.sh's header, and referenced from the relevant README
troubleshooting sections and the hf_cache bind-mount comment in
docker-compose.gpu.yml.
This commit is contained in:
Claude
2026-06-18 16:13:11 +00:00
parent 38e80f8fb8
commit 3a977c7438
5 changed files with 123 additions and 7 deletions
+3 -4
View File
@@ -73,10 +73,9 @@ services:
# Persistent project data
- ./data:/app/data
# HuggingFace model cache — bind mount so models can be pre-downloaded on the host.
# If container DNS is blocked, download on the host and the container picks them up:
# pip install huggingface-hub
# huggingface-cli download diffusers/stable-diffusion-xl-1.0-inpainting-0.1 \
# --cache-dir ./data/hf_cache
# If container DNS is blocked, run ./prefetch-models.sh on the host first —
# it downloads BEN2/BiRefNet-HR (and optionally SDXL with --sdxl) straight
# into this directory, and the container picks them up on next start.
# To free disk space: rm -rf ./data/hf_cache
- ./data/hf_cache:/root/.cache/huggingface
# Scripts (for exec access)