1.代码(下载zip后解压)
https://github.com/WongKinYiu/yolov7https://github.com/WongKinYiu/yolov7
2.anaconda配置环境(以管理员身份打开anaconda prompt)
(1)创建环境
conda create -n yolov7 python=3.8
(2)激活环境
activate yolov7
(3)在代码文件夹路径下
pip install -r requirements.txt
而后 pip list查看安装成功没有,以下进行torch版本更换。
如果完全按照requirements.txt来安装的话,会发现安装的torch版本并不是gpu版本,所以得重新安装gpu版本的才能用你的gpu来训练Yolov7
Pytorch下载官网:PyTorchAn open source machine learning framework that accelerates the path from research prototyping to production deployment.https://pytorch.org/到previous中去寻找对应自己cuda版本的pytorch,选择wheel下(linux and windows)的pip下载指令,我选择的是对应cuda 11.1的(其实我的cuda版本是11.2),复制pip指令,我用的指令(torch1.8.0版本):
# CUDA 11.1
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
再通过pip list查看是否成功。
附加cuda与pytorch版本对应关系:PyTorch和CUDA版本对应关系 - 墨莲玦 - 博客园
3.安装小工具(labelImg):用于制作VOC数据集时,对数据集进行标注的工具。
(1)以管理员身份运行anaconda prompt输入:
conda install pyqt=5
(2)使用cd 命令进入刚刚下载解压的labelimg文件夹 【第一条指令执行完在终端是没有什么显示的,直接是下一条指令输入】
pyrcc5 -o resources.py resources.qrc
python labelImg.py
(3)第二条指令输入后可能出现以下两种错误:
1.ModuleNotFoundError: No module named 'libs.resources'
解决办法 将resources.py文件放入libs文件夹,再输入python labelImg.py尝试。可能会在出错
2.ModuleNotFoundError: No module named 'lxml'
参考链接:(全程记录yolov7入门到实现训练)跟着炮哥yolov5教程自学yolov7,接触yolov7半天,成功实现训练