CoolFace
Modelpublic

AXERA-TECH/RMBG-1.4

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes13downloads
Model Card

RMBG-1.4

This version of RMBG-1.4 has been converted to run on the Axera NPU using w8a8 quantization.

Compatible with Pulsar2 version: 5.1

Convert tools links:

For those who are interested in model conversion, you can try to export axmodel through

Support Platform

  • —AX650
Chipscost
AX650128 ms

How to use

Download all files from this repository to the device

bash
(base) root@ax650:/home/ax650/RMBG-1.4# tree
.
├── ax_inference.py
├── axmodel
│   ├── build_config.json
│   └── rmbg1_4_ax650.axmodel
├── ax_rmbg
├── img
│   ├── 3_1920x1080.jpg
│   └── example_input.jpg
├── mask.png
├── README.md
├── result.png
└── rmbg_1_4_sim.onnx

Inference

If you Inference with python,pyaxengine is need,you can install by:

python
wget https://github.com/AXERA-TECH/pyaxengine/releases/download/0.1.3.rc1/axengine-0.1.3-py3-none-any.whl
pip install axengine-0.1.3-py3-none-any.whl

Inference with AX650 Host, such as M4N-Dock(爱芯派Pro)

python
(base) root@ax650:/home/ax650/RMBG-1.4# python3 ax_inference.py -m ./axmodel/rmbg1_4_ax650.axmodel -i ./img/example_input.jpg
Command: ax_inference.py -m ./axmodel/rmbg1_4_ax650.axmodel -i ./img/example_input.jpg
Parameters:
  --model: ./axmodel/rmbg1_4_ax650.axmodel
  --img_path: ./img/example_input.jpg
  --save_path: ./result.png
[INFO] Available providers:  ['AxEngineExecutionProvider']
[INFO] Using provider: AxEngineExecutionProvider
[INFO] Chip type: ChipType.MC50
[INFO] VNPU type: VNPUType.DISABLED
[INFO] Engine version: 2.12.0s
[INFO] Model type: 0 (single core)
[INFO] Compiler version: 5.1 59c683ff
输入名称:input,输入尺寸:[1024, 1024]
推理时间:121.97 ms
推理完成,带透明通道的结果已保存至:./result.png
InputOutput
<img src="./img/exampleinput.jpg" alt="exampleinput" style="zoom: 33%;" /><img src="./img/exampleinputresult.png" alt="exampleinputresult" style="zoom:33%;" />

Inference with C++ version :

(base) root@ax650:/home/ax650/RMBG-1.4# ./ax_rmbg -m ./axmodel/rmbg1_4_ax650.axmodel -i ./img/3_1920x1080.jpg
--------------------------------------
Model file: ./axmodel/rmbg1_4_ax650.axmodel
Input image: ./img/3_1920x1080.jpg
Output image: result.png
Model input size: 1024 x 1024
Repeat count: 1
--------------------------------------
Original image size: 1920 x 1080, channels: 3
Engine creating handle is done.
Engine creating context is done.
Engine get io info is done. 
Inputs:
  [0] name: input, shape: [1, 3, 1024, 1024]
Outputs:
  [0] name: output, shape: [1, 1, 1024, 1024]
Engine alloc io is done. 
Engine push input is done. 
--------------------------------------
post process cost time:23.89 ms 
--------------------------------------
Repeat 1 times, avg time 106.16 ms, max_time 106.16 ms, min_time 106.16 ms
--------------------------------------
Saved result image: result.png
Saved mask: mask.png
InputOutputMask
<img src="./img/31920x1080.jpg" alt="31920x1080" style="zoom:20%;" /><img src="./img/31920x1080result.png" alt="31920x1080result" style="zoom:20%;" /><img src="./img/31920x1080mask.png" alt="31920x1080mask" style="zoom:20%;" />