Support loading model weights from local project folders
Add bgfilter/weights.py: resolve_model_source() maps a HuggingFace repo id to a local folder under the weights dir (models/ by default, override with BGFILTER_WEIGHTS_DIR) when one named after the repo basename exists; otherwise the repo id is returned unchanged. Opt-in and backward compatible. - vitmatte_infer.py / segmentation.py resolve model_name through it; anime-seg reads <dir>/isnetis.onnx directly instead of hf_hub_download when local. - .gitignore: models/, model-cache/ - README: document bundling weights as plain project folders. Verified: anime-seg loads from a local models/anime-seg/ folder offline. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -205,6 +205,13 @@ D:\MiniConda\envs\lightML\python.exe scripts\smoke_samples.py `
|
||||
`FileMetadataError`; (2) with `hf-xet` installed the Xet download path fails instantly.
|
||||
Once the weights are cached, run offline with `HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1`
|
||||
(as the service does in production).
|
||||
- Bundling weights in the project — instead of the HF cache, drop each model into a
|
||||
plain folder named after the repo basename under `models/`:
|
||||
`models/vitmatte-base-composition-1k`, `models/BiRefNet`, `models/anime-seg`. The loader
|
||||
prefers a matching local folder and falls back to the HF repo id / cache when absent, so
|
||||
it is opt-in. Populate them with e.g. `hf download ZhengPeng7/BiRefNet --local-dir
|
||||
models/BiRefNet`. Override the base directory with `BGFILTER_WEIGHTS_DIR`. `models/` is
|
||||
gitignored.
|
||||
- Foreground colour estimation uses pymatting's `estimate_foreground_ml` to propagate
|
||||
clean foreground colour into semi-transparent edges before de-spill. Set
|
||||
`foreground.method: unmix` to fall back to the legacy heuristic.
|
||||
|
||||
Reference in New Issue
Block a user