tensorflow / models

Models and examples built with TensorFlow
Other
77.01k stars 45.79k forks source link

Object Detection API training documentation/tutorial from scratch + from retraining for TF2 #8869

Open grewe opened 4 years ago

grewe commented 4 years ago

Prerequisites

Please answer the following question for yourself before submitting an issue.

1. The entire URL of the file you are using

https://github.com/tensorflow/models/tree/master/official/...

2. Describe the feature you request

I would like to request two simple examples training Object Detection API from scratch and a second retraining (possibly of a SSD MobileNet model...dataset don't care) --to understand how to use the new API for TF2. Without this it is extremely difficult to understand how to transition from Object Detection API under TF1 to TF2. Tensorflow has nice examples (and codelabs) for doing both for classification. Detection examples are needed and not present even for TF1 officially --for TF2 it is critical.

3. Additional context

4. Are you willing to contribute it? (Yes or No)

Yes but, need at least shell of program to begin

Jacobsolawetz commented 4 years ago

@grewe I hope this can be of use to you and others searching for a minimal getting started example!

I wrote a tutorial to train EfficientDet in Google Colab with the TensorFlow 2 Object Detection API.

You can run this tutorial by changing just one line for your custom dataset import. I hope this tutorial allows newcomers to the repository to quickly get up and running with TensorFlow 2 for object detection!

In the tutorial, I write how to:

Acquire Labeled Object Detection Data Install TensorFlow 2 Object Detection Dependencies Download Custom TensorFlow 2 Object Detection Dataset Write Custom TensorFlow 2 Object Detection Training Configuration Train Custom TensorFlow 2 Object Detection Model Export Custom TensorFlow 2 Object Detection Weights Use Trained TensorFlow 2 Object Detection For Inference on Test Images

Specifically, to use this tutorial for retraining - it isn't the most intuitive, but you should be able to edit the config file where it is pointing to the checkpoint to point to one of your trained checkpoints. The model should pick up again from that point.

AshishGusain17 commented 4 years ago

@grewe I hope this can be of use to you and others searching for a minimal getting started example!

I wrote a tutorial to train EfficientDet in Google Colab with the TensorFlow 2 Object Detection API.

You can run this tutorial by changing just one line for your custom dataset import. I hope this tutorial allows newcomers to the repository to quickly get up and running with TensorFlow 2 for object detection!

In the tutorial, I write how to:

Acquire Labeled Object Detection Data Install TensorFlow 2 Object Detection Dependencies Download Custom TensorFlow 2 Object Detection Dataset Write Custom TensorFlow 2 Object Detection Training Configuration Train Custom TensorFlow 2 Object Detection Model Export Custom TensorFlow 2 Object Detection Weights Use Trained TensorFlow 2 Object Detection For Inference on Test Images

Specifically, to use this tutorial for retraining - it isn't the most intuitive, but you should be able to edit the config file where it is pointing to the checkpoint to point to one of your trained checkpoints. The model should pick up again from that point.

@grewe I hope this can be of use to you and others searching for a minimal getting started example!

I wrote a tutorial to train EfficientDet in Google Colab with the TensorFlow 2 Object Detection API.

You can run this tutorial by changing just one line for your custom dataset import. I hope this tutorial allows newcomers to the repository to quickly get up and running with TensorFlow 2 for object detection!

In the tutorial, I write how to:

Acquire Labeled Object Detection Data Install TensorFlow 2 Object Detection Dependencies Download Custom TensorFlow 2 Object Detection Dataset Write Custom TensorFlow 2 Object Detection Training Configuration Train Custom TensorFlow 2 Object Detection Model Export Custom TensorFlow 2 Object Detection Weights Use Trained TensorFlow 2 Object Detection For Inference on Test Images

Specifically, to use this tutorial for retraining - it isn't the most intuitive, but you should be able to edit the config file where it is pointing to the checkpoint to point to one of your trained checkpoints. The model should pick up again from that point.

Just don't post the same comment everywhere, you haven't wrote anything worth in that so called tutorial

Jacobsolawetz commented 4 years ago

@AshishGusain17 that is good feedback... i'm learning with each passing day - would you be willing to share how the tutorial could have been written to be of more use to you?

grewe commented 4 years ago

@Jacobsolawetz thank you for your tutorial...I am going to look at it today/tomorrow.

grewe commented 4 years ago

@Jacobsolawetz quick question --I am trying your colab and at the same time trying to run locally (note I am a professor and often students like to train locally to get a handle on how to set things up locally first --also budgets limited --have not yet tried to teach students to make their own colabs). With this in mind, I note you have the change in the code to fix some keras code issue with the Ob. Det. API for TF2 --- I am having some trouble understanding how to do this locally ---I launch my jupyter notebook from a conda environment --but, not sure where the appropriate file /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/tf_utils.py is located. I have paths like C:\Users\Lynne\Anaconda3\pkgs\tensorflow-base-2.1.0-eigen_py36h49b2757_0\Lib\site-packages\tensorflow_core\python\keras\utils where the tf_utils.py is located but, there are multiple paths -and more importantly --when inside of a notebook and you are doing an upgrade of tensorflow to say 2.3 --how is this effecting the location of this tf_utils.py I need to over-write with the new code you provide in the notebook. Thank you Lynne

Petros626 commented 2 years ago

@grewe I think if you want to use the TF OD API and train from scratch, you should delete the line with fine_tune_checkpoint , fine_tune_checkpoint_type. There you normally pass the model.ckpt, which contains the pretrained weights on a specific dataset. But careful you need maybe a huge amount of images for training from 0, because the weights are initialized randomly and need much examples to learn new weights related to your dataset