Problem Description:
There was a problem running the yolov5-train.py file:
Attributeerror: cant get attribute sppf on module models.common… (followed by file path)
Solution:
1. Double click to open the common.py file:
2. Add code:
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)) Copy and paste it directly into the common.py file. Tips: Put import warnings on it!
Read More:
- [Solved] YOLO v5 Error: AttributeError: Can‘t get attribute SPPF on module models
- [Solved] yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
- [Solved] AttributeError: module ‘dlib‘ has no attribute ‘get_face_chip‘
- [Solved] YOLOv5 Model training error: TypeError: new(): invalid data type ‘str’
- AttributeError: can‘t set attribute [How to Solve]
- [Solved] AttributeError: ‘Manager‘ object has no attribute ‘get_by_natural_key‘
- [Solved] AttributeError: module ‘distutils‘ has no attribute ‘version‘
- [Solved] AttributeError: module ‘logging‘ has no attribute ‘Handler‘
- [How to Solve]AttributeError: module ‘scipy’ has no attribute ‘io’
- [Solved]AttributeError: module ‘urllib’ has no attribute ‘quote’
- AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘ [How to Solve]
- [Solved] AttributeError: module ‘setuptools._distutils‘ has no attribute ‘version‘
- [Solved] AttributeError: partially initialized module ‘xlwings’ has no attribute ‘App’
- AttributeError: module ‘time‘ has no attribute ‘clock‘ [How to Solve]
- [How to Solve]AttributeError: module ‘scipy’ has no attribute ‘stats’
- [Solved] AttributeError: module ‘selenium.webdriver‘ has no attribute ‘Chrome‘
- [Solved] AttributeError: module ‘PIL.Image‘ has no attribute ‘open‘
- [Solved] AttributeError: module ‘tensorflow‘ has no attribute ‘distributions‘
- [Solved] AttributeError: module ‘pandas‘ has no attribute ‘rolling_count‘
- How to Solve Python AttributeError: ‘module’ object has no attribute ‘xxx’