参考:
https://github.com/mindspore-lab/mindyolo
使用案例:
https://github.com/mindspore-lab/mindyolo/blob/master/GETTING_STARTED.md
安装:
pip install mindyolo
特别注意opencv-python、opencv-python-headless版本问题,不然会遇到ImportError: libGL.so.1: cannot open shared object file: No such file or directory等问题
1)下载项目
git clone https://github.com/mindspore-lab/mindyolo
2)运行测试
模型权重下载:https://github.com/mindspore-lab/mindyolo/blob/master/MODEL_ZOO.md
测试这种命令形式用华为昇腾npu推理速度不算快
cd mindyolo
# Run with Ascend (By default)华为昇腾npu推理
python demo/predict.py --config ./configs/yolov7/yolov7.yaml --weight=/path_to_ckpt/WEIGHT.ckpt --image_path /path_to_image/IMAGE.jpg
# Run with GPU
python demo/predict.py --config ./configs/yolov7/yolov7.yaml --weight=/path_to_ckpt/WEIGHT.ckpt --image_path /path_to_image/IMAGE.jpg --device_target=GPU
## 我这里用的yolov7-tiny测试
python demo/predict.py --config ./configs/yolov7/yolov7-tiny.yaml --weight=../yolov7-tiny_300e_mAP375-d8972c94.ckpt --image_path ../17people.jpg --device_target=CPU
推理图片结果保存在runs_infer/*/detect_results下
参考:https://github.com/mindspore-lab/mindyolo/blob/master/GETTING_STARTED.md
1)下载项目
git clone https://github.com/mindspore-lab/mindyolo
2)数据集制作或者下载第三方,制作数据集对应yaml;mindyolo暂时只支持yolo数据集格式,voc、coco暂时不大支持
数据下载:https://universe.roboflow.com/hero-d6kgf/yolov5-fall-detection/dataset/1
mindyolo yaml格式参考:
data:
dataset_name: gesture
train_set: /hom***/yolo/Rock_paper_scissor_test/train/images
val_set: /home/***/yolo/Rock_paper_scissor_test/valid/images
test_set: /home/***/yolo/Rock_paper_scissor_test/test/images
nc: 3
names: ['Paper', 'Rock', 'Scissor']
yolov8n1.yaml
__BASE__: [
'/home/***/yolo/Rock_paper_scissor_test/data.yaml',
'./hyp.scratch.low.yaml',
'./yolov8-base.yaml'
]
network:
depth_multiple: 0.33 # scales module repeats
width_multiple: 0.25 # scales convolution channels
max_channels: 1024
其他定义参数可以yolov8-base.yaml、hyp.scratch.low.yaml里更改,比如nc、names 训练的目标分类数量,或者训练train.py 传入
逐级覆盖,所有可配置参数满足,命令行直接传入 > yolov8n.yaml > yolov8-base.yaml > hyp.yaml > coco.yaml
3)训练
#单卡 也可以是on 1 NPU/GPU/CPU:
python train.py --config ./configs/yolov8/yolov8n1.yaml --device_target Ascend
##多卡
mpirun --allow-run-as-root -n 2 python train.py --config ./configs/yolov7/yolov7.yaml --is_parallel True
训练报错:
解决方法:
mindyolo/data/dataset.py Line 198 self.imgIds =
[int(Path(im_file).stem) for im_file in self.img_files]
由于采用自定义数据集,图片并非按照 int value.jpg 的格式保存,故改为 self.imgIds = [index for
index in range(len(self.img_files))]
5)训练好的模型预测:
python demo/predict.py --config ./configs/yolov8/yolov8n1.yaml --weight ./runs/2023.11.14-18.58.18/weights/yolov8n1-100_82.ckpt --image_path ../1a.jpeg
然后拷贝桶内内容到云服务器里:
参考:https://support.huaweicloud.com/moxing-devg-modelarts/modelarts_11_0005.html#section5