一、下载YOLOv5源码
网址:https://github.com/ultralytics/yolov5/tree/v5.0
下载的版本:V5.0
问题1:要把配置好的pytorch环境用上
描述:主要是配置环境为:
操作步骤:file->settings->project->python interpreter
然后点击apply->ok.
问题2:发现安装库的时候pip指令不行
解决方法:https://zhuanlan.zhihu.com/p/126669852
参考以上博主的解决方法就可以解决了,要下载一个离线的VS tools
问题3:package requirement 'opencv-4.1.2’is not satisfied
解决方法:pip install python-opencv
原因:pycharm库里OpenCV不叫cv2
问题4:package requirement ‘pycocotools’ is not satisfied
解决方法:pip install pycocotools
问题5:ERROR: Invalid requirement: “'colorama”
解决方法:pip install colorama
问题6:AttributeError: Can’t get attribute ‘SPPF’ on <module ‘models.common’ from ’
解决方法:https://blog.csdn.net/inaner/article/details/121177939
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))
在moudle得到commom.py里修改