automl icon indicating copy to clipboard operation
automl copied to clipboard

How fast should finetuning happen?

Open LucasSloan opened this issue 6 years ago • 19 comments

I have a custom dataset that I tried to finetune on. I used the D0 model, and trained for 10 epochs of 150k images, but I got a max AP of 0.05. The tutorial for PASCAL VOC 2012 gets 0.33 AP after a single epoch of only 5k images. Although I think that's evaluating on the training data...

LucasSloan avatar Apr 12 '20 19:04 LucasSloan

Update:

  1. I'm using the Waymo dataset, and had dumped the training data sequentially into a single tfrecord. Dumping it into multiple tfrecords to allow better mixing of training data got me to an AP of 0.11 after 2 epochs.

  2. I tested finetuning on PASCAL with a 20% holdout set and got an AP of .27 after one epoch.

I think the issue is just that my dataset is much harder to train on, I'm going to try a longer training period and I'll report back.

LucasSloan avatar Apr 14 '20 19:04 LucasSloan

Ok, just finished a training run with 5x the data and 5x the epochs (800k images, 10 epochs) and topped out at an AP of 0.13.

Very confused at this point, I'm going to take a good, hard look at my tfrecord converter to make sure there isn't some bug...

Has anyone else tried training on the Waymo dataset and gotten better results?

LucasSloan avatar Apr 19 '20 17:04 LucasSloan

0

I ran inference on one of the images, and it looks vaguely sensible? 2 or 3 huge spurious detection boxes, though... Does anyone know if that's a know failure mode that I could track down?

LucasSloan avatar Apr 20 '20 02:04 LucasSloan

Not sure about why there are some big boxes. A temporary solution is that you can try to increase the the min_score_thresh might avoid drawing those boxes.

mingxingtan avatar Apr 20 '20 03:04 mingxingtan

When I saw those big spurious detections, I thought the issue might be that my finetuning was actually making things worse, so I added some code to map the classes from coco to waymo so I could get mAP values with just the released checkpoints. It confirmed that the finetuning was helping - the mapped class version only had an mAP of 0.06.

LucasSloan avatar May 08 '20 17:05 LucasSloan

For comparison, the mapped version of d7 had a mAP of 0.19.

LucasSloan avatar May 08 '20 21:05 LucasSloan

d4 was 0.16.

LucasSloan avatar May 09 '20 06:05 LucasSloan

d4 was 0.16.

Hi, can you explain that how did you fine-tune?

uysalmustafa avatar Jun 11 '20 10:06 uysalmustafa

That number isn't from fine-tuning - I just added some code that translated the classes from COCO to the classes in the Waymo Dataset (car, truck -> vehicle, etc.) and used the checkpoint weights as is. From that I was able to confirm that finetuning was in fact working, since the finetuned d0 had an AP of 0.13 instead of the 0.6 that the mapped d0 had.

I've never successfully finetuned one of the larger models, due to issues with memory and compute utilization.

LucasSloan avatar Jun 11 '20 17:06 LucasSloan

You should follow https://github.com/google/automl/tree/master/efficientdet#8-finetune-on-pascal-voc-2012-with-detector-coco-ckpt for finetuning dataset. I could train with batch size 64 on GTX 1080TI.

fsx950223 avatar Jun 28 '20 07:06 fsx950223

You should follow https://github.com/google/automl/tree/master/efficientdet#8-finetune-on-pascal-voc-2012-with-detector-coco-ckpt for finetuning dataset. I could train with batch size 64 on GTX 1080TI.

You are surely not using one GPU, right? Training efficientdet-d0 on coco I could only have batch size of 10 on a single GPU, and a batch size of 12 per GPU on a server with horovod docker.

debabicz avatar Jul 03 '20 13:07 debabicz

I only train head. Why batch size only 10? Do you understand what I mean? I suggest you should read README.md again.

fsx950223 avatar Jul 03 '20 14:07 fsx950223

One batch is a number of images that can fit into the GPU while calculating the gradient and changing the weights of the network, I am aware of that (but not because I read the README.md). And that could be the difference, your gradient is only changing the weights of the head, while the rest of the network is frozen I presume. However, training the whole network - which I'd like to do in order to replicate the paper's results - contains a lot more weights to be trained and changed.

debabicz avatar Jul 03 '20 15:07 debabicz

One batch is a number of images that can fit into the GPU while calculating the gradient and changing the weights of the network, I am aware of that (but not because I read the README.md). And that could be the difference, your gradient is only changing the weights of the head, while the rest of the network is frozen I presume. However, training the whole network - which I'd like to do in order to replicate the paper's results - contains a lot more weights to be trained and changed.

We are talking about finetune dataset in the issue, maybe I missed something?

fsx950223 avatar Jul 03 '20 15:07 fsx950223

No, you are completely right, I am sorry, there was a miscommunication in that matter,. I should open new issues for new problems. (I was just scrolling through old issues because part of the documentation is in the issues and the repo does not work without them.)

debabicz avatar Jul 03 '20 15:07 debabicz

You should follow https://github.com/google/automl/tree/master/efficientdet#8-finetune-on-pascal-voc-2012-with-detector-coco-ckpt for finetuning dataset. I could train with batch size 64 on GTX 1080TI.

@fsx950223 what checkpoints were you able to fine-tune on? Were you able to fine-tune on d4 with one/multiple GPU?

drwaltman avatar Jul 22 '20 17:07 drwaltman

I've been able to finetune with d3 on a single GPU. I still haven't gotten multi gpu training working, but I think the new keras code might make it work.

LucasSloan avatar Jul 22 '20 17:07 LucasSloan

Running d4 is very slow + batch size 1 on my 2080 ti

LucasSloan avatar Jul 22 '20 17:07 LucasSloan

Hi @LucasSloan,

Would you mind sharing the finetuning command that you have used? I would also like to fine tune on my own dataset.

Thanks! David

davidmurray avatar Jul 27 '20 00:07 davidmurray