以下为yolo系列模型在ascend 310推理的步骤
pip install -r requirement.txt
MindSpore Lite官方页面请查阅:MindSpore Lite
- 下载tar.gz包并解压,同时配置环境变量LITE_HOME,LD_LIBRARY_PATH,PATH
tar -zxvf mindspore_lite-[xxx].tar.gz
export LITE_HOME=/[path_to_mindspore_lite_xxx]
export LD_LIBRARY_PATH=$LITE_HOME/runtime/lib:$LITE_HOME/tools/converter/lib:$LD_LIBRARY_PATH
export PATH=$LITE_HOME/tools/converter/converter:$LITE_HOME/tools/benchmark:$PATH
export Convert=$LITE_HOME/tools/converter/converter/converter_lite
LITE_HOME为tar.gz解压出的文件夹路径,请设置绝对路径
- 安装whl包
pip install mindspore_lite-[xxx].whl
- 验证过的MindSpore Lite版本为:2.2.14/2.3.0/2.3.1
- 请安装相对应的ascend driver/firmware/ascend-toolkit
训练完成的模型ckpt权重转为mindir 例如
python ./deploy/export.py --config ./configs/yolov5/yolov5n.yaml --weight yolov5.ckpt --file_format MINDIR --device_target Ascend
- 以yolov5为例,工作目录为/work
cd work
git clone https://github.com/mindspore-lab/mindyolo.git
cd mindyolo
export PYTHONPATH="/work/mindyolo":$PYTHONPATH
python ./deploy/mslite_predict.py --mindir_path yolov5n.mindir --config ./configs/yolov5/yolov5n.yaml --image_path test_img.jpg
yolov5n.mindir 是已经从ckpt转好的mindir文件。可从mindir支持列表中下载
- 如果想加快推理时加载模型的速度,可以把MindSpore mindir文件转换成MindSpore Lite mindir文件,直接使用lite mindir文件进行推理,例如:
$Convert --fmk=MINDIR --modelFile=./yolov5n.mindir --outputFile=./yolov5n_lite --saveType=MINDIR --optimize=ascend_oriented
python ./deploy/mslite_predict.py --mindir_path yolov5n_lite.mindir --config ./configs/yolov5/yolov5n.yaml --image_path test_img.jpg
modelFile为上面ckpt转好的mindir文件;outputFile为转换生成的MindSpore Lite mindir文件,默认会加扩展名mindir
model | scale | img size | dataset | map | recipe | mindir |
---|---|---|---|---|---|---|
YOLOv8 | N | 640 | MS COCO 2017 | 37.2 | yaml | mindir |
YOLOv8 | S | 640 | MS COCO 2017 | 44.6 | yaml | mindir |
YOLOv8 | M | 640 | MS COCO 2017 | 50.5 | yaml | mindir |
YOLOv8 | L | 640 | MS COCO 2017 | 52.8 | yaml | mindir |
YOLOv8 | X | 640 | MS COCO 2017 | 53.7 | yaml | mindir |
YOLOv7 | Tiny | 640 | MS COCO 2017 | 37.5 | yaml | mindir |
YOLOv7 | L | 640 | MS COCO 2017 | 50.8 | yaml | mindir |
YOLOv7 | X | 640 | MS COCO 2017 | 52.4 | yaml | mindir |
YOLOv5 | N | 640 | MS COCO 2017 | 27.3 | yaml | mindir |
YOLOv5 | S | 640 | MS COCO 2017 | 37.6 | yaml | mindir |
YOLOv5 | M | 640 | MS COCO 2017 | 44.9 | yaml | mindir |
YOLOv5 | L | 640 | MS COCO 2017 | 48.5 | yaml | mindir |
YOLOv5 | X | 640 | MS COCO 2017 | 50.5 | yaml | mindir |
YOLOv4 | CSPDarknet53 | 608 | MS COCO 2017 | 45.4 | yaml | mindir |
YOLOv4 | CSPDarknet53(silu) | 640 | MS COCO 2017 | 45.8 | yaml | mindir |
YOLOv3 | Darknet53 | 640 | MS COCO 2017 | 45.5 | yaml | mindir |
YOLOX | N | 416 | MS COCO 2017 | 24.1 | yaml | mindir |
YOLOX | Tiny | 416 | MS COCO 2017 | 33.3 | yaml | mindir |
YOLOX | S | 640 | MS COCO 2017 | 40.7 | yaml | mindir |
YOLOX | M | 640 | MS COCO 2017 | 46.7 | yaml | mindir |
YOLOX | L | 640 | MS COCO 2017 | 49.2 | yaml | mindir |
YOLOX | X | 640 | MS COCO 2017 | 51.6 | yaml | mindir |
YOLOX | Darknet53 | 640 | MS COCO 2017 | 47.7 | yaml | mindir |