News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

2024-11(7)

yolov7模型训练结果分析以及如何评估yolov7模型训练的效果

posted on 2023-05-21 18:17     read(198)     comment(0)     like(13)     collect(4)


Recently, I have just trained the yolov7 model, but it is not enough to train only one brain. You need to know how many epochs to train and which indicators to use to check the effect of the training. Now let me summarize the experience of the past few days.

This experiment takes person as an example, training 100epoch, 60epoch, 50epoch respectively

Training experience: Since I don't know how many epochs are better for training, I set it to 100 for now. (In the past few days, the conclusions drawn from the data inquiries are generally more than 50)

1. File analysis about yolov7 training results

1. weights

That is, the trained model, generally use best.pt for reasoning

 Including best.pt and last.pt, and the default 25epoch to save the model once, and save the last 5 epoch model

2. confusion_matrix.png

confusion matrix

The confusion matrix summarizes the records in the data set in the form of a matrix according to the two criteria of the real category and the category predicted by the classification model . The rows of the matrix represent the true values, and the columns of the matrix represent the predicted values.

TP (True Positive): Predicting the positive class as the number of positive classes is the correct prediction, the real is 0, and the prediction is also 0

FN (False Negative): Predicting the positive class as a negative class is a wrong prediction, the real is 0, and the prediction is 1

FP (False Positive): Predicting the negative class as the positive class number is wrong prediction, the real is 1, and the prediction is 0

TN (True Negative): The negative class is predicted as the number of negative classes, that is, the correct prediction, the real is 1, and the prediction is also 1

How to calculate precision and recall

Accuracy rate Precision=TP / (TP+FP), among all the results of the prediction is Positive, the proportion of the correct prediction

Recall rate recall=TP / (TP+FN), among all the results whose true value is Positive, predict the correct proportion

 3. F1_curve.png

F1 score, which is defined as the harmonic mean of precision and recall

Some machine learning competitions with multi-category problems often use F1-score as the final evaluation method. It is the harmonic mean of precision and recall , with a maximum of 1 and a minimum of 0.

The value of F1-Score is from 0 to 1, 1 is the best and 0 is the worst.

 This is the F1_curve obtained by 100epoch, indicating that a relatively good F1 score is obtained within the confidence range of 0.4-0.6

Four, hyp.yaml and opt.yaml

Hyperparameters during training and parameters in the middle of train.py

5. P_curve.png

Relationship diagram of precision and confidence

 6. PR_curve.png

P in the PR curve represents precision (precision rate), and R represents recall (recall rate), which represents the relationship between precision rate and recall rate. In general, recall is set to the abscissa, and precision is set to Y-axis. The area enclosed under the PR curve is AP, and the average value of AP of all categories is Map.

If one of the curves A in the PR diagram completely covers the curve B of another learner, it can be asserted that the performance of A is better than B. When A and B cross, the comparison can be made according to the size of the area under the curve. The general training results mainly observe the fluctuation of precision and recall rate (if the fluctuation is not too large, the training effect is better)

Precision and Recall are often a pair of contradictory performance metrics; and the higher the value of one, the lower the other;
increasing Precision <==> increases the threshold of the positive example of the binary classifier prediction <==> to make the positive prediction of the binary classifier The example is as real as possible;
increase the Recall <==> to reduce the threshold of the two classifiers to predict positive examples <== > so that the two classifiers can select the real positive examples as much as possible


7. R_curve.png

The relationship between recall rate recall and confidence confidence

 Eight, results.png

Box: Box is estimated to be the mean value of the GIoU loss function, and the smaller the box is, the more
accurate it is; Objectness: It is estimated to be the mean value of target detection loss, and the smaller the target detection is
, the more accurate it is; Classification: It is estimated to be the mean value of classification loss, and the smaller the box, the more accurate the classification. One class is therefore 0;
Precision: precision (find the right positive class/all found positive classes);

Recall: The true positive accuracy rate, that is, how many positive samples have been found out (how many have been recalled).

From the perspective of real results, Recall describes how many real positive examples in the test set are selected by the binary classifier, that is, how many real positive examples are recalled by the binary classifier.

val BOX: Validation set bounding box loss

val Objectness: Validation set target detection loss mean

val classification: the mean value of the validation set classification loss, this experiment is a category so it is 0

mAP is the area enclosed by Precision and Recall as two-axis plotting, m means average, the number after @ means the threshold for judging iou as a positive or negative sample, @0.5:0.95 means the threshold is 0.5:0.05:0.95 and the average is taken .

mAP@.5:.95 (mAP@[.5:.95])
means different IoU thresholds (from 0.5 to 0.95, step size 0.05) (0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95) on average mAP.

mAP@.5: Indicates the average mAP with a threshold greater than 0.5

The general training results mainly observe the fluctuation of precision and recall rate (if the fluctuation is not too large, the training effect is better)
and then observe mAP@0.5 & mAP@0.5:0.95 to evaluate the training results.

Nine, results.txt

 The respective meanings are training times, GPU consumption, training set bounding box loss, training set target detection loss, training set classification loss, training set total loss, targets target, input image size, Precision, Recall, mAP@.5, mAP@ .5:.95, validation set bounding box loss, validation set object detection loss, validation machine classification loss

10. train_batchx

The batch_size I set is 8, so I read 8 pictures at a time

 Eleven, test_batchx_labels

The actual labels for the first round of the validation set

12. Run tensorboard

  1. activate yolov7(自己所配的环境名称)
  2. tensorboard --logdir=训练结果所在的文件夹

2. Analyze the training effect of the model

Next, I will show the visual training results of tensorboard of 100epoch, 60epoch and 50epoch respectively

100epoch

Loss

AP value

60 epoch

Loss

AP value

50epoch

Loss

AP value

 Analysis: Judging from the Loss of 100epoch, the loss value from 50-60epoch is maintained within a certain range, so we can reduce the training epoch, and then set the epoch to 60 to continue training. Compared with the AP value of 100epoch, which is 86.8, the AP of 60epoch The value was 87.7 and increased by 0.9, but it was found that the target detection loss of val increased after 50 epoch, so we set the epoch to 50 again for training, and found that the AP value increased by 0.1.

Summary: So to check the effect of yolov7 model training, you need to combine the values ​​of the four loss functions. First, set more epoch times, then use the loss function to reduce or increase the number of training rounds, and then check whether the AP value is different. Increase.

Finally, increase the FPS value of the calculation model training, set the corresponding parameters and run test.py

operation result

 FPS=1000/(4.3+0.6+5.0)=101



Category of website: technical article > Blog

Author:kkkkkkkkkkdsdsd

link:http://www.pythonblackhole.com/blog/article/25344/028cf408707fd27b0d6f/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

13 0
collect article
collected

Comment content: (supports up to 255 characters)