Summary of common errors in YOLOv5

Table of contents

1. Error when installing pycocotools

2.Cant get attribute SPPF on module models.common

2.1 Reasons

2.2 Solutions

3.[WinError 1455] The page file is too small and the operation cannot be completed.

3.1 Reasons

3.2 Solution

4.AssertionError: Image Not Found D:\PycharmProjects\yolov5-hat\VOCdevkit\images\train\000000 

4.1 Reasons

4.2 Solutions

5.AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘  

5.1 Reasons

5.2 Solution

 6- You can see that although there are result pictures, the recognition results are not framed.

reason

solution


1. Error when installing pycocotools

 Installation under windows

pip install pycocotools-windows

2.Cant get attribute SPPF on module models.common

The error reported when executing train.py must be a problem in common.py of models according to the prompts.

2.1 Reasons

YOLOv6 has updated the SPPF class in common.py but it is not in the v5 version. I am also confused about this reason. Why does it have anything to do with v6?

2.2 Solutions

As shown in the reason, find the SPPF class directly from the v6 version and add it to common.py. You can directly copy the following code into common:
Pay attention to importing the warnings library. The warnings are placed at the beginning of the 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))

3.[WinError 1455] The page file is too small and the operation cannot be completed.

3.1 Reasons

 Insufficient virtual memory.

3.2 Solution

In line 81 of datasets under the utils file, change num_workers=nw to =0:

4.AssertionError: Image Not Found D:\PycharmProjects\yolov5-hat\VOCdevkit\images\train\000000 

4.1 Reasons

If you are downloading someone else's data set for training, if this error is reported when other paths are configured correctly, it means that train.py reads the previous cache file when reading the data set.

4.2 Solutions

Delete the two cache files under the labels folder of the data set and retrain.

5.AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘  

5.1 Reasons

The version of torch is too high causing incompatibility.

5.2 Solution

Click on ~\torch\nn\modules\upsampling.py from above and delete the last parameter in the return function in forword.

 6- You can see that although there are result pictures, the recognition results are not framed.

The results of the training images are normally placed in the following file, but when I open it, I find that no recognition box is drawn for us as expected.

reason

The detect.py detection code does not set the picture frame.

solution

Add cudnn.benchmark = True around line 53 of detect.py. I added comments to line 58 here.

 The actual logic is that webcam represents the situation where batchsize>=1. If there is only one picture to detect, no frame will be drawn by default. After adding inference, the effect is as follows:

Guess you like

Origin blog.csdn.net/weixin_45303602/article/details/132835629