运行yolov5下面Tags5的代码出现问题:
AttributeError: Cant get attribute SPPF on module models.common from e:\pyWorkSpace\yolov5-5.0\models\common.py
遇到这个问题提之后我在百度查了很久,都没找到答案。
最后我在某个地方的评论区找到了某个大佬的回复,最终得到解决方案,特此公布给遇到同样问题的人。
我这边运行的是yolov5下面Tags5的代码,出现了这个报错:
AttributeError: Cant get attribute SPPF on module models.common from e:\pyWorkSpace\yolov5-5.0\models\common.py
解决方案是:去Tags6里面的model/common.py里面去找到这个SPPF的类,把它拷过来到你这个Tags5的model/common.py里面,这样你的代码就也有这个类了,还要引入一个warnings包就行了!
有的同学找不到SPPF这个类,那我现在直接粘贴在这里,你们只需要复制到你们的common.py里面即可,记得把import 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 = Co