kalthommusa / Saudi_Founding_Day_Object_Detection

A custom model trained on a novel dataset using TensorFlow Object Detection API version 2 (On Google Colab).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Saudi Founding Day Object Detection


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.

Technology and tools used:

  • Google Colab

  • Python 3.8.10

  • TensorFlow 2.11.0

  • Tensorflow 2 object detection API

  • labelImg

Project steps/pipline:

  • 1- Building the dataset (Data preparation)

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.

  • 2- Annotating the dataset

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)

  • 3- Training the model

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 to num_classes: 1

  • Changed fine_tune_checkpoint to fine_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 to fine_tune_checkpoint_type: "detection"

  • Changed batch_size to batch_size: 24 (Note: batch_size = 128 and 64 give an error in google colab)

  • Changed num_steps to num_steps: 2000

  • Changed label_map_path to label_map_path: "/content/drive/MyDrive/saudi-founding-day-object-detection/data/label_map.pbtxt"

  • Changed input_path to input_path: "/content/drive/MyDrive/saudi-founding-day-object-detection/data/train.record"

  • Changed label_map_path to label_map_path: "/content/drive/MyDrive/saudi-founding-day-object-detection/data/label_map.pbtxt"

  • Changed input_path to input_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)

  • 4- Monitoring Training with TensorBoard

  • 5- Testing out the custom trained model

Below are some of the model predictions on images and videos to show the model performance:

output-1.mp4
output-2.mp4

Observation

As we can see, the outcome of the model is very acceptable and gives high accuracy and I am happy with the results.

Future work

For a more robust model, I would suggest increasing the size of the dataset and training the model for more than 2000 steps.

About

A custom model trained on a novel dataset using TensorFlow Object Detection API version 2 (On Google Colab).


Languages

Language:Jupyter Notebook 100.0%Language:Python 0.0%