gcw_mXoV1I2Z/briaai-RMBG-1.4
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

briaai/RMBG-1.4 — 昇腾 NPU 适配

BRIA RMBG-1.4 背景移除/抠图模型,适配 昇腾 NPU(Ascend 910 / torch-npu)。

环境

  • 昇腾 NPU + CANN
  • torch 2.9.0 + torch_npu 2.9.0.post1
  • transformers 4.57.6 / timm 1.0.28 / fastapi / uvicorn / pillow / safetensors

用法

# CLI 单图推理
python inference.py --img test_input.jpg

# FastAPI 服务
uvicorn inference:app --host 0.0.0.0 --port 8001
curl -F "file=@test_input.jpg" http://127.0.0.1:8001/predict

推理输出 JSON:device=npu:0、前景图(透明背景 PNG)路径、mask 覆盖率等。

适配说明

  • 全量清理 CUDA 调用,模型与输入 Tensor 迁移至 npu:0。
  • 入口 inference.py 顶部含 NPU 初始化 try-except。
  • 模型代码位于 rmbg_model/(BriaRMBG 为 U²-Net 风格分割网络),权重缓存于 model_weights/briaai/RMBG-1.4/(model.safetensors,不入库)。