2

I want to detect 9 objects all of which are clothes. So I wanted to use yolov5. I wanted to train using the pretrained yolov5x.pt weights. I changed the number of categories in the yolov5x.yaml and clothing_data.yaml to 9. When I try to train the custom dataset by the following :

!python train.py --img 640 --batch 4 --epochs 100 --data ./data/clothing.yaml --cfg models/yolov5x.yaml --weights yolov5x.pt --name yolov5x_clothing --cache

It shows the error.

KeyError: 'model.18.conv.weight'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "train.py", line 404, in <module>
    train(hyp)
  File "train.py", line 122, in train
    raise KeyError(s) from e
KeyError: "yolov5x.pt is not compatible with models/yolov5x.yaml. Specify --weights '' or specify a --cfg compatible with yolov5x.pt."

I don't know what to do here. I cloned the repo of yolov5 using

!git clone https://github.com/ultralytics/yolov5
%cd yolov5
!git checkout ec72eea62bf5bb86b0272f2e65e413957533507f

Is there something I am missing here? Please let me know. Thanks in advance.

  • 1
    Did you see [this](https://github.com/ultralytics/yolov5/issues/222) issue? Maybe you need to delete your current pretrained model to download a newest version? – cbolwerk Dec 17 '20 at 08:22
  • Thanks @cbolwerk ..I was using the weights which were downloaded along with the repo. It was somehow not working. Then I used the current release of the weights which finally worked. I guess they didn't update them. – Sandipan Majhi Dec 18 '20 at 07:19

1 Answers1

0

I solved it after downloading the current releases of weights mentioned in the link : YOLO V5 current releases

In my case the weights in the repo was not working somehow. This definitely solved it.