onehahaha756 / yolov5_rotation

GNU General Public License v3.0
106 stars 20 forks source link

AttributeError: 'Focus' object has no attribute 'contract' #19

Open tinly00 opened 2 years ago

tinly00 commented 2 years ago

my env: windows 10 python3.9 cuda 10.2 torch 1.9.0 torchvision 0.10.0

when i run the test.py i got an error as following:

C:\Users\Administrator\anaconda3\envs\yolov5_py39cu102forrotation\python.exe "C:\Program Files\JetBrains\PyCharm 2021.1.3\plugins\python\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 63646 --file E:/DL/yolov5_rotation_master/yolov5_rotation_master/detect.py
Connected to pydev debugger (build 211.7628.24)
Namespace(weights='yolov5s.pt', source='data/images', imgsz=640, conf_thres=0.25, iou_thres=0.45, max_det=1000, device='', view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, update=False, project='runs/detect', name='exp', exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False)
YOLOv5  2022-3-14 torch 1.9.0+cu102 CUDA:0 (GeForce GTX 1660, 6144.0MB)

Fusing layers... 
Model Summary: 283 layers, 7276605 parameters, 0 gradients
Traceback (most recent call last):
  File "C:\Users\Administrator\anaconda3\envs\yolov5_py39cu102forrotation\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "E:/DL/yolov5_rotation_master/yolov5_rotation_master/detect.py", line 80, in detect
    model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters())))  # run once
  File "C:\Users\Administrator\anaconda3\envs\yolov5_py39cu102forrotation\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "E:\DL\yolov5_rotation_master\yolov5_rotation_master\models\yolo.py", line 126, in forward
    return self.forward_once(x, profile)  # single-scale inference, train
  File "E:\DL\yolov5_rotation_master\yolov5_rotation_master\models\yolo.py", line 157, in forward_once
    x = m(x)  # run
  File "C:\Users\Administrator\anaconda3\envs\yolov5_py39cu102forrotation\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "E:\DL\yolov5_rotation_master\yolov5_rotation_master\models\common.py", line 172, in forward
    return self.conv(self.contract(x))
  File "C:\Users\Administrator\anaconda3\envs\yolov5_py39cu102forrotation\lib\site-packages\torch\nn\modules\module.py", line 1130, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Focus' object has no attribute 'contract'

Process finished with exit code -1

the yolov5 latest version is 6.1 without 'Focus' object and before this version yolov5 has 'Focus', is this will cause this error?

anyone has the same question with me ? how can i handle this error? thank you!

@onehahaha

Tony-Lann commented 8 months ago

How do you solve this?