Skip to content

Latest commit

 

History

History
74 lines (65 loc) · 7.68 KB

README.md

File metadata and controls

74 lines (65 loc) · 7.68 KB

MindYOLO推理

以下为yolo系列模型在ascend 310推理的步骤

1 安装依赖

pip install -r requirement.txt

2 安装MindSpore Lite

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

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

3 模型转换 ckpt -> mindir(可选)

训练完成的模型ckpt权重转为mindir 例如

python ./deploy/export.py --config ./configs/yolov5/yolov5n.yaml --weight yolov5.ckpt --file_format MINDIR --device_target Ascend

4 单张图片推理

以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支持列表中下载

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