Skip to content

Using Transfer Learning to build an logo Object Detection model for Tensorflow and Tensorflow Lite #ShadowML

License

Notifications You must be signed in to change notification settings

BrooksIan/LogoTL

Repository files navigation

Cloudera Logo Object Detection

Deep Learning

Transfer Learning with Tensorflow

Introduction - Corporate Logo Object Detection

The goal of this project is to build a Tensorflow Object Detection model designed to detect the Cloudera and Hortonworks logos. This project will include the scripts, photos, and instructions that are required to follow this project at home. This Github repo include annotated images and completed models for quick testing.

hwlogodetection clogodetection COlogodetection

Language: Python

Requirements:

  • Python 3.8
  • Tensorflow 2.3.1

Author: Ian R Brooks

Follow: LinkedIn - Ian Brooks PhD

Table of Contents

  1. Introduction

  2. Links

    1. Object Detection
    2. Image Augmentation For Object Detection
    3. Converting Tensorflow Models to Tensorflow Lite Models
    4. Google Coral Dev Board
    5. Tools
  3. Image Preprocessing - Image and Label Preparation (Optional)

  4. Data Augmentation - Synthetic Image Creation

  5. Build Tensorflow Model Instructions

    1. CDSW/CML Run Instructions
    2. Quick Instructions
    3. Step By Step Command Line Instructions
  6. Convert Tensorflow Models

Links

Object Detection:

Image Augmentation For Object Detection:

Converting Tensorflow Models:

Google Coral Dev Board:

Tools:

Image Preprocessing - Image and Label Preparation (Optional)

Since this is an Object Detection model, images and annotation labels, which x,y coordinate information on the location of the object in the image, are both required for training. To create these label annotations, the software package LabelImg can create the object's label annotation into XML files. Please note this step is optional, these files have been provided in this project, and they are avaiable in the Images/train/ or Images/test/ directories. Below is a screenshot of the the application.

LabelImg

Data Augmentation - Synthetic Image Creation

Considering this is a Deep Learning model, the training set should be in the 1000s of photographs, but this project only has 10s of photos. In order to create trainset that is proper size, Data Augmentation will be required to create synthetic images for training. Using this library, this project will take the originally provided photos and create synthetic images for training to boost model performance. This article on the subject is a must read to fully understand this project.

This process is automated by provided scripts, but the user will need to determine the amount of synthetic training examples that will be created.

Below are a few different examples, please note the object labels are updated for the image.

AugImg1 AugImg2 AugImg3 AugImg4

Build Tensorflow Object Detection Model Instructions

Please Note: Any scripts that use '~/' in the path are assuming this is the home directory of the downloaded project. This is the default for CDSW.

CDSW/CML Run Instructions

  1. In CSDW/CML, download the project using the git url for here.
  2. Open a new session, run the CDSW-build.sh script at the terminal prompt, which contains the following operating code.

Manual Instructions

Download and Install Libraries

  1. Download the project using the git url for here.

  2. Project Setup

./scripts/setup.sh

Preprocessing Images

  1. Convert CSV labels to Tensorflow TF-Record type.
./scripts/imagePrep.sh
  1. (Optional) Validate images for sizing errors
 python3 scripts/checkImages.py 

Build Model Using Transfer Learning - Retrain Model With New Detection Objects

  1. Start model training process.
./scripts/buildModel.sh

modeltrain0 modeltrain1

  1. Evaluate model
./scripts/evalModel.sh

modeleval

Export TensorFlow Model to Saved Model Format

  1. Export model
./scripts/exportModel.sh

modelsaved

Convert TensorFlow Saved Model To Java Script

  1. Export model
./scripts/exportModelJS.sh

modeljs

(Optional) Convert TensorFlow Saved Model To TFLite Model

  1. Export model
./scripts/convertTF2TFL.sh

modeltfl modeltfl1

logodetection

About

Using Transfer Learning to build an logo Object Detection model for Tensorflow and Tensorflow Lite #ShadowML

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published