add DEPLOY.md
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# Deploying BgFilter to a Linux server
|
||||
|
||||
> 中文版:[DEPLOY_ZH.md](DEPLOY_ZH.md)
|
||||
|
||||
This guide covers everything needed to run the BgFilter HTTP service
|
||||
(`POST /remove-background`, `GET /healthz`) on a Linux server. It assumes a CPU
|
||||
deployment (the default); GPU notes are called out where relevant.
|
||||
@@ -99,7 +101,38 @@ the `hub/` folder over.
|
||||
### Option B — plain folders inside the project
|
||||
|
||||
Drop each model into `models/<repo-basename>/` and the loader uses it directly (no
|
||||
HF cache, no network). Absent folders fall back to the repo id, so this is opt-in:
|
||||
HF cache, no network). Absent folders fall back to the repo id, so this is opt-in.
|
||||
|
||||
**The folder name must match the repo basename exactly** — that is how the loader
|
||||
finds it (`ZhengPeng7/BiRefNet` → `models/BiRefNet`). Required files per model:
|
||||
|
||||
```text
|
||||
<project-root>/
|
||||
└── models/
|
||||
├── vitmatte-base-composition-1k/ # ViTMatte matting model
|
||||
│ ├── config.json
|
||||
│ ├── preprocessor_config.json
|
||||
│ └── pytorch_model.bin # ~369 MB
|
||||
├── BiRefNet/ # default segmenter (trust_remote_code)
|
||||
│ ├── config.json
|
||||
│ ├── BiRefNet_config.py # custom code — required by trust_remote_code
|
||||
│ ├── birefnet.py # custom code — required by trust_remote_code
|
||||
│ └── model.safetensors # ~424 MB
|
||||
└── anime-seg/ # optional segmenter (seg_model=anime-seg)
|
||||
└── isnetis.onnx # ~168 MB
|
||||
```
|
||||
|
||||
Notes:
|
||||
- **ViTMatte**: needs `config.json`, `preprocessor_config.json`, and the weights
|
||||
(`pytorch_model.bin`; `model.safetensors` also works if present).
|
||||
- **BiRefNet**: the two `.py` files are mandatory — `trust_remote_code` executes them
|
||||
to build the model. Keep `config.json` + `model.safetensors` alongside them. (The
|
||||
repo's `handler.py` / `requirements.txt` / `README.md` are not needed.)
|
||||
- **anime-seg**: only `isnetis.onnx` is read; nothing else is required.
|
||||
- `anime-seg` is optional — omit its folder if you never use `seg_model=anime-seg`.
|
||||
|
||||
The easiest way to populate the folders is to let `hf download` fetch them (it also
|
||||
pulls a couple of unused files like `README.md`, which is harmless):
|
||||
|
||||
```bash
|
||||
hf download hustvl/vitmatte-base-composition-1k --local-dir models/vitmatte-base-composition-1k
|
||||
|
||||
Reference in New Issue
Block a user