Add scripts/fetch_weights.py; correct HR-matting size in DEPLOY

- fetch_weights.py: no-argument script that downloads every model weight into
  models/ via the hf-mirror (proxy forced-bypassed, Xet disabled). Model ids are
  read from config/code, and folders that already hold a weight file are skipped
  (no network, no re-download). After it runs the app has full functionality
  offline. Verified end to end (skips the 3 present models, pulls HR-matting).
- DEPLOY.md / DEPLOY_ZH.md: correct BiRefNet_HR-matting size from ~0.9 GB to the
  verified ~425 MB.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-05 09:35:17 +00:00
parent 4b5c714fa3
commit bfbeb9fc7f
3 changed files with 122 additions and 6 deletions
+3 -3
View File
@@ -81,7 +81,7 @@ print('torch', torch.__version__, 'cuda=', torch.version.cuda)"
Three models are used by default: `hustvl/vitmatte-base-composition-1k` (matting),
`ZhengPeng7/BiRefNet` (default segmenter), `skytnt/anime-seg` (optional segmenter).
A fourth model, `ZhengPeng7/BiRefNet_HR-matting` (~0.9 GB), is only needed if you
A fourth model, `ZhengPeng7/BiRefNet_HR-matting` (~425 MB), is only needed if you
enable the **cross-check** veto — see the note at the end of this section.
Pick **one** of the two layouts below.
@@ -127,7 +127,7 @@ finds it (`ZhengPeng7/BiRefNet` → `models/BiRefNet`). Required files per model
├── config.json
├── BiRefNet_config.py # custom code — required by trust_remote_code
├── birefnet.py # custom code — required by trust_remote_code
└── model.safetensors # ~0.9 GB
└── model.safetensors # ~425 MB
```
Notes:
@@ -155,7 +155,7 @@ Override the base directory with `BGFILTER_WEIGHTS_DIR`. `models/` is gitignored
### Cross-check veto (optional, off by default in the service)
The pipeline can run a second, high-resolution matting model
(`ZhengPeng7/BiRefNet_HR-matting`, ~0.9 GB) as a "second opinion" that only clears
(`ZhengPeng7/BiRefNet_HR-matting`, ~425 MB) as a "second opinion" that only clears
background residue trapped between hair strands. In the **HTTP service it is OFF by
default** and lazy-loaded, so you don't need this model unless you turn it on: