Train a custom Object Detection model
Here, we will see how to perform transfer learning from a pre-trained model on your own dataset the easiest way ever !
Last updated
Was this helpful?
Here, we will see how to perform transfer learning from a pre-trained model on your own dataset the easiest way ever !
Last updated
Was this helpful?
If you just want to skip explanations and just start training your model, we have cooked a notebook just for you that you can open in Colab.
First we need to install the picsellia
modules to get started.
And then install one of the following package whether you want to work with Tensorflow 1 or Tensorflow 2.
Now that we are all set, let's get started !
In order for your code to interact with the platform you need to start with those lines.
Ok, those first lines might need some explanations.
pxl_utils
and pxl_tf
are the only two modules we need to perform training with Tensorflow.
You can find your api_token
in your profile on the platform, see this.
You should see a greeting message in your console.
Now that we are connected to Picsell.ia, let's get down to real business.
If you have already created an experiment on the platform and chose a base model, you might want to retrieve it to launch your training and not create a new experiment, to do this you can call the following method
Let's explain the parameters :
'my-new-model' is obviously the name of the experiment you created earlier
tree
, setting this parameter to True will create the folder structure needed to store and organize all files issued from training (records, checkpoints, config, saved_model ...)
with_file
, this parameters is set to True to fetch on your machine all the files stored under your experiment (checkpoints, config...)
If you want to log and store everything you create or observe during training, you have to create what we call an experiment.
Check out this page to learn more about the experiment system.
Now we can see that our experiment has been created and that we have retrieved all the assets from the efficientdet network to start our training :
Now that we have created our experiment we need to do a few more steps before we can train, i'm sure you've guessed them :
Download annotations
Download images
Perform a train/test split
Create tfrecords (data placeholder optimized for training)
Edit the config file (needed to tune our experiment)
Now let's fetch the default parameters for our mode, if you want to change some, don't forget to log them back afterward !
Now we can call this simple method to run the training
Call this method to run an evaluation on all our test images
Now we can export our model so we can load it to perform inference later on
Let's try our model on a few images to check the results
Nice job ! We have performed a complete training in just a few steps, now we will log our metrics and logs to the platform and store our file assets so we can restore it in our next iteration:
The Client
is the main Picsell.ia class, it will be used in every tutorials. You can check the reference . The Client is for general use that's why here we initialize the subclass Experiment in order to focus on the experiment part of Picsell.ia.
This tutorial assumes that you have created your first project, please refer to if it's not the case.
Here are the functions that will perform those actions, if you need more information please check the reference .