"yolov5x.pt is not compatible with models/yolov5x.yaml. Specify --weights '' or specify a --cfg compatible with yolov5x.pt."

Viewed 782

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 Answers

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.

Related