下载项目https://github.com/xugaoxiang/yolov5-pyqt5
解压项目,创建anaconda环境
conda create -n 环境名 python=3.8 conda activate 环境名 conda remove --name env_name --all 删除环境
Pycharm项目中settings设置使用创建的环境,定位到环境后使用命令安装需要的库
pip install -r requirements.txt
安装库后,安装pytorch、cuda,安装版本为1.7,cuda为11.0
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=11.0
等待安装完成后,测试
python import torch print(torch.cuda.is_available())
如果为True,则安装完成
pyinstaller打包出现Error loading错误_ccp_huster的博客-CSDN博客
下载Yolov5版本模型,下载地址https://objects.githubusercontent.com/github-production-release-asset-2e65be/264818686/56dd3480-9af3-11eb-9c92-3ecd167961dc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220531%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220531T082809Z&X-Amz-Expires=300&X-Amz-Signature=227ad4633300c72a70ab87b6beab9702c4e704a12f377fc48884899e90f46ec2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=264818686&response-content-disposition=attachment%3B%20filename%3Dyolov5s.pt&response-content-type=application%2Foctet-stream
下载后,保存到项目的weights文件夹中
运行项目时,报以下错误
报错1:
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ......
解决方案:model/common.py里面去找到这个SPPF的类,把它拷过来到你这个Tags5的model/common.py里面,这样你的代码就也有这个类了,还要引入一个warnings包
import warnings
class SPPF(nn.Module):
# Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher
def __init__(self, c1, c2, k=5): # equivalent to SPP(k=(5, 9, 13))
super().__init__()
c_ = c1 // 2 # hidden channels
self.cv1 = Conv(c1, c_, 1, 1)
self.cv2 = Conv(c_ * 4, c2, 1, 1)
self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)
def forward(self, x):
x = self.cv1(x)
with warnings.catch_warnings():
warnings.simplefilter('ignore') # suppress torch 1.9.0 max_pool2d() warning
y1 = self.m(x)
y2 = self.m(y1)
return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))
报错2:AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
更改forward函数,复制一遍,去掉下面一行的代码即可
- yolov5 5.0+pytorch1.7+cu110
- pyqt5
安装生成exe包可视化工具
pip install auto-py-to-exe
此时可以重启电脑,至于为什么不知道
启动:auto-py-to-exe
参考网址:
图像化工具打包yolov5,生成可执行文件exe - 迷途小书童的Note迷途小书童的Notehttps://xugaoxiang.com/2021/10/13/yolov5-to-exe/
intel-openmp
pip install intel-openmp



