# yolov7 **Repository Path**: smyai/yolov7 ## Basic Information - **Project Name**: yolov7 - **Description**: 添加对mlu200支持 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2023-01-06 - **Last Updated**: 2023-07-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # **环境信息** - 板卡:MLU270-S4 - 模型:yolov7 - 模型链接:https://github.com/WongKinYiu/yolov7.git - pt文件:https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt # **环境准备** ## **下载模型和权重** ``` git clone https://github.com/WongKinYiu/yolov7.git cd yolov7 wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt ``` ## **安装系统依赖** ``` pip install seaborn ``` # **模型转换和验证** **备注:** - 转换成nozip的模型可以在训练模型的容器或者是大等于pytorch 1.6 环境进行模型转换 - 转换后的模型分别在大等于pytorch 1.6 环境和MLU 容器内基于CPU运行验证模型正确性 ## **模型转换** ### **转换成no zip 版本模型(大于等于1.6 Pytorch)** ``` python mlu/gen_unzipmodel.py ``` ## **验证转换后的模型(no zip )** ### **转换前(原始模型)-CPU运行:** ``` python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg --no-trace ``` ### **转换后模型-CPU运行** ``` python mlu/detect.py --weights mlu/weight/yolov7_unzip.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --no-trace ``` # **基于MLU验证** ## 模型量化 ``` python mlu/mlu_quant.py --weights mlu/weight/yolov7_unzip.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --qua_weight mlu/weight/yolov7_intx.pth --no-trace ``` ## **基于MLU运行量化后的模型** ### **运行命令(MLU+CPU NMS)** ``` #逐层运行+CPU NMS python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml # 融合模型运行+CPU NMS python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --jit #生成离线模型 python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --jit --mcore MLU270 --mname yolov7_4b4c --core 4 --batch 4 --save ``` ### **运行命令(MLU+mlu Yolo det)** ``` #逐层运行 + MLU yolo detection output python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --mlu_det #融合模型运行 + MLU yolo detection output python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --jit --mlu_det #生成MLU270离线模型 4B4C python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --jit --mlu_det --mcore MLU270 --mname yolov7_4b4c --core 4 --batch 4 --save #生成MLU270离线模型 1B4C python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --jit --mlu_det --mcore MLU270 --mname yolov7_1b4c --core 4 --batch 1 --save #生成MLU220离线模型 4B4C python mlu/mlu_detect.py --weights mlu/weight/yolov7_intx.pth --conf 0.25 --img-size 640 --source inference/images/horses.jpg --cfg ./cfg/deploy/yolov7.yaml --jit --mlu_det --mcore MLU220 --mname mlu220_yolov7_1b4c --core 4 --batch 1 --save ```