Skip to content

ankith2409-web/object_detection_using_tensor_flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Object Detection using TensorFlow

A deep learning project that performs object detection on handwritten digits β€” simultaneously classifying what the digit is and localizing where it appears in an image using bounding box regression.

Built with TensorFlow and Keras as a custom multi-output CNN from scratch.


πŸ“Œ What It Does

Given an image with a digit placed at a random location, the model:

  • Classifies the digit (0–9)
  • Localizes it by predicting a bounding box [xmin, ymin, xmax, ymax]

This is the core idea behind object detection β€” not just what is in the image, but where.


🧠 Model Architecture

Input (75x75x1)
     β”‚
     β–Ό
Conv2D(16) β†’ AveragePooling
Conv2D(32) β†’ AveragePooling
Conv2D(64) β†’ AveragePooling
     β”‚
     β–Ό
Flatten β†’ Dense(128)
     β”‚
     β”œβ”€β”€β–Ί Dense(10, softmax)   β†’ Classification Output (digit 0–9)
     └──► Dense(4)             β†’ Bounding Box Output [xmin, ymin, xmax, ymax]

The model uses two output heads trained simultaneously:

Head Loss Function Metric
Classification Categorical Crossentropy Accuracy
Bounding Box Mean Squared Error (MSE) MSE

πŸ“‚ Dataset

  • Source: MNIST via tensorflow_datasets
  • Each 28Γ—28 digit is randomly placed inside a 75Γ—75 canvas
  • Bounding box coordinates are normalized between 0 and 1
  • Train set: 60,000 images | Validation set: 10,000 images

πŸ› οΈ Tech Stack

Tool Purpose
TensorFlow / Keras Model building & training
TensorFlow Datasets MNIST data loading
NumPy Array operations
Matplotlib Visualization
Pillow (PIL) Bounding box drawing

πŸ“Š Evaluation

Model is evaluated using:

  • Classification Accuracy β€” how often the digit label is correct
  • Bounding Box MSE β€” how close predicted box coordinates are to ground truth
  • IoU (Intersection over Union) β€” overlap between predicted and true bounding boxes (threshold: 0.6)

πŸš€ Getting Started

1. Clone the repo

git clone https://github.com/your-username/object-detection-tensorflow.git
cd object-detection-tensorflow

2. Install dependencies

pip install tensorflow tensorflow-datasets numpy matplotlib pillow

3. Run the notebook

Open objectdetection.ipynb in Jupyter or Google Colab and run all cells.


πŸ“ˆ Training

  • Optimizer: Adam
  • Epochs: 20
  • Batch Size: 64
  • Strategy: tf.distribute (supports multi-GPU)

πŸ“ Project Structure

object-detection-tensorflow/
β”‚
β”œβ”€β”€ objectdetection.ipynb   # Main notebook
β”œβ”€β”€ my_mnist_model.keras    # Saved trained model (after training)
└── README.md

πŸ’‘ Key Concepts Demonstrated

  • Multi-output neural networks
  • Bounding box regression
  • IoU-based evaluation
  • Custom data preprocessing pipelines with tf.data
  • Transfer of object detection concepts to digit localization

πŸ‘€ Author

HB Mrudhal Ankith
B.Tech AI & ML | Amity University, Bangalore
GitHub β€’ LinkedIn

About

🧠 Custom multi-output CNN built with TensorFlow/Keras that simultaneously classifies MNIST digits and predicts their bounding boxes using regression. Trained on a synthetic 75Γ—75 canvas dataset with IoU-based evaluation.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors