How to get metrics during yolov4 detector training process and how to solve data overfitting?
조회 수: 5 (최근 30일)
이전 댓글 표시
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 .
댓글 수: 0
채택된 답변
Gayathri
2024년 8월 13일
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
Gayathri
2024년 8월 16일
편집: Gayathri
2024년 8월 16일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!