hunglc007 / tensorflow-yolov4-tflite

YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
https://github.com/hunglc007/tensorflow-yolov4-tflite
MIT License
2.23k stars 1.24k forks source link

Predict confidence so low that Bboxes predict result are filtered out #358

Open Julius-ZCJ opened 3 years ago

Julius-ZCJ commented 3 years ago

use model: yolov4 When I use Yolov4 train model with my own data, I get the model. But when I predict, I found predict result is 0, I was confused, So, I check where has wrong, and I found predict confidence is very small, like this: [[0.06150062] [0.05631879] [0.05217019]] And this result will lead to predict bboxes all filtered out.

Try to fix: When I check the code, I found generate label need use anchor and gt_bboxes cal iou, and I found iou is very small, So I guess maybe this anchors lead to this problem, I use k-means cal anchors and change this set, and retrain model, but get the same result.

I use faster rcnn I can get correct result, I want compare yolov4 with faster rcnn, which model is better in our data. Anyone can tall me how I can get correct result.

I suspect yolov4 is not suit my data, but I don't know how to proof it.


this is part of train loss: => STEP 623/ 645 lr: 0.000027 giou_loss: 2.52 conf_loss: 1.43 prob_loss: 2.62 total_loss: 6.57 => STEP 624/ 645 lr: 0.000024 giou_loss: 4.47 conf_loss: 6.56 prob_loss: 2.00 total_loss: 13.02 => STEP 625/ 645 lr: 0.000022 giou_loss: 2.26 conf_loss: 1.82 prob_loss: 0.84 total_loss: 4.91 => STEP 626/ 645 lr: 0.000020 giou_loss: 1.95 conf_loss: 1.10 prob_loss: 1.26 total_loss: 4.31 => STEP 627/ 645 lr: 0.000018 giou_loss: 1.85 conf_loss: 3.20 prob_loss: 0.57 total_loss: 5.62 => STEP 628/ 645 lr: 0.000016 giou_loss: 1.12 conf_loss: 1.02 prob_loss: 0.14 total_loss: 2.28 => STEP 629/ 645 lr: 0.000015 giou_loss: 1.13 conf_loss: 1.37 prob_loss: 0.16 total_loss: 2.66 => STEP 630/ 645 lr: 0.000013 giou_loss: 3.03 conf_loss: 4.35 prob_loss: 0.43 total_loss: 7.81 => STEP 631/ 645 lr: 0.000011 giou_loss: 3.39 conf_loss: 2.66 prob_loss: 1.16 total_loss: 7.21 => STEP 632/ 645 lr: 0.000010 giou_loss: 1.18 conf_loss: 1.19 prob_loss: 0.12 total_loss: 2.50 => STEP 633/ 645 lr: 0.000009 giou_loss: 1.74 conf_loss: 2.74 prob_loss: 1.24 total_loss: 5.73 => STEP 634/ 645 lr: 0.000007 giou_loss: 2.88 conf_loss: 2.66 prob_loss: 0.33 total_loss: 5.87 => STEP 635/ 645 lr: 0.000006 giou_loss: 1.57 conf_loss: 2.18 prob_loss: 0.64 total_loss: 4.39 => STEP 636/ 645 lr: 0.000005 giou_loss: 1.31 conf_loss: 1.94 prob_loss: 0.51 total_loss: 3.75 => STEP 637/ 645 lr: 0.000004 giou_loss: 2.03 conf_loss: 2.92 prob_loss: 4.37 total_loss: 9.31 => STEP 638/ 645 lr: 0.000004 giou_loss: 1.10 conf_loss: 1.95 prob_loss: 2.95 total_loss: 6.00 => STEP 639/ 645 lr: 0.000003 giou_loss: 1.62 conf_loss: 2.35 prob_loss: 0.40 total_loss: 4.38 => STEP 640/ 645 lr: 0.000002 giou_loss: 2.35 conf_loss: 1.44 prob_loss: 1.22 total_loss: 5.01 => STEP 641/ 645 lr: 0.000002 giou_loss: 0.86 conf_loss: 2.05 prob_loss: 3.07 total_loss: 5.98 => STEP 642/ 645 lr: 0.000001 giou_loss: 1.42 conf_loss: 3.04 prob_loss: 1.16 total_loss: 5.61 => STEP 643/ 645 lr: 0.000001 giou_loss: 3.12 conf_loss: 2.35 prob_loss: 0.69 total_loss: 6.16 => STEP 644/ 645 lr: 0.000001 giou_loss: 1.23 conf_loss: 1.10 prob_loss: 0.35 total_loss: 2.68 => STEP 645/ 645 lr: 0.000001 giou_loss: 1.26 conf_loss: 1.51 prob_loss: 0.35 total_loss: 3.12

thegamercoder19 commented 3 years ago

Hello, I think as you said, problems can be in anchors. Anchors may be to small or too big for your dataset bounding boxes so IoU became small. You can generate new anchors using KMeans. I am using https://github.com/qqwweee/keras-yolo3/blob/master/kmeans.py for this. But, you need to give little changes to this code such as change path to saving, path to annotations and cluster number. Cluster number should be 18. Although, problems may be not in anchors, but in your dataset. Check your dataset, please. Write if that worked.