Training Yolov7

2 min readJul 22, 2022


Prepare the dataset

Prepare in the following format.

Prepare the image and annotation text file with the same name.

For example, prepare a set corresponding to




In the annotation text file, write the following (one line for each object):

Box coordinates are in xywh format normalized to 0 to 1.

Class numbers start at 0.

You can generate annotation files for Yolo using annotation services such as:

Data used for training (train) Data

used for model verification (val)

is generally distributed at a ratio of about 8: 2.


If the dataset was previously trained with yolov5 etc., the .cache file may remain in the labels directory and the following error may occur. In that case, delete the .cache file.

Description of Config file

Create a file that directs the training configuration. Write the following in your .yaml file:

・ Image path

・ Number of classes

・ Array of class names

Is described.

Yolov 7 setup

Pre-trained weights for your model can be downloaded from the official repository.


GPU memory may be insufficient depending on the usage environment such as Colab. In that case, you can learn by reducing the batch size.


There are several types of models depending on their size and accuracy, and each model has a config file in the repository, so
run the pre-trained model and the config file type together.

After training, the result weights and logs are saved in run / exp.


I’m a freelance engineer.
Work consultation
Please feel free to contact us with a brief development description.

I am making an app that uses Core ML and ARKit.
We send machine learning / AR related information.