Yolov5: Issues when training custom dataset

Created on 28 Nov 2020  ·  8Comments  ·  Source: ultralytics/yolov5

❔Getting TypeError: create_dataloader() got an unexpected keyword argument 'image_weights' when train the datasets.

This was working for me until Thursday and when I tried it try to train my dataset using the same code, I get this error. I am using google colab to train my model.

Optimizer groups: 62 .bias, 70 conv.weight, 59 other
Traceback (most recent call last):
File "train.py", line 492, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 186, in train
image_weights=opt.image_weights)
TypeError: create_dataloader() got an unexpected keyword argument 'image_weights'
CPU times: user 27.2 ms, sys: 7.34 ms, total: 34.6 ms
Wall time: 7.95 s

[Note: New to Yolo]

question

Most helpful comment

@MLcodie @asal97 Here's an example YOLOv5 notebook that incorporates @kchandawat's suggested edit.

All 8 comments

Hello @MLcodie, 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://www.ultralytics.com or email Glenn Jocher at glenn.[email protected].

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

I have the same issue. Please give me a solution as soon as possible.

@MLcodie @Choikyungho9 this issue seems to lack the minimum requirements for a proper response, or is insufficiently detailed for us to help you. Please note that most technical problems are due to:

  • Your modified or out-of-date code. If your issue is not reproducible in a new git clone version of this repo we can not debug it. Before going further run this code and verify your issue persists:
$ git clone https://github.com/ultralytics/yolov5 yolov5_new  # clone latest
$ cd yolov5_new
$ python detect.py  # verify detection

# CODE TO REPRODUCE YOUR ISSUE HERE
  • Your custom data. If your issue is not reproducible in one of our 3 common datasets (COCO, COCO128, or VOC) we can not debug it. Visit our Custom Training Tutorial for guidelines on training your custom data. Examine train_batch0.jpg and test_batch0.jpg for a sanity check of your labels and images.

  • Your environment. If your issue is not reproducible in one of the verified environments below we can not debug it. If you are running YOLOv5 locally, verify your environment meets all of the requirements.txt dependencies specified below. If in doubt, download Python 3.8.0 from https://www.python.org/, create a new venv, and then install requirements.

If none of these apply to you, we suggest you close this issue and raise a new one using the Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you!

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.6. To install run:

$ pip install -r requirements.txt

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 passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.

I have the same problem i've been working with the same colab notebook for the past few weeks in yolov5.
but somehow today i got this error :

Transferred 794/802 items from yolov5x.pt
Optimizer groups: 134 .bias, 142 conv.weight, 131 other
Traceback (most recent call last):
File "train.py", line 492, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 186, in train
image_weights=opt.image_weights)
TypeError: create_dataloader() got an unexpected keyword argument 'image_weights'
CPU times: user 73.4 ms, sys: 28.9 ms, total: 102 ms
Wall time: 17 s

while running this code for training :
!python train.py --img 416 --batch 40 --epochs 1000 --data '../data.yaml' --cfg /content/yolov5/models/yolov5x.yaml --weights yolov5x.pt --name yolov5x_results --cache

@asal97 this is due to your modified or out of date code. I'm running Colab trainings right now without issue.

  • Your modified or out-of-date code. If your issue is not reproducible in a new git clone version of this repo we can not debug it. Before going further run this code and verify your issue persists:
$ git clone https://github.com/ultralytics/yolov5 yolov5_new  # clone latest
$ cd yolov5_new
$ python detect.py  # verify detection

# CODE TO REPRODUCE YOUR ISSUE HERE

@MLcodie @Choikyungho9 @asal97 had the same issue, I resolved this by going to yolov5/train.py
line number 183
remove the argument image_weights=opt.image_weights
in dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, hyp=hyp, augment=True, cache=opt.cache_images, rect=opt.rect, rank=rank, world_size=opt.world_size, workers=opt.workers, image_weights=opt.image_weights)

@kchandawat your code is modified or out of date.

  • Your modified or out-of-date code. If your issue is not reproducible in a new git clone version of this repo we can not debug it. Before going further run this code and verify your issue persists:
$ git clone https://github.com/ultralytics/yolov5 yolov5_new  # clone latest
$ cd yolov5_new
$ python detect.py  # verify detection

# CODE TO REPRODUCE YOUR ISSUE HERE

@MLcodie @asal97 Here's an example YOLOv5 notebook that incorporates @kchandawat's suggested edit.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hktxt picture hktxt  ·  3Comments

krishnam3065 picture krishnam3065  ·  4Comments

cswwp picture cswwp  ·  4Comments

dereyly picture dereyly  ·  4Comments

Alex-afka picture Alex-afka  ·  3Comments