-1

So this is my error, I am using the OID dataset for training using the YOLOV5 model. As a reference, I'm using this article: https://blog.paperspace.com/train-yolov5-custom-data/. I am getting stuck at the training part, please help.

 [Epoch   gpu_mem       box       obj       cls    labels  img_size
  0% 0/664 \[00:00<?, ?it/s\]
Traceback (most recent call last):

  File "train.py", line 667, in <module>
    main(opt)
  File "train.py", line 562, in main
    train(opt.hyp, opt, device, callbacks)
  File "train.py", line 323, in train
    for i, (imgs, targets, paths, _) in pbar:  

  File "/usr/local/lib/python3.7/dist-packages/tqdm/std.py", line 1195, in __iter__
    for obj in iterable:
  File "/content/yolov5/utils/datasets.py", line 160, in __iter__
    yield next(self.iterator)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 530, in __next__
    data = self._next_data()
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1224, in _next_data
    return self._process_data(data)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1250, in _process_data
    data.reraise()
  File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 457, in reraise
    raise exception
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
    data = fetcher.fetch(index)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = \[self.dataset\[idx\] for idx in possibly_batched_index\]
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = \[self.dataset\[idx\] for idx in possibly_batched_index\]
  File "/content/yolov5/utils/datasets.py", line 589, in __getitem__
    img, labels = self.load_mosaic(index)
  File "/content/yolov5/utils/datasets.py", line 725, in load_mosaic
    img4, labels4, segments4 = copy_paste(img4, labels4, segments4, p=self.hyp\['copy_paste'\])
KeyError: 'copy_paste'][1]

2 Answers2

1

I get this problem and get resolved by add this line in data/hyp.scratch.yaml file.

copy_paste: 0.0 # segment copy-paste (probability)

Hope this solved for you.

Marcelo
  • 11
  • 1
0

I see that you're using an old version of yolov5. Kindly update your code by git pull from main repo or download it as zip file.

If this does not solve your problem, kindly provide more info like your train command and your use case.

Vijay P
  • 43
  • 1
  • 4