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

5 visualizaciones (últimos 30 días)
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 .

Respuesta aceptada

Gayathri
Gayathri el 13 de Ag. de 2024
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 comentarios
xinru
xinru el 14 de Ag. de 2024
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 el 16 de Ag. de 2024
Editada: Gayathri el 16 de Ag. de 2024
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by