Image Segmentation
Transformers.js
ONNX
BiRefNet
swin
background-removal
dichotomous-image-segmentation
webgpu
onnxruntime-web
Instructions to use CardAnvilModels/BiRefNet-lite-1024-WebGPU with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use CardAnvilModels/BiRefNet-lite-1024-WebGPU with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-segmentation', 'CardAnvilModels/BiRefNet-lite-1024-WebGPU'); - BiRefNet
How to use CardAnvilModels/BiRefNet-lite-1024-WebGPU with BiRefNet:
# Option 1: use with transformers from transformers import AutoModelForImageSegmentation birefnet = AutoModelForImageSegmentation.from_pretrained("CardAnvilModels/BiRefNet-lite-1024-WebGPU", trust_remote_code=True)# Option 2: use with BiRefNet # Install from https://github.com/ZhengPeng7/BiRefNet from models.birefnet import BiRefNet model = BiRefNet.from_pretrained("CardAnvilModels/BiRefNet-lite-1024-WebGPU") - Notebooks
- Google Colab
- Kaggle
Copy the files Card Anvil loads, unchanged
Browse files- LICENSE +21 -0
- README.md +33 -0
- config.json +6 -0
- onnx/model_fp16.onnx +3 -0
- preprocessor_config.json +23 -0
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 ZhengPeng
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: transformers.js
|
| 4 |
+
base_model: ZhengPeng7/BiRefNet_lite
|
| 5 |
+
pipeline_tag: image-segmentation
|
| 6 |
+
tags:
|
| 7 |
+
- onnx
|
| 8 |
+
- birefnet
|
| 9 |
+
- background-removal
|
| 10 |
+
- dichotomous-image-segmentation
|
| 11 |
+
- webgpu
|
| 12 |
+
- transformers.js
|
| 13 |
+
- onnxruntime-web
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# BiRefNet-lite 1024 (ONNX, WebGPU-runnable)
|
| 17 |
+
|
| 18 |
+
BiRefNet-lite at 1024 × 1024 as an fp16 ONNX export whose graph is patched to run on WebGPU in the browser; the weights are unchanged. [Card Anvil](https://github.com/Card-Anvil) uses it with [Transformers.js](https://github.com/huggingface/transformers.js) to select the main subject of card art.
|
| 19 |
+
|
| 20 |
+
This is an unchanged copy of the files Card Anvil loads from [`jiabins0303/birefnet-lite-1024-webgpu`](https://huggingface.co/jiabins0303/birefnet-lite-1024-webgpu) at commit [`1ad01ce`](https://huggingface.co/jiabins0303/birefnet-lite-1024-webgpu/tree/1ad01cef0f4101a285c5a3e0bd7f15597d93403f), kept here so the app loads files that can't change under it. See the source repo for how the graph was patched and verified.
|
| 21 |
+
|
| 22 |
+
| File | Source path |
|
| 23 |
+
| --- | --- |
|
| 24 |
+
| `config.json` | `config.json` |
|
| 25 |
+
| `preprocessor_config.json` | `preprocessor_config.json` |
|
| 26 |
+
| `onnx/model_fp16.onnx` | `onnx/model_fp16.onnx` |
|
| 27 |
+
|
| 28 |
+
## Credits and licence
|
| 29 |
+
|
| 30 |
+
- Model: [BiRefNet](https://github.com/ZhengPeng7/BiRefNet) by Peng Zheng et al. ([`ZhengPeng7/BiRefNet_lite`](https://huggingface.co/ZhengPeng7/BiRefNet_lite)), from *Bilateral Reference for High-Resolution Dichotomous Image Segmentation* (CAAI AIR 2024).
|
| 31 |
+
- WebGPU-runnable export: [`jiabins0303/birefnet-lite-1024-webgpu`](https://huggingface.co/jiabins0303/birefnet-lite-1024-webgpu).
|
| 32 |
+
|
| 33 |
+
Licensed under the MIT License, as the original model is. See [`LICENSE`](LICENSE).
|
config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "swin",
|
| 3 |
+
"transformers.js_config": {
|
| 4 |
+
"dtype": "fp32"
|
| 5 |
+
}
|
| 6 |
+
}
|
onnx/model_fp16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4059896039dfccb0f15b9080ff06d11d90e499449bb045e797055eb8901cf5f4
|
| 3 |
+
size 114834127
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_normalize": true,
|
| 3 |
+
"do_rescale": true,
|
| 4 |
+
"do_resize": true,
|
| 5 |
+
"feature_extractor_type": "ViTFeatureExtractor",
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.485,
|
| 8 |
+
0.456,
|
| 9 |
+
0.406
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "ViTFeatureExtractor",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.229,
|
| 14 |
+
0.224,
|
| 15 |
+
0.225
|
| 16 |
+
],
|
| 17 |
+
"resample": 2,
|
| 18 |
+
"rescale_factor": 0.00392156862745098,
|
| 19 |
+
"size": {
|
| 20 |
+
"height": 1024,
|
| 21 |
+
"width": 1024
|
| 22 |
+
}
|
| 23 |
+
}
|