mlpack / models

models built with mlpack
https://models.mlpack.org/docs
BSD 3-Clause "New" or "Revised" License
35 stars 41 forks source link

Add YOLO PreProcessor #25

Closed kartikdutt18 closed 3 years ago

kartikdutt18 commented 4 years ago

Hey everyone, This PR aims to add preprocessor function for YOLO class. This basically converts annotations into feature maps that can be used for training YOLO model i.e. have the same format as output of YOLO model. To Do :

CC : @KimSangYeon-DGU, @saksham189, @zoq

saksham189 commented 4 years ago

Hey @kartikdutt18 , I just wanted to know whether you were stuck anywhere with this because we were planning to finish this first.

kartikdutt18 commented 4 years ago

Hey @saksham189, I've probably written some expression wrong somewhere and I wasn't able to track it down before Saturday so as it was decided to start with the translator from Saturday, I implemented the weight translator here so we can now transfer weights of Darknet model or any other model from PyTorch to mlpack. However other than weights we also need to transfer running mean and variance for BatchNorm Layer and with that I'm stuck with the error here. I'll take a look at the preprocessor again today. In the meanwhile, I tried training Darknet 19 model on Cifar10, It didn't converge, so I also added Darknet 1 (same as YOLO model) on Cifar10 to see if we can train that and it takes 3 hours for a single epoch so we should also be able to train YOLO model (in less time than Darknet), if needed. Here is the log for the first epoch (20% accuracy). 21_log_epoch Kindly let me know what you think.

saksham189 commented 4 years ago

Looks good and the training time is also considerably lower. So, maybe we should just train that first and look at the accuracy.

kartikdutt18 commented 4 years ago

Looks good and the training time is also considerably lower. So, maybe we should just train that first and look at the accuracy.

Great, I'm letting the model train. In the meanwhile, I will try to get running mean and variance also loaded into mlpack. Also, with transferred weights we can also train the model on imagenette (that way running mean and variance will be set in training).

kartikdutt18 commented 4 years ago

Hey @saksham189, I fixed the errors in the implementation as well added tests fro single image, multiple images and image with multiple bounding box.

kartikdutt18 commented 4 years ago

So, maybe we should just train that first and look at the accuracy.

Hey @saksham189, @KimSangYeon-DGU, I continued the training. Initially it was for 5 epochs (the learning rate was 0.01) and after 5 epochs it remained constant and the below graph was obtained. Then, I set learning rate to 0.001 and it's still training and has completed nearly 25 epochs out of 40. The training and validation accuracy are continuously increasing from 20% and 7% respectively to 31% and roughly 20%. The graph for that is also attached below. Also, about using larger image sizes such as imagenette, The training time doesn't change significantly with larger images however time for loading the dataset is very large. Imagenette with 320 x 320 x 3 image size and 5k images nearly took an hour. Current training log (lr = 1e-3). darknet_v1_fast_mean_log_epoch darknet_v1_fast

First attempt to train (5 epochs / lr = 1e-2) (training accuracy = 26%, Graphs are shown below) darknet_v1_slow_mean_log_epoch darknet_v1_slow I'll add the changes for YOLOv3 in a couple of minutes. Then I would also have to add tests for the same.

kartikdutt18 commented 3 years ago

I think this is ready to go as well.

saksham189 commented 3 years ago

Thanks for the great contribution @kartikdutt18 !

kartikdutt18 commented 3 years ago

Thanks lot @KimSangYeon-DGU, @saksham189, @zoq for the reviews and all the help. Also, thanks a lot for mentoring me during GSoC.