File size: 1,609 Bytes
7bda5b0
 
 
 
 
 
 
 
 
 
 
 
c183d33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36552af
98d0755
36552af
c183d33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
license: afl-3.0
language:
- en
base_model:
- qualcomm/MobileSam
pipeline_tag: image-segmentation
tags:
- SAM
- MobileSAM
- Segmentation
---
# MobileSAM
基于MobileSAM的图像分割Pipeline,支持多种输入提示(框、点、掩码),支持650N/620E系列平台的模型推理。

支持芯片:
- AX650N
- AX620E
- AX630C


支持硬件

  - [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html)
  - [M.2 Accelerator card](https://docs.m5stack.com/zh_CN/ai_hardware/LLM-8850_Card)

原始模型请参考
- [MobileSAM Github](https://github.com/ChaoningZhang/MobileSAM)

## 性能对比

- 输入图片大小 1024x1024

|Chip| Models                | Latency (ms) | CMM Usage (MiB) |
|----| --------------------- | ---------------------- | -------------- |
|650N| mobile_sam_encoder          |49.495               | 48.334   |
|630C| mobile_sam_encoder         |520.044              | 63.231   |
|650N| mobile_sam_decoder          |9.930                | 16.703   | 
|630C| mobile_sam_decoder         |36.382               | 14.970   |

## 模型转换
- 模型转换工具链[Pulsar2](https://huggingface.co/AXERA-TECH/Pulsar2)
- 转换文档[Model Convert](https://github.com/AXERA-TECH/MobileSAM.axera/tree/master/convert)

## 环境准备
- NPU Python API: [pyaxengine](https://github.com/AXERA-TECH/pyaxengine)

安装需要的python库
```pip install -r requirements.txt```

## 运行
```shell
cd python_ax
python3 main.py -i ../images/test.jpg -c 650
```
output:
![point](./images/point_mask_ovlap_point_1.jpg)
![box](./images/box_mask_ovlap_box_1.jpg)