Effacer les filtres
Effacer les filtres

How to get metrics during yolov4 detector training process and how to solve data overfitting?

50 vues (au cours des 30 derniers jours)
xinru
xinru le 12 Août 2024 à 8:09
Modifié(e) : Gayathri le 16 Août 2024 à 3:32
When i use yolov4 detector to achieve a single-class target detection tasks, i can only get training-loss and validation-loss after training process.I have tried to use "options" to get metrics ,but it made Errow, wrong use " nnet.cnn.TrainingOptions/validateDataFormatsAndMetricsAreEmpty ,trainYOLOv4ObjectDetector can't support 'Metrics' training options",my code and errow are below:
Then how to get metrics during yolov4 detector training process?
----------------------------------------------------------------------------------------------
Meanwhile, after fine-tuning options parameters,I have trained the detector many times, the final training loss maintains 0.1 while validation loss can only get 2.0, how can I avoid this data overfitting?I've tried many methods , if you can give me some suggestions , it will be very helpful .

Réponses (1)

Gayathri
Gayathri le 13 Août 2024 à 8:55
Hi @xinru,
As the error suggests, its not possible to pass “metrics” option in “trainingOptions” for “YOLOv4ObjectDetector”. Instead I can suggest you to use “evaluateObjectDetection” function to obtain the metrics Precision, Recall and Accuracy. This function also provides the confusion matrix through which all metrics could be calculated.
detectionresults=detect(trainedDetector,imds)
%%%%%%%%%%%%%Calculate metrics
metrics = evaluateObjectDetection(detectionresults, blds)
%%To obtain confusion matrix
cm=metrics.ConfusionMatrix
%%To obtain Precision,recall and AP
recall = metrics.ClassMetrics{"vehicle","Recall"}
precision = metrics.ClassMetrics{"vehicle","Precision"}
ap = metrics.ClassMetrics{"vehicle","AP"}
For additional information and example about “evaluateObjectDetection” please refer to https://www.mathworks.com/help/vision/ref/evaluateobjectdetection.html
To avoid overfitting, you can try training with more data. That would help mitigate overfitting.
Hope you find this information helpful.
  2 commentaires
xinru
xinru le 14 Août 2024 à 16:29
Very thanks for your answer! However I think your code should use testdata to test detector precision instead of training data ,which cannot reflect real training situations.I've tried augmented data to increase amount of data, however the training loss is 0.01 and validation loss maintains 1.0,still overfitting.
Gayathri
Gayathri le 16 Août 2024 à 3:32
Modifié(e) : Gayathri le 16 Août 2024 à 3:32
Hi, yes we should be using test data. The code provided was just for illustrating the function usage. For overfitting, you can also try reducing the learning rate from 0.01 to 0.001 or lesser, if you have not tried this earlier. A learning rate that is high might cause the model to converge too quickly on the training data, leading to overfitting.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by