yolov5报错:AttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘

Using CUDA device0 _CudaDeviceProperties(name='GeForce RTX 2080 Super with Max-Q Design', total_memory=8192MB)

Fusing layers... 
Model Summary: 140 layers, 7.45958e+06 parameters, 0 gradients
Traceback (most recent call last):
  File "C:/Users/liqiang/Desktop/yolov5_pytorch/YOLOV5/yolov5-master/detect.py", line 170, in
    detect()
  File "C:/Users/liqiang/Desktop/yolov5_pytorch/YOLOV5/yolov5-master/detect.py", line 63, in detect
    _ = model(img.half() if half else img) if device.type != 'cpu' else None  # run once
  File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\liqiang\Desktop\yolov5_pytorch\YOLOV5\yolov5-master\models\yolo.py", line 115, in forward
    return self.forward_once(x, profile)  # single-scale inference, train
  File "C:\Users\liqiang\Desktop\yolov5_pytorch\YOLOV5\yolov5-master\models\yolo.py", line 135, in forward_once
    x = m(x)  # run
  File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\liqiang\Desktop\yolov5_pytorch\YOLOV5\yolov5-master\models\common.py", line 89, in forward
    return self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))
  File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\liqiang\Desktop\yolov5_pytorch\YOLOV5\yolov5-master\models\common.py", line 33, in fuseforward
    return self.act(self.conv(x))
  File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\activation.py", line 474, in forward
    return F.hardswish(input, self.inplace)
  File "D:\programfiles\miniconda\envs\py38torch_gpu\lib\site-packages\torch\nn\modules\module.py", line 1130, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Hardswish' object has no attribute 'inplace'

Process finished with exit code 1

yolov5报错:AttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘_第1张图片

 定位到报错的哪一行代码:

yolov5报错:AttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘_第2张图片

 修改方法:

yolov5报错:AttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘_第3张图片

 在F.hardswish中删除inplace即可。

yolov5报错:AttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘_第4张图片

 

你可能感兴趣的:(计算机视觉,计算机视觉,目标检测,python)