Downloads · 30 days
0
happyme531/segment-anything-rknn2
segment-anything-rknn2 is a machine learning model from happyme531. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as unknown.
- 安装RKNPU2 2.0.0b23版本运行库 - 在开发板上安装python-opencv, rknn-toolkit-lite2, onnxruntime等 - 从 https://huggingface.co/happyme531/segment-anything-rknn2 下载模型文件(samvitb01ec64.pth.encoder.patched.onnx.rknn,samvitb01ec64.pth.decod…
Downloads · 30 days
0
Access
Public
Updated Jul 25, 2024
Repo size
255 MB
Likes
1
Public
Click a slice to open those files.
.rknn239 MB · 93%
From the Hugging Face model README
sam_vit_b_01ec64.pth.encoder.patched.onnx.rknn,sam_vit_b_01ec64.pth.decoder.onnx)输入:

提示:
{"type": "point", "data": [540, 512], "label": 1}
输出:

性能: RK3588,单NPU核心,耗时约22000ms
..性能瓶颈: Softmax太大,NPU无法执行
https://github.com/vietanhdev/samexporter 导出ONNX模型convert_encoder.py, 修改模型路径:
ONNX_MODEL="sam_vit_b_01ec64.pth.encoder.onnx"
convert_encoder.pypatch_graph.py, 会生成调整后的onnx文件convert_encoder.py, 修改模型路径, 执行转换即可sam_vit_b_01ec64.pth.encoder.patched.onnx.rknn, sam_vit_b_01ec64.pth.decoder.onnx)Input:

Prompt:
{"type": "point", "data": [540, 512], "label": 1}
Output:

Performance: RK3588, single NPU core, takes about 22000ms
..Performance bottleneck: Softmax is too large, NPU cannot execute
https://github.com/vietanhdev/samexporter to export ONNX modelconvert_encoder.py, modify the model path:
ONNX_MODEL="sam_vit_b_01ec64.pth.encoder.onnx"
convert_encoder.pypatch_graph.py, which will generate an adjusted onnx fileconvert_encoder.py again, modify the model path, and execute the conversion