CoolFace
Modelpublic

AXERA-TECH/RMBG-1.4

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes13downloads
README.md122 linesDownload Raw Back to root
1---2license: apache-2.03language:4- en5base_model:6- briaai/RMBG-1.47pipeline_tag: image-segmentation8---9# RMBG-1.4 10 11This version of RMBG-1.4 has been converted to run on the Axera NPU using **w8a8** quantization.12 13Compatible with Pulsar2 version: 5.114 15## Convert tools links:16 17For those who are interested in model conversion, you can try to export axmodel through18 19- [The repo of AXera Platform](https://github.com/AXERA-TECH/ax-samples), which you can get the detial of guide20- [Pulsar2 Link, How to Convert ONNX to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/pulsar2/introduction.html)21 22 23## Support Platform24 25- AX65026 27  - [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html)28 29  - [M.2 Accelerator card](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_introduction.html)30 31| Chips | cost   |32| ----- | ------ |33| AX650 | 128 ms |34 35## How to use36 37Download all files from this repository to the device38 39```bash40(base) root@ax650:/home/ax650/RMBG-1.4# tree41.42├── ax_inference.py43├── axmodel44│   ├── build_config.json45│   └── rmbg1_4_ax650.axmodel46├── ax_rmbg47├── img48│   ├── 3_1920x1080.jpg49│   └── example_input.jpg50├── mask.png51├── README.md52├── result.png53└── rmbg_1_4_sim.onnx54```55 56### Inference57 58If you Inference with python,pyaxengine is need,you can install by:59 60```python61wget https://github.com/AXERA-TECH/pyaxengine/releases/download/0.1.3.rc1/axengine-0.1.3-py3-none-any.whl62pip install axengine-0.1.3-py3-none-any.whl63```64 65Inference with AX650 Host, such as M4N-Dock(爱芯派Pro)66 67```python68(base) root@ax650:/home/ax650/RMBG-1.4# python3 ax_inference.py -m ./axmodel/rmbg1_4_ax650.axmodel -i ./img/example_input.jpg69Command: ax_inference.py -m ./axmodel/rmbg1_4_ax650.axmodel -i ./img/example_input.jpg70Parameters:71  --model: ./axmodel/rmbg1_4_ax650.axmodel72  --img_path: ./img/example_input.jpg73  --save_path: ./result.png74[INFO] Available providers:  ['AxEngineExecutionProvider']75[INFO] Using provider: AxEngineExecutionProvider76[INFO] Chip type: ChipType.MC5077[INFO] VNPU type: VNPUType.DISABLED78[INFO] Engine version: 2.12.0s79[INFO] Model type: 0 (single core)80[INFO] Compiler version: 5.1 59c683ff81输入名称:input,输入尺寸:[1024, 1024]82推理时间:121.97 ms83推理完成,带透明通道的结果已保存至:./result.png84```85 86|                            Input                             |                            Output                            |87| :----------------------------------------------------------: | :----------------------------------------------------------: |88| <img src="./img/example_input.jpg" alt="example_input" style="zoom: 33%;" /> | <img src="./img/example_input_result.png" alt="example_input_result" style="zoom:33%;" /> |89 90Inference with C++ version :91 92```93(base) root@ax650:/home/ax650/RMBG-1.4# ./ax_rmbg -m ./axmodel/rmbg1_4_ax650.axmodel -i ./img/3_1920x1080.jpg94--------------------------------------95Model file: ./axmodel/rmbg1_4_ax650.axmodel96Input image: ./img/3_1920x1080.jpg97Output image: result.png98Model input size: 1024 x 102499Repeat count: 1100--------------------------------------101Original image size: 1920 x 1080, channels: 3102Engine creating handle is done.103Engine creating context is done.104Engine get io info is done. 105Inputs:106  [0] name: input, shape: [1, 3, 1024, 1024]107Outputs:108  [0] name: output, shape: [1, 1, 1024, 1024]109Engine alloc io is done. 110Engine push input is done. 111--------------------------------------112post process cost time:23.89 ms 113--------------------------------------114Repeat 1 times, avg time 106.16 ms, max_time 106.16 ms, min_time 106.16 ms115--------------------------------------116Saved result image: result.png117Saved mask: mask.png118```119 120| Input                                                        | Output                                                       | Mask                                                         |121| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |122| <img src="./img/3_1920x1080.jpg" alt="3_1920x1080" style="zoom:20%;" /> | <img src="./img/3_1920x1080_result.png" alt="3_1920x1080_result" style="zoom:20%;" /> | <img src="./img/3_1920x1080_mask.png" alt="3_1920x1080_mask" style="zoom:20%;" /> |