Solved the error when training my own yolov7 detection model: AssertionError: train: No labels in XXX/XXX/train.cache.

Solved the error when training my own yolov7 detection model: AssertionError: train: No labels in XXX/XXX/train.cache.

Problem Description

When using yolov7 to train the model of your own data set, after the data set is created and processed and the parameters of the train.py file are modified, the error message when running train.py is: AssertionError: train: No labels in VOCdevkit/VOC2007 / train.cache. (VOCdevkit/VOC2007 is the path where I store my own data set)
Insert image description here

Solution

  1. After debugging, it was found that the yolov7 source code is in the def img2label_paths(img_paths): function in the utils/datasets.py file. The default folder for storing data set images is images. You need to change 'images' to 'JPEGImages' (store the data set yourself. folder of the image) , the label position can be obtained based on the image position.
    Insert image description hereInsert image description here

  2. However, when running train.py after the modification in the previous step, the same error will still be reported. This is because the train.py file was run previously and the train.cache file (incomplete) has been generated in the VOCdevkit/VOC2007 folder. It needs to be added below. Delete the train.cache file before running .
    Insert image description here

  3. After the above two operations, re-run the train.py network to start training.

Guess you like

Origin blog.csdn.net/ff_5_5_/article/details/129632374