ONNX 模型库
返回模型

说明文档

I need to fetch the README content for the HuggingFace model first. Let me retrieve it. The README.md for this model appears to be empty on HuggingFace. The user's message also shows "README content:" followed by nothing.

Let me check if this is a mirror of the original BRIA RMBG model: Found the original README. Here's the Chinese (Simplified) translation:


---
license: other
license_name: bria-rmbg-1.4
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
- transformers.js

extra_gated_description: RMBG v1.4 是一款源代码开放模型,仅供非商业用途
extra_gated_heading: "填写此表单即可立即获取访问权限"
extra_gated_fields:
  Name: text
  Company/Org name: text
  Org Type (Early/Growth Startup, Enterprise, Academy): text
  Role: text
  Country: text
  Email: text
  By submitting this form, I agree to BRIA's Privacy policy and Terms & conditions, see links below: checkbox
---

BRIA 背景移除 v1.4 模型卡片

RMBG v1.4 是我们最先进的背景移除模型,旨在有效分离各类目和图像类型中的前景与背景。该模型基于精心筛选的数据集训练,包括:通用素材图片、电商、游戏和广告内容,使其适用于支持大规模企业内容创作的商业应用场景。其准确性、效率和通用性目前已可媲美领先的源代码开放模型。在内容安全性、合法授权数据集和偏见缓解至关重要的场景中,该模型是理想选择。

RMBG v1.4 由 BRIA AI 开发,作为源代码开放模型提供,仅供非商业用途。

如需购买商业许可,请点击这里

点击此处查看演示

注意 新版 RMBG 已发布!请查看 RMBG-2.0

加入我们的 Discord 社区 获取更多信息、教程、工具,并与其他用户交流!

示例

模型描述

  • 开发者: BRIA AI

  • 模型类型: 背景移除

  • 许可协议: bria-rmbg-1.4

    • 该模型以知识共享许可协议发布,仅供非商业用途。
    • 商业用途需与 BRIA 签订商业协议。如需购买商业许可,请点击这里
  • 模型描述: BRIA RMBG 1.4 是一款专门基于专业级数据集训练的显著性分割模型。

  • BRIA: 更多信息请访问:BRIA AI

训练数据

Bria-RMBG 模型使用超过 12,000 张高质量、高分辨率、人工标注(像素级精度)、完全授权的图像进行训练。 我们的基准测试涵盖了性别平衡、种族平衡以及不同类型残障人士。 为清晰起见,我们提供了不同类别的数据分布,展示了模型的通用性。

图像分布:

类别 分布
仅物体 45.11%
人物与物体/动物 25.24%
仅人物 17.35%
人物/物体/动物与文字 8.52%
仅文字 2.52%
仅动物 1.89%
类别 分布
写实图像 87.70%
非写实图像 12.30%
类别 分布
非纯色背景 52.05%
纯色背景 47.95%
类别 分布
单一主要前景物体 51.42%
多个前景物体 48.58%

定性评估

示例

架构

RMBG v1.4 基于 IS-Net 开发,并结合了我们独特的训练方案和专有数据集。 这些改进显著提升了模型在各种图像处理场景中的准确性和有效性。

安装

pip install -qr https://huggingface.co/briaai/RMBG-1.4/resolve/main/requirements.txt

使用方法

加载管道

from transformers import pipeline
image_path = "https://farm5.staticflickr.com/4007/4322154488_997e69e4cf_z.jpg"
pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True)
pillow_mask = pipe(image_path, return_mask = True) # 输出 pillow 蒙版
pillow_image = pipe(image_path) # 将蒙版应用于输入并返回 pillow 图像

或加载模型

from PIL import Image
from skimage import io
import torch
import torch.nn.functional as F
from transformers import AutoModelForImageSegmentation
from torchvision.transforms.functional import normalize
model = AutoModelForImageSegmentation.from_pretrained("briaai/RMBG-1.4",trust_remote_code=True)
def preprocess_image(im: np.ndarray, model_input_size: list) -> torch.Tensor:
    if len(im.shape) < 3:
        im = im[:, :, np.newaxis]
    # orig_im_size=im.shape[0:2]
    im_tensor = torch.tensor(im, dtype=torch.float32).permute(2,0,1)
    im_tensor = F.interpolate(torch.unsqueeze(im_tensor,0), size=model_input_size, mode='bilinear')
    image = torch.divide(im_tensor,255.0)
    image = normalize(image,[0.5,0.5,0.5],[1.0,1.0,1.0])
    return image

def postprocess_image(result: torch.Tensor, im_size: list)-> np.ndarray:
    result = torch.squeeze(F.interpolate(result, size=im_size, mode='bilinear') ,0)
    ma = torch.max(result)
    mi = torch.min(result)
    result = (result-mi)/(ma-mi)
    im_array = (result*255).permute(1,2,0).cpu().data.numpy().astype(np.uint8)
    im_array = np.squeeze(im_array)
    return im_array

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model.to(device)

# 准备输入
image_path = "https://farm5.staticflickr.com/4007/4322154488_997e69e4cf_z.jpg"
orig_im = io.imread(image_path)
orig_im_size = orig_im.shape[0:2]
model_input_size = [1024, 1024]
image = preprocess_image(orig_im, model_input_size).to(device)

# 推理
result=model(image)

# 后处理
result_image = postprocess_image(result[0][0], orig_im_size)

# 保存结果
pil_mask_im = Image.fromarray(result_image)
orig_image = Image.open(image_path)
no_bg_image = orig_image.copy()
no_bg_image.putalpha(pil_mask_im)

jellybox/bria-rmbg-1.4

作者 jellybox

image-segmentation
↓ 0 ♥ 0

创建时间: 2024-06-18 07:34:21+00:00

更新时间: 2024-07-13 21:04:25+00:00

在 Hugging Face 上查看

文件 (3)

.gitattributes
README.md
bria-rmbg-14_1024.onnx ONNX