--- license: apache-2.0 language: - en base_model: - briaai/RMBG-1.4 pipeline_tag: image-segmentation --- # 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 - [The repo of AXera Platform](https://github.com/AXERA-TECH/ax-samples), which you can get the detial of guide - [Pulsar2 Link, How to Convert ONNX to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/pulsar2/introduction.html) ## Support Platform - AX650 - [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html) - [M.2 Accelerator card](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_introduction.html) | Chips | cost | | ----- | ------ | | AX650 | 128 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 ``` | Input | Output | | :----------------------------------------------------------: | :----------------------------------------------------------: | | example_input | example_input_result | 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 ``` | Input | Output | Mask | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | 3_1920x1080 | 3_1920x1080_result | 3_1920x1080_mask |