AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.75k stars 7.96k forks source link

KITTI Results #4454

Open CuongNguyen218 opened 4 years ago

CuongNguyen218 commented 4 years ago

@AlexeyAB , Hi Alex. Thanks for your amazing code. But I have a trouble when Training your repo with KITTI Dataset. When I use your repo and trained around 50k iter, I get a bad result with car AP detection when test with KITTI Devkit. Details in image below. image

And my result at final iter with your repo below image And chart image of training process below: image I see a gap between the result of car mAP when I use your repo and GaussianYolo repo is large. Notice that I don't use Gaussian Yolo Layer. Result from Gaussian Yolo repo in the image below image Can you explain it for me ? This is my config file yolov3-kitti.txt : And this is the number of box of KITTI dataset in training set and test set: image

AlexeyAB commented 4 years ago

@CuongNguyen218 Hi,

  1. There was a bug in the data augmentation from 26 oct to 4 dec 2019. So you should train it again in this repo.

  2. Also what Darknet-repo and what command do you use to get car_detection AP?

CuongNguyen218 commented 4 years ago

@AlexeyAB , Hi, Thank for your quick reply. Darknet repo what i use to reproduce this result below is Gaussian Yolo Repo ( i used yolo layer not gaussian Yolo Layer). image Gaussian Repo: https://github.com/jwchoi384/Gaussian_YOLOv3 and I used official evaluate code from KITTI dataset webpage without any change: http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=2d

AlexeyAB commented 4 years ago

Darknet repo what i use to reproduce this result below is Gaussian Yolo Repo

Try to use this repo: https://github.com/AlexeyAB/darknet

I just added ./darknet detector valid for KITTI and BDD: https://github.com/AlexeyAB/darknet/commit/aaba21bdd336c77561f6c79cb940ef9b52a2b11b

CuongNguyen218 commented 4 years ago

@AlexeyAB , thank for your support but I think there is a misunderstanding between us. Let me explain:

  1. I trained KITTI dataset with your repo get weight file A. Then, I use weight file A to valid on testset and result of weight A in gaussian repo and get results in image below when test with devkit code. The order is E M H left to right image

I see it is an unreasonable result follow gaussian paper: image

  1. To check problems, I retrained KITTI dataset with Gaussian Yolov3 Repo and get weight file B (it don't have GIOU value in log file and I don't know that GIOU affects to this result when i use your repo). Then, I used weight B to valid on testset and get results in image below with devkit code. image Results and trend seem good. My cmd line is: ./darknet detector valid cfg/datafile cfg/cfgfile weights Maybe i will retry with your newest repo. Thanks
AlexeyAB commented 4 years ago

My cmd line is: ./darknet detector valid cfg/datafile cfg/cfgfile weights Maybe i will retry with your newest repo. Thanks

  1. Yes. You should do ./darknet detector valid on the same repo where did you do ./darknet detector train There are different resize approaches in different frameworks with pros and cons: https://github.com/AlexeyAB/darknet/issues/232#issuecomment-336955485

  2. Also there was a bug 26 oct -> 4 dec in training: https://github.com/AlexeyAB/darknet/issues/4454#issuecomment-562188010

CuongNguyen218 commented 4 years ago

@AlexeyAB , I will retrain tomorrow. Thanks you. One more question, I want to use GIOU with Gaussian Yolo Layer as a metrics instead of IOU ( do not use GIOU loss). How can I do that ?

CuongNguyen218 commented 4 years ago

@AlexeyAB , Hi i want to read about data augment bug. Maybe you prefer wrong comment above?

AlexeyAB commented 4 years ago

I will retrain tomorrow. Thanks you. One more question, I want to use GIOU with Gaussian Yolo Layer as a metrics instead of IOU ( do not use GIOU loss). How can I do that ?

There isn't mAP that is based on GIoU instead of IoU. Try to ask it in GIoU-repository.

Hi i want to read about data augment bug. Maybe you prefer wrong comment above?

Just Bilateral-blurring will be used for 50% of images even if you didn't enable it.

CuongNguyen218 commented 4 years ago

@AlexeyAB , In #3114 inyolo_v3_tiny_pan5 matrix_gaussian_GIoU aa_ae_mixup_new.cfg , I saw you use GIOU for Gaussian Yolo layer. I think something not correct when see NLL loss in Gaussian Yolo Paper because NLL loss in Gaussian Yolo Layer is loss function for bounding box and GIOU also Bounding Box loss. Can you explain it for me ? iou_loss=giou

AlexeyAB commented 4 years ago

@CuongNguyen218

GIoU just replaces NLL loss for b-box. So there will be GIoU-loss for bbox-loss and Gaussian_yolo-loss for Uncertainty.

CuongNguyen218 commented 4 years ago

@AlexeyAB , Hi. I think something wrong with valid image

I retrained KITTI dataset with your new code and your valid code but something when wrong with car class. The trend is Easy > Moderate > Hard but my result what I get from your code is not follow that. I don't know why ?

AlexeyAB commented 4 years ago

@CuongNguyen218

Also you can try to set in your cfg-file

[net]
letter_box=1

Then train usin AlexeyAB repo, and valid by using Jwchoi repo.

CuongNguyen218 commented 4 years ago

@AlexeyAB , Thanks for your support. and i want to find commit of bag of freebie. Can you find it for me?

AlexeyAB commented 4 years ago

Serach commit with MixUp.

or just use

[net]
mixup=1
CuongNguyen218 commented 4 years ago

@AlexeyAB , i saw bag_freebies=1 in #3272 . does it equal to mixup = 1 ?

AlexeyAB commented 4 years ago

Yes.

AlexeyAB commented 4 years ago

But you should know, that mixup=1 improves accuracy only for Classifier. (and the use Classifier pre-trained weights file for Detector).

For training Detector is recommended to use mosaic=1. Use the latest version of Darknet,.

CuongNguyen218 commented 4 years ago

okay, I got it. Thanks you. I want to try it because i see it improve performance of yolov3 in gluoncv +5% on COCO. Paper: https://arxiv.org/pdf/1902.04103.pdf Maybe it included a bag of trick for object detection.

AlexeyAB commented 4 years ago

BoF (Bag of Freebies) includes 5 features - there are implemented 5 of 5 features in this repository, read: https://github.com/AlexeyAB/darknet/issues/3272#issuecomment-497149618

There is implemented mixup=1 that gives +1.5 - +2.0% mAP for Yolov3, but:

mixup=1 for Detector gives only +0.3% mAP@0.5...0.95 on MS COCO

Paper: https://arxiv.org/pdf/1902.04103.pdf image


To get +1.5 - +2.0% mAP you must first train the Classifier with [net] mixup=1 https://github.com/AlexeyAB/darknet/blob/master/cfg/darknet53.cfg and then use this pre-trained weights file for training Detector Yolo with [net] mixup=1 https://github.com/AlexeyAB/darknet/blob/master/cfg/yolov3.cfg then you will get +2% MS COCO


To get another +2.0% you should use: mixup=1, SGDR (cosine lr), random=1, and GPU-processing + CPU-RAM - it takes a lot of time to training.


There are better approaches than MixUP:

CuongNguyen218 commented 4 years ago

@AlexeyAB , I retrained my model with your repo and setting letter_box = 1 in my cfg file, and bad results for car class still appear. This is my result: image

AlexeyAB commented 4 years ago

What width= and height= do you use in both cfg-files? What random= do you use in the last [yolo] layer in both cfg-files?

CuongNguyen218 commented 4 years ago

Hi @AlexeyAB , I set width = height = 512 in both cfg file. random = 1, ignore_thresh = 0.5 in both.

AlexeyAB commented 4 years ago

I retrained my model with your repo and setting letter_box = 1 in my cfg file, and bad results for car class still appear.

Did you set [net] letter_box=1 in cfg, then train with AlexeyAB, then valid with Jwchoi and get Car AP = 59.56%?

Can you attach both cfg-files?

There is also different network resize approaches:

CuongNguyen218 commented 4 years ago

@AlexeyAB

Did you set [net] letter_box=1 in cfg, then train with AlexeyAB, then valid with Jwchoi and get Car AP = 59.56%?

Yes. Here is my both cfg-files? yolov3-kiit-jwchoi.txt yolov3-kitti-AlexeyAB.txt

AlexeyAB commented 4 years ago

Did you train both models with the same batch and subdivisions?

batch=64
subdivisions=16

Try to change these lines: https://github.com/AlexeyAB/darknet/blob/318919e1cbb362aac6cb5c3d9388735f9ab594b6/src/detector.c#L169-L171

To these

            int dim = (rand() % 10 + 10) * 32;
            if (get_current_batch(net)+200 > net->max_batches) dim = 608;
int dim_w = dim;
int dim_h = dim;

recompile and train without letter_box=1

CuongNguyen218 commented 4 years ago

Did you train both models with the same batch and subdivisions?

batch=64
subdivisions=16

Yes, I set both are Batch=64 and sub =16 i will retry this with 10000k iter.

CuongNguyen218 commented 4 years ago

@AlexeyAB , I change these line above and get an error image

Maybe related to this line https://github.com/AlexeyAB/darknet/blob/2a873f34485c75d44a346f92ba7dcf2e2aa57a15/src/detector.c#L83

AlexeyAB commented 4 years ago

Use if (get_current_batch(net) + 200 > net.max_batches) dim = 608; instead of if (get_current_batch(net) + 200 > net->max_batches) dim = 608;

Also removes these lines: https://github.com/AlexeyAB/darknet/blob/318919e1cbb362aac6cb5c3d9388735f9ab594b6/src/detector.c#L173-L177

CuongNguyen218 commented 4 years ago

@AlexeyAB image This is new error. image Here is my change in code. Maybe I miss a '(' right? Sorry i'm not familiar with C

AlexeyAB commented 4 years ago

Use // for commenting instad of #

CuongNguyen218 commented 4 years ago

@AlexeyAB , thank you it work. As I feel, training speed is faster.

CuongNguyen218 commented 4 years ago

@AlexeyAB , I trained my model with 10k iter and finally it works. image Thank you for your support.

err-or commented 4 years ago

Hi, if you are using ./darknet detector valid for kitti, what do you use for eval= in obj,data? If you are using the devkit to evaluate yolo for kitti, can you please tell me how you are using the devkit? Thanks!

AlexeyAB commented 4 years ago

Use eval=kitti in the obj.data file.

Can be: voc, coco, imagenet, kitty, bdd: https://github.com/AlexeyAB/darknet/blob/49bff0e24da36f7c1a2471b12089efb27a0173b1/src/detector.c#L662-L708

err-or commented 4 years ago

Hi Alexey, thank you for your response. I did what you said but I get an error while running ./darknet detector valid where eval = kitti in obj.data. The error is this: image To give you an idea of what I did:

  1. I downloaded the training images of KITTI 2D object detection
  2. I have converted the labels according to yolo
  3. I have taken around 6k images as train.txt
  4. The remaining images are in valid.txt
  5. I trained the model up to 16k iterations

Can you please tell me how can I evaluate the model according to kitti 2D detection benchmark?

AlexeyAB commented 4 years ago

If you can't get Kitti-evalutation, also you can try to use BDD-evalutation methond

python evaluate.py det gt_KITTI_valid_for_bdd_eval_method.json ../results/bdd_results.json

err-or commented 4 years ago

Hi Alexey,

  1. Yes I can successfully detect with my model
  2. The /results/ folder was already there even before running the training
  3. I get the /results/kitti_results/data/ folder when I run ./darknet detector valid with eval = kitti in obj.data but I encounter the error that I mentioned. I only get a single .txt file one of the image file but that .txt file is blank.
  4. This is the command that I used: ./darknet detector valid data/obj.data cfg/yolo-obj.cfg backup/yolo-obj_final.weights
  5. Yes I can successfully run ./darknet detector map ... and this is what I get after running this:

image