yolov5 trains its own data for watermark detection
Article directory
foreword
Grasp yolov5 from the overall process to use its own data for target detection to prevent students from stepping on the pit
1. Download yolov5 source code
Download the source code from the yolov5 official git address https://github.com/ultralytics/yolov5, and determine the small version, so that there will be no version inconsistency in training and deploying the model.
Here I choose the v6.0 version and deploy it relatively stable
2. Modify the configuration information of your own yolov5
1. Modify the configuration file in the data directory
Modify the VOC.yaml file.
This is an official sample file that tells you what the input model data should look like. The
above picture is our modified configuration file.
What needs to be modified is nc to your target detection category number
and names . Create your own categories
train and val are the data directories of your own training set and test set, and
delete the other parts.
The data input into the model should be processed into the following form:
images is the data of pictures
labels is the label information data,
and each txt file contains the category and coordinate position information of the detection target
2. Modify the models configuration file
It depends on which model you are using, and you can modify the configuration file of which model you use.
I used the yolov5s model this time, so modify the yolov5s configuration file
to modify the nc value and change it to the total number of categories of your target detection.
After the modification, the configuration part is completed, and then the train.py function is modified.
3. Modify the train function
What needs to be modified is this part.
Wieghts, cfg, data, epoch, and batchsize
are pre-training weight files, model configuration information, data configuration information, training rounds, and batch data respectively.
Summarize
The above is the training process of using your own data for the yolov5 target detection model