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
@@ -75,7 +75,7 @@ print('torch', torch.__version__, 'cuda=', torch.version.cuda)"
默认用到三个模型:`hustvl/vitmatte-base-composition-1k`(抠图)、
`ZhengPeng7/BiRefNet`(默认分割)、`skytnt/anime-seg`(可选分割)。
第四个模型 `ZhengPeng7/BiRefNet_HR-matting`(约 0.9 GB)只有在启用 **cross-check(交叉校验)
第四个模型 `ZhengPeng7/BiRefNet_HR-matting`(约 425 MB)只有在启用 **cross-check(交叉校验)
否决**时才需要——见本节末尾说明。下面两种放法**二选一**。
### 方案 A —— HuggingFace 缓存 + 离线模式(推荐)
@@ -119,7 +119,7 @@ hf download ZhengPeng7/BiRefNet_HR-matting # 仅在使用 cross-check 时(
├── config.json
├── BiRefNet_config.py # 自定义代码——trust_remote_code 必需
├── birefnet.py # 自定义代码——trust_remote_code 必需
└── model.safetensors # 约 0.9 GB
└── model.safetensors # 约 425 MB
```
说明:
@@ -145,7 +145,7 @@ hf download ZhengPeng7/BiRefNet_HR-matting --local-dir models/BiRefNet_HR-
### cross-check 否决(可选,服务里默认关闭)
管线可以再跑一个高分辨率 matting 模型(`ZhengPeng7/BiRefNet_HR-matting`,约 0.9 GB)
管线可以再跑一个高分辨率 matting 模型(`ZhengPeng7/BiRefNet_HR-matting`,约 425 MB)
作为"第二意见",专门清理发丝间残留的背景色。在 **HTTP 服务里默认是关的**、且懒加载,
所以不开启就不需要这个模型: