ultralytics / yolov5

YOLOv5 πŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.37k stars 16.26k forks source link

Training with issues at the end -- 'DeformConv2d' object has no attribute 'in_channels' #7303

Closed hubery1619 closed 2 years ago

hubery1619 commented 2 years ago

Search before asking

Question

I add the deformable convolution network in yolov5. At the end of the training, it shows as follows:

Optimizer stripped from runs/train/modified_yolov5/weights/last.pt, 98.0MB Optimizer stripped from runs/train/modified_yolov5/weights/best.pt, 98.0MB

Validating runs/train/modified_yolov5/weights/best.pt... Fusing layers... Traceback (most recent call last): File "train.py", line 630, in main(opt) File "train.py", line 527, in main train(opt.hyp, opt, device, callbacks) File "train.py", line 425, in train model=attempt_load(f, device).half(), File "/home/ models/experimental.py", line 98, in attempt_load model.append(ckpt['ema' if ckpt.get('ema') else 'model'].float().fuse().eval()) # FP32 model File "/home/models/yolo.py", line 351, in fuse m.conv = fuse_conv_and_bn(m.conv, m.bn) # update conv File "/home/ /utils/torch_utils.py", line 200, in fuse_conv_and_bn fusedconv = nn.Conv2d(conv.in_channels, File "/home/yolov5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1177, in getattr raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'DeformConv2d' object has no attribute 'in_channels'

Additional

It could train for all 300 epochs. But at the end of the training, it raises issues.

github-actions[bot] commented 2 years ago

πŸ‘‹ Hello @hubery1619, thank you for your interest in YOLOv5 πŸš€! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a πŸ› Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 2 years ago

@hubery1619 it seems it ran into a problem during the model.fuse() operation. Fusing combines BN with Conv. You can either eliminate fusing or fix fusing. The code is here: https://github.com/ultralytics/yolov5/blob/d257c75c848ccab4d9195300a61195cf0dfef1bf/models/yolo.py#L225-L234

github-actions[bot] commented 2 years ago

πŸ‘‹ Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 πŸš€ resources:

Access additional Ultralytics ⚑ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐!