Yolov5 基本环境(cpu)搭建记录

Yolov5 基本环境(cpu)搭建记录

软件包:
1.anaconda(https://www.anaconda.com/)
2.pycharm(https://www.jetbrains.com/pycharm/)
3.torchvision-0.11.0+cpu-cp37-cp37m-win_amd64.whl(https://download.pytorch.org/whl/torchvision/)
4.torch-1.10.0+cpu-cp37-cp37m-win_amd64.whl(https://download.pytorch.org/whl/torch/)
5.yolov5-master.zip(https://github.com/ultralytics/yolov5/)
6.yolov5s.pt(https://github.com/ultralytics/yolov5/releases/download/v6.2/yolov5s.pt)

1.安装anaconda,创建py3.7环境;
2.进入py3.7环境,设置pip地址为清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
3.cd 进入到软件包3、4路径下,依次安装torch、torchvision
pip install torch-1.10.0+cpu-cp37-cp37m-win_amd64.whl
pip install torchvision-0.11.0+cpu-cp37-cp37m-win_amd64.whl
4.输入Python进入环境,然后输入
import torch
torch.version
查询是否安装成功,显示
‘1.10.0+cpu’
则成功安装torch.
5.yolov5-master.zip解压缩,并把yolov5s.pt文件放到解压目录里,cd进入YOLOv5master路径下
pip install --user -r requirements.txt
安装所需包,如遇到安装报错,重复执行耐心等待即可,直至出现
Successfully installed MarkupSafe-2.1.1 PyYAML-6.0 absl-py-1.3.0 backcall-0.2.0 cachetools-5.2.0 charset-normalizer-2.1.1 colorama-0.4.6 cycler-0.11.0 decorator-5.1.1 fonttools-4.38.0 gitdb-4.0.10 gitpython-3.1.29 google-auth-2.14.1 google-auth-oauthlib-0.4.6 grpcio-1.51.1 idna-3.4 importlib-metadata-5.1.0 ipython-7.34.0 jedi-0.18.2 kiwisolver-1.4.4 markdown-3.4.1 matplotlib-3.5.3 matplotlib-inline-0.1.6 oauthlib-3.2.2 opencv-python-4.6.0.66 packaging-21.3 pandas-1.3.5 parso-0.8.3 pickleshare-0.7.5 prompt-toolkit-3.0.33 protobuf-3.20.3 psutil-5.9.4 pyasn1-0.4.8 pyasn1-modules-0.2.8 pygments-2.13.0 pyparsing-3.0.9 python-dateutil-2.8.2 pytz-2022.6 requests-2.28.1 requests-oauthlib-1.3.1 rsa-4.9 scipy-1.7.3 seaborn-0.12.1 six-1.16.0 smmap-5.0.0 tensorboard-2.11.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 thop-0.1.1.post2209072238 tqdm-4.64.1 traitlets-5.6.0 urllib3-1.26.13 wcwidth-0.2.5 werkzeug-2.2.2 zipp-3.11.0

6.还是在YOLOv5master目录下,执行
python detect.py --source data/images/bus.jpg --weights pretrained/yolov5s.pt
出现关键信息:
YOLOv5 2022-11-19 Python-3.7.15 torch-1.10.0+cpu CPU
表示YOLOv5已经成功运行在CPU上了,后面会给出结果:
Fusing layers…
YOLOv5s summary: 213 layers, 7225885 parameters, 0 gradients, 16.4 GFLOPs
image 1/1 D:\yolov5-master\data\images\bus.jpg: 640x480 4 persons, 1 bus, 127.7ms
Speed: 0.0ms pre-process, 127.7ms inference, 2.0ms NMS per image at shape (1, 3, 640, 640)
Results saved to runs\detect\exp
成功识别出人和汽车,结果在路径下。

7.为更方便做项目,安装pytharm社区版,选择YOLOv5master目录打开,File->Setting->Plugins->ChineseLanguage->Install
8.File->Setting->Project:yolov-master->Python Interpreter->Addinterpreter->Add local Interpreter->
Conda Environment->Location->anaconda安装路径\anaconda3\envs\Py3.7,Python version选3.7->OK
Yolov5 基本环境(cpu)搭建记录_第1张图片

你可能感兴趣的:(经验总结,python,pycharm,开发语言)