This project aims to develop and train a custom object detection model on a novel dataset to identify and recognize the outfit representing the Saudi Foundation Day.
In this project, I have trained the Saudi Founding Day outfit detector on Google Colab utilizing its free GPU resources using Tensorflow object detection API version 2.
Note: in this repository, I am providing a summary of some of the model training steps, and I have demonastrted the entire model training steps in detail in this saudi founding day object detection jupyter notebook.
-
Google Colab
-
Python 3.8.10
-
TensorFlow 2.11.0
-
Tensorflow 2 object detection API
-
labelImg
I collected 500 images that express the outfits for the Saudi Foundation Day, then divided them into 400 images to feed into the model for the training phase and 100 images for the testing phase.
To annotate the dataset, I used the LabelImg tool on the train and test images, and labeled each image. (Note: It took me 3 hours and 30 minutes to finish the annotations process)
I trained the custom model using the fine-tuning technique(transfer learning). I chose the pre-trained ssd_mobilenet_v2_fpnlite_320x320_coco17
model checkpoint (that has been trained on the COCO dataset) as a starting point to train my model.
I made the following changes to the model pipeline config file:
-
Changed
num_classes
tonum_classes: 1
-
Changed
fine_tune_checkpoint
tofine_tune_checkpoint: "/content/drive/MyDrive/ saudi-founding-day-object-detection/data/ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8/checkpoint/ckpt-0"
-
Changed
fine_tune_checkpoint_type
tofine_tune_checkpoint_type: "detection"
-
Changed
batch_size
tobatch_size: 24
(Note: batch_size = 128 and 64 give an error in google colab) -
Changed
num_steps
tonum_steps: 2000
-
Changed
label_map_path
tolabel_map_path: "/content/drive/MyDrive/saudi-founding-day-object-detection/data/label_map.pbtxt"
-
Changed
input_path
toinput_path: "/content/drive/MyDrive/saudi-founding-day-object-detection/data/train.record"
-
Changed
label_map_path
tolabel_map_path: "/content/drive/MyDrive/saudi-founding-day-object-detection/data/label_map.pbtxt"
-
Changed
input_path
toinput_path: "/content/drive/MyDrive/saudi-founding-day-object-detection/data/test.record"
(Note: I trained the model on 500 images for 2000 steps thus the training process took 8 hours on google colab)
Below are some of the model predictions on images and videos to show the model performance:
output-1.mp4
output-2.mp4
As we can see, the outcome of the model is very acceptable and gives high accuracy and I am happy with the results.
For a more robust model, I would suggest increasing the size of the dataset and training the model for more than 2000 steps.