YOLOv8 for training, verification and reasoning records

This article records the detailed process of how to use yolov8 for training, verification and reasoning.

1. Code download and environment configuration

Directly refer to my previous article: Yolov8 reproduction and simple test records

2. Data set preparation

First of all, let me declare that yolov8's requirements for data sets can only be in voc format or yolo format.

Here is a VOC format dataset for small target cigarette butt detection : small target cigarette butt detection VOC format dataset and data.yaml configuration file

1. Use of VOC annotation format data set

(1) Store the pictures in the dataset\VOCdevkit\JPEGImages directory under the project (if not available, create a new one yourself). The picture suffixes need to be consistent, such as jpg or png , etc. Mixed picture suffix formats are not supported, such as some Some are jpg and some are png.

(2) Store the XML file in the VOC annotation format in the dataset\VOCdevkit\Annotations directory.

(3) Open xml2txt.py . In this file, it will convert the XML format annotation file in Annotations to the yolo format annotation file in txt. Among them, the postfix parameter in xml2txt.py is the picture suffix of JPEGImages, which can be changed to the picture suffix, and the default is jpg. For example, my pictures are all with png suffixes, so I need to modify postfix to png. After the modification is complete, right-click Run to run xml2txt.py.

When running this file, the output information will output the category of your dataset.

(4) Modify the parameters in the data.yaml file. You need to copy the category list output after running the xml2txt.py file to names in data.yaml, and change nc to your category number, which is the number of categories in names.

(5) Run split_data.py , this file is divided into training, verification, and test sets. It supports modifying the val_size verification set ratio and test_size test set ratio, you can find the corresponding parameters in split_data.py to modify, and then the postfix parameter is also the suffix format of your image data set, the default is jpg, if your image suffix does not end with jpg If so, you need to modify this parameter.

The split_data.py file will not display anything when it is running. How to determine whether it is running is to see if there are two folders, images and labels, in the dataset folder.

2. Use of YOLO annotation format dataset

(1) Store the pictures in dataset\VOCdevkit\JPEGImages . The picture suffixes need to be consistent, such as jpg or png , etc. Mixed picture suffix formats are not supported, such as some are jpg and some are png.

(2) Store the TXT file in the YOLO annotation format in dataset\VOCdevkit\txt .

(3) Run split_data.py , this file is divided into training, verification, and test sets. Among them, it is supported to modify the proportion of val_size verification set and test_size test set. You can find the corresponding parameters in split_data.py to modify, and then the postfix parameter is also the suffix format of your image data setÿ

Guess you like

Origin blog.csdn.net/m0_63604019/article/details/130091686