mirror of
https://www.modelscope.cn/AI-ModelScope/RMBG-2.0.git
synced 2025-04-10 11:50:22 +08:00
Update README.md
This commit is contained in:
parent
6b1dc29b74
commit
e371aea0f8
32
.gitattributes
vendored
32
.gitattributes
vendored
@ -1,38 +1,42 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
||||
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
*.db* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ark* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.gguf* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ggml filter=lfs diff=lfs merge=lfs -text
|
||||
*.llamafile* filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
model_not_working.not_safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
t4.png filter=lfs diff=lfs merge=lfs -text
|
||||
collage.png filter=lfs diff=lfs merge=lfs -text
|
||||
collage3.png filter=lfs diff=lfs merge=lfs -text
|
||||
collage5.png filter=lfs diff=lfs merge=lfs -text
|
||||
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
pytorch_model.bin filter=lfs diff=lfs merge=lfs -text
|
||||
|
11
BiRefNet_config.py
Normal file
11
BiRefNet_config.py
Normal file
@ -0,0 +1,11 @@
|
||||
from transformers import PretrainedConfig
|
||||
|
||||
class BiRefNetConfig(PretrainedConfig):
|
||||
model_type = "SegformerForSemanticSegmentation"
|
||||
def __init__(
|
||||
self,
|
||||
bb_pretrained=False,
|
||||
**kwargs
|
||||
):
|
||||
self.bb_pretrained = bb_pretrained
|
||||
super().__init__(**kwargs)
|
178
README.md
178
README.md
@ -1,47 +1,143 @@
|
||||
---
|
||||
license: Apache License 2.0
|
||||
|
||||
#model-type:
|
||||
##如 gpt、phi、llama、chatglm、baichuan 等
|
||||
#- gpt
|
||||
|
||||
#domain:
|
||||
##如 nlp、cv、audio、multi-modal
|
||||
#- nlp
|
||||
|
||||
#language:
|
||||
##语言代码列表 https://help.aliyun.com/document_detail/215387.html?spm=a2c4g.11186623.0.0.9f8d7467kni6Aa
|
||||
#- cn
|
||||
|
||||
#metrics:
|
||||
##如 CIDEr、Blue、ROUGE 等
|
||||
#- CIDEr
|
||||
|
||||
#tags:
|
||||
##各种自定义,包括 pretrained、fine-tuned、instruction-tuned、RL-tuned 等训练方法和其他
|
||||
#- pretrained
|
||||
|
||||
#tools:
|
||||
##如 vllm、fastchat、llamacpp、AdaSeq 等
|
||||
#- vllm
|
||||
license: other
|
||||
license_name: bria-rmbg-2.0
|
||||
license_link: https://bria.ai/bria-huggingface-model-license-agreement/
|
||||
pipeline_tag: image-segmentation
|
||||
tags:
|
||||
- remove background
|
||||
- background
|
||||
- background-removal
|
||||
- Pytorch
|
||||
- vision
|
||||
- legal liability
|
||||
- transformers
|
||||
---
|
||||
### 当前模型的贡献者未提供更加详细的模型介绍。模型文件和权重,可浏览“模型文件”页面获取。
|
||||
#### 您可以通过如下git clone命令,或者ModelScope SDK来下载模型
|
||||
|
||||
SDK下载
|
||||
# BRIA Background Removal v2.0 Model Card
|
||||
|
||||
RMBG v2.0 is our new state-of-the-art background removal model, designed to effectively separate foreground from background in a range of
|
||||
categories and image types. This model has been trained on a carefully selected dataset, which includes:
|
||||
general stock images, e-commerce, gaming, and advertising content, making it suitable for commercial use cases powering enterprise content creation at scale.
|
||||
The accuracy, efficiency, and versatility currently rival leading source-available models.
|
||||
It is ideal where content safety, legally licensed datasets, and bias mitigation are paramount.
|
||||
|
||||
Developed by BRIA AI, RMBG v2.0 is available as a source-available model for non-commercial use.
|
||||
|
||||
[CLICK HERE FOR A DEMO](https://huggingface.co/spaces/briaai/BRIA-RMBG-2.0)
|
||||

|
||||
|
||||
## Model Details
|
||||
#####
|
||||
### Model Description
|
||||
|
||||
- **Developed by:** [BRIA AI](https://bria.ai/)
|
||||
- **Model type:** Background Removal
|
||||
- **License:** [bria-rmbg-2.0](https://bria.ai/bria-huggingface-model-license-agreement/)
|
||||
- The model is released under a Creative Commons license for non-commercial use.
|
||||
- Commercial use is subject to a commercial agreement with BRIA. [Contact Us](https://bria.ai/contact-us) for more information.
|
||||
|
||||
- **Model Description:** BRIA RMBG-2.0 is a dichotomous image segmentation model trained exclusively on a professional-grade dataset.
|
||||
- **BRIA:** Resources for more information: [BRIA AI](https://bria.ai/)
|
||||
|
||||
|
||||
|
||||
## Training data
|
||||
Bria-RMBG model was trained with over 15,000 high-quality, high-resolution, manually labeled (pixel-wise accuracy), fully licensed images.
|
||||
Our benchmark included balanced gender, balanced ethnicity, and people with different types of disabilities.
|
||||
For clarity, we provide our data distribution according to different categories, demonstrating our model’s versatility.
|
||||
|
||||
### Distribution of images:
|
||||
|
||||
| Category | Distribution |
|
||||
| -----------------------------------| -----------------------------------:|
|
||||
| Objects only | 45.11% |
|
||||
| People with objects/animals | 25.24% |
|
||||
| People only | 17.35% |
|
||||
| people/objects/animals with text | 8.52% |
|
||||
| Text only | 2.52% |
|
||||
| Animals only | 1.89% |
|
||||
|
||||
| Category | Distribution |
|
||||
| -----------------------------------| -----------------------------------------:|
|
||||
| Photorealistic | 87.70% |
|
||||
| Non-Photorealistic | 12.30% |
|
||||
|
||||
|
||||
| Category | Distribution |
|
||||
| -----------------------------------| -----------------------------------:|
|
||||
| Non Solid Background | 52.05% |
|
||||
| Solid Background | 47.95%
|
||||
|
||||
|
||||
| Category | Distribution |
|
||||
| -----------------------------------| -----------------------------------:|
|
||||
| Single main foreground object | 51.42% |
|
||||
| Multiple objects in the foreground | 48.58% |
|
||||
|
||||
|
||||
## Qualitative Evaluation
|
||||
Open source models comparison
|
||||

|
||||

|
||||
|
||||
### Architecture
|
||||
RMBG-2.0 is developed on the [BiRefNet](https://github.com/ZhengPeng7/BiRefNet) architecture enhanced with our proprietary dataset and training scheme. This training data significantly improves the model’s accuracy and effectiveness for background-removal task.<br>
|
||||
If you use this model in your research, please cite:
|
||||
|
||||
```
|
||||
@article{BiRefNet,
|
||||
title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
|
||||
author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
|
||||
journal={CAAI Artificial Intelligence Research},
|
||||
year={2024}
|
||||
}
|
||||
```
|
||||
|
||||
#### Requirements
|
||||
```bash
|
||||
#安装ModelScope
|
||||
pip install modelscope
|
||||
```
|
||||
```python
|
||||
#SDK模型下载
|
||||
from modelscope import snapshot_download
|
||||
model_dir = snapshot_download('AI-ModelScope/RMBG-2.0')
|
||||
```
|
||||
Git下载
|
||||
```
|
||||
#Git模型下载
|
||||
git clone https://www.modelscope.cn/AI-ModelScope/RMBG-2.0.git
|
||||
torch
|
||||
torchvision
|
||||
pillow
|
||||
kornia
|
||||
transformers
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
||||
|
||||
|
||||
```python
|
||||
from PIL import Image
|
||||
import matplotlib.pyplot as plt
|
||||
import torch
|
||||
from torchvision import transforms
|
||||
from transformers import AutoModelForImageSegmentation
|
||||
|
||||
model = AutoModelForImageSegmentation.from_pretrained('briaai/RMBG-2.0', trust_remote_code=True)
|
||||
torch.set_float32_matmul_precision(['high', 'highest'][0])
|
||||
model.to('cuda')
|
||||
model.eval()
|
||||
|
||||
# Data settings
|
||||
image_size = (1024, 1024)
|
||||
transform_image = transforms.Compose([
|
||||
transforms.Resize(image_size),
|
||||
transforms.ToTensor(),
|
||||
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
||||
])
|
||||
|
||||
image = Image.open(input_image_path)
|
||||
input_images = transform_image(image).unsqueeze(0).to('cuda')
|
||||
|
||||
# Prediction
|
||||
with torch.no_grad():
|
||||
preds = model(input_images)[-1].sigmoid().cpu()
|
||||
pred = preds[0].squeeze()
|
||||
pred_pil = transforms.ToPILImage()(pred)
|
||||
mask = pred_pil.resize(image.size)
|
||||
image.putalpha(mask)
|
||||
|
||||
image.save("no_bg_image.png")
|
||||
```
|
||||
|
||||
<p style="color: lightgrey;">如果您是本模型的贡献者,我们邀请您根据<a href="https://modelscope.cn/docs/ModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88" style="color: lightgrey; text-decoration: underline;">模型贡献文档</a>,及时完善模型卡片内容。</p>
|
2244
birefnet.py
Normal file
2244
birefnet.py
Normal file
File diff suppressed because it is too large
Load Diff
BIN
collage5.png
(Stored with Git LFS)
Normal file
BIN
collage5.png
(Stored with Git LFS)
Normal file
Binary file not shown.
20
config.json
Normal file
20
config.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"_name_or_path": "ZhengPeng7/BiRefNet",
|
||||
"architectures": [
|
||||
"BiRefNet"
|
||||
],
|
||||
"auto_map": {
|
||||
"AutoConfig": "BiRefNet_config.BiRefNetConfig",
|
||||
"AutoModelForImageSegmentation": "birefnet.BiRefNet"
|
||||
},
|
||||
"custom_pipelines": {
|
||||
"image-segmentation": {
|
||||
"pt": [
|
||||
"AutoModelForImageSegmentation"
|
||||
],
|
||||
"tf": [],
|
||||
"type": "image"
|
||||
}
|
||||
},
|
||||
"bb_pretrained": false
|
||||
}
|
1
configuration.json
Normal file
1
configuration.json
Normal file
@ -0,0 +1 @@
|
||||
{"framework": "pytorch", "task": "image-segmentation", "allow_remote": true}
|
BIN
diagram.png
Normal file
BIN
diagram.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
BIN
diagram1.png
Normal file
BIN
diagram1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
model.safetensors
(Stored with Git LFS)
Normal file
BIN
model.safetensors
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
pytorch_model.bin
(Stored with Git LFS)
Normal file
BIN
pytorch_model.bin
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user