In the previous blogs we have seen how to generate data for object detection and convert it into TFRecord format to train the model. In this blog we will learn how to use this data to train the model.
To train the model we will use the pre-trained model and then use transfer learning to train it on our dataset. I have used
The configuration file that we have downloaded, needs to be edited as per our requirement. In configuration


For the object-detection.pbtxt file,
Now go to models -> research -> object detection -> legecy and copy train.py file to models -> research folder.
Then create a folder named images inside models -> research folder. Put your mobilenet model, configuration file, train and test image data folders, and train and test csv label files. Inside training_data folder,
Also create a training folder inside the images folder where model will save its checkpoints. Now run the following command to train the model from models -> research folder.
Time for training your model will depend upon your machine configuration and no. of steps that you have mentioned in the configuration file.
Now we have our trained model and its checkpoints are saved inside the models/research/images/training folder. In order to test this model and use this model to detect objects we need to export the inference graph.
To do this first we need to copy models/research/object_detection/export_inference_graph.py to models/research/ folder. Then inside models/research folder create a folder named “snake” which will save the inference graph. From models -> research folder run the following command:
Now we are having forzen_inference_graph.pb inside models/research/snake folder which will be used to detect object using trained model.
This is all for training the model and saving the inference graph, in the next blog we will see how to use this inference graph for object detection and how to run our snake game using this trained object detection model.
Next Blog: Snake Game Using Tensorflow Object Detection API – Part IV
Hope you enjoy reading.
If you have any doubt/suggestion please feel free to ask and I will do my best to help or improve myself. Good-bye until next time.