Skip to content

YousefAlaaAli/Object-Localization-with-TensorFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Emoji Detection & Classification with CNN

Detect and classify emojis in images using a Convolutional Neural Network (CNN) model built with TensorFlow/Keras.
This project predicts both the class of an emoji and its location using a dual-output neural network โ€” one for classification and one for bounding box regression.


๐Ÿ“Œ Features

  • ๐Ÿ” Emoji Detection โ€” Locate emoji within the image by predicting bounding box coordinates.
  • ๐ŸŽญ Emoji Classification โ€” Classify the emoji (e.g., happy, sad, skeptical, etc.).
  • ๐Ÿ“ฆ Custom IoU Metric โ€” Measures the overlap between predicted and ground-truth boxes.
  • ๐Ÿ–ผ๏ธ Visualization โ€” Real-time plotting of predicted vs actual results with bounding boxes.

๐Ÿ—๏ธ Model Architecture

  • CNN backbone (Conv + MaxPooling layers)
  • Two heads:
    • class_out โ†’ softmax activation for emoji classification
    • box_out โ†’ linear activation for bounding box coordinates
  • Compiled with:
    model.compile(
        loss={
            'class_out': 'categorical_crossentropy',
            'box_out': 'mse'
        },
        optimizer=tf.keras.optimizers.Adam(learning_rate=1e-3),
        metrics={
            'class_out': 'accuracy',
            'box_out': IoU(name='iou')
        }
    )

๐Ÿ” Output Visualization

When testing the model, the visualization uses the following color-coding:

  • Bounding Boxes:

    • โœ… Green box = Ground-truth location (actual position)
    • โŒ Red box = Model's predicted location
  • Class Labels:

    • โœ… Green label = Correct classification
    • โŒ Red label = Incorrect classification

How to Run

  1. Clone the repository
git clone https://github.com/your-username/emoji-detector.git
cd emoji-detector
  1. Install dependencies
pip install -r requirements.txt
  1. Train the model
jupyter notebook train.ipynb
  1. Test predictions
jupyter notebook test.ipynb

๐Ÿ”ง Requirements

  • Python 3.6+

  • TensorFlow 2.x

  • Jupyter Notebook


๐Ÿ“Š Custom IoU Metric

Includes a custom tf.keras.metrics.Metric implementation to track bounding box overlap performance across batches.


๐Ÿ”ฎ Future Improvements

  • Detect multiple emojis per image
  • Add data augmentation
  • Train on larger, real-world datasets
  • Use YOLO or SSD for real-time detection

๐Ÿ“Œ Dependencies

TensorFlow

NumPy

Matplotlib

Pillow (PIL)

About

Object Localization with TensorFlow and Keras

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published