tensorflow / models

Models and examples built with TensorFlow
Other
77.23k stars 45.75k forks source link

Tensorflow 2 Object Detection API - Training MobileNet v2 from scratch #9931

Open Hyp3rbole opened 3 years ago

Hyp3rbole commented 3 years ago

I initially followed this tutorial to fine tune a SSD MobileNet v2 320x320 model from the TF2 model zoo.

However, I want to try training this MobileNetV2 model with a depth multiplier of 0.75. To do this, I understand that I need to retrain the MobileNetV2 model 'from scratch'. So I downloaded the COCO2017 dataset, with the intent to use this config file to train the model. This config mentions that it was trained from an ImageNet checkpoint, so I retrieved a MobileNet checkpoint trained on ImageNet checkpoint with dm=0.75 from here. However, the checkpoint files in this seem to be a different format to the checkpoints provided with the pre trained models on the model zoo? Eg, the model zoo models provide checkpoint, ckpt-0.data-00000-of-00001 and ckpt-0.index, whereas the imagnet checkpoint is missing the 'checkpoint' file.

When I try to train the model on any dataset using the downloaded config and ImageNet checkpoint, I get an error that the checkpoint is expected to be an object-based checkpoint?

I've uploaded my pipeline.config (I had to change the extension to .txt to upload it), from when I tried to train the model on a simple dataset with only one object class.

pipeline.txt

Hyp3rbole commented 3 years ago

Any update on this?

Petros626 commented 2 years ago

Sucks, that a whole repo can't be maintained well. Let me tell you what are my thoughts about training from scratch. You need a BIG dataset and then you must configure the parameters in such a way, that you get a satisfying result...could take weeks or months

Use better the option to fine tune your model on the pretrained dataset.

phydesmith commented 2 years ago

I ran into this issue as well.

On the defining your own model page, it has a link to slim checkpoints that I believe were originally used to to train the Zoo checkpoints. These are in the TF 1 checkpoint format which, even if you attempt to migrate it to the TF2 format, it does not work.

I was about to give up on training from scratch, but after re-reading the training and evaluation guide I found the hyperlinks to the 'classification checkpoints' which I believe in general correspond with the aforementioned slim models. These classification checkpoints are in the TF2 format which I was then able to get to work.

@Hyp3rbole I'm not sure if you've moved on from this, but for anyone else that has gotten to the point of trying to train from scratch, you at least have this option as of 9/29/2022.