Shebin Jose Jacob / Label Inspection Public

Shebin Jose Jacob / Label Inspection

This is your Edge Impulse project. From here you acquire new training data, design impulses and train models.

Object detection

About this project

Automated Label Inspection With FOMO

Every day, billions of variable data labels are utilized to offer vital consumer information, defend brands, give brand protection and identification, and track or identify things. That much capability is packed into a short area. The information written on labels, whether they act as a routing barcode on a postal item or are used to help identify products, must be clear and accurate, and the labels themselves must be properly placed. The capabilities offered by label inspection systems ensure that these standards are met.

Print quality is greatly influenced by several factors, including machine settings, environmental conditions, and raw material quality. Mislabels, ink spills, smudged lettering, missing prints, dots, and markings are common printing-related occurrences. These flaws not only leave potential for misunderstandings and erroneous information, but they also lead to repeated client rejections and reduce the value of the brand. Inspection of print quality is a crucial step that can spare your production from all of that hassle.

So we are trying to build a fast and accurate automated label inspection system utilizing the capabilities of FOMO to detect ink smudges, foreign elements, unwanted dots and marks, inverted labels, and many other printing issues. As FOMO is fast and accurate, the automated label inspection system can be built at a very lower price with immense accuracy and speed.


Cover 2.jpg

How Does It Work

Our system consists of a Raspberry Pi 4 along with a compatible 5 MP camera module. The system ceaselessly runs an AI model built using FOMO. The model is currently capable of detecting Ink Spills, Ink Smudges, Die Cutting, and Inverted Labels. More classes can be easily added and the system can be made more robust.

If the system detects any of the known defects it generates an alert in the web interface, which can be easily monitored. This system can be easily tweaked in such a way that whenever a defect is detected in the printing machine itself, the machine is stopped instantaneously for operator interference, which reduces the chances of any such defects due to machine error. Or this system can be easily employed to categorize the defective labels from a collection of printed labels using a sorter device.


Hardware requirements

  • Raspberry Pi 4
  • 5 MP Camera Module

Software requirements

  • Edge Impulse
  • Python

Hardware Setup

The hardware setup is pretty simple. It consists of a Raspberry Pi 4 Model B and a compatible 5 MP camera module.


SetUp 2.jpg

Software Setup

Raspberry Pi 4 comes with a quick get-started guide here, that will help you to set up Edge Impulse on your device. Follow the instructions and get your device connected to Edge Impulse Dashboard.


Build The TinyML Model

Once we have set up our hardware and software, now it's time to build the tinyML model. Let's start by collecting some data.

1. Data Acquisition and Labelling

Our data consists of four classes : Ink Smudges, Ink Spill, Die Cutting and Inverted Label.





We have collected 20 images belonging to each class and uploaded them using the Data Uploader. Label them from the Labelling Queue and split them into Training and Testing sets, in the ratio of 80:20, which forms a good dataset to start model training.

2. Impulse Architechture

As we are using FOMO as our object detection model, which performs better with 96 X 96 images we set our image width and height to 96px. Keeping Resize Mode to Fit shortest axis, add an Image processing block and an Object Detection (Images) learning block to the impulse.

Create Impulse.png

Image - Paramters.png

Move on by keeping the settings as it is, and use Feature Explorer to see how well your data collection and classes are separated.

Image - Features.png

3. Model Training and Testing

Once we have designed our impulse, let's continue training the model. The model training settings we used are as shown in the figure. You can tweak the parameters in such a way that the trained model shows a greater accuracy but beware of overfitting when playing with model training settings.

NN Settings.png

In this case, we are using FOMO (MobileNet V2 0.35) as the neural network, which outputs a fast, lightweight, and reliable machine learning model. We are using 225 learning cycles with a learning rate of 0.003 to build a fully functional model.


The trained model has an accuracy of 97%, which is pretty awesome. Now let's test how the model works with some previously unknown data. Move on to Model Testing and Classify All to evaluate the model's performance.

Model Testing.png

We've got 87.5% accuracy, quite promising. Now let's verify it again with some live classification. Navigate to Live Classification and collect some image samples from your development board or the uploaded test data.

4. Live Classification

Here we are collecting some data from our RPI 4 and let's test.

Live Classification.png

The model is working perfectly. Now let's deploy it back to the device.

Firebase Realtime Database

For our project, we used Firebase real-time database that allows us to rapidly upload and retrieve data without any waiting. In this case, we made advantage of the Pyrebase package, a Python wrapper for Firebase.

To install Pyrebase,

pip install pyrebase

In the database, follow the given steps.

  • Create a project.
  • Then navigate to the Build section and create a realtime database.
  • Start in test mode, so we can update the data without any authentication
  • From Project Settings, copy the config.

Now add this piece of code by replacing the config details, into your python file to access data from firebase.

import pyrebase
config = {
  "apiKey": "apiKey",
  "authDomain": "",
  "databaseURL": "",
  "storageBucket": ""
firebase = pyrebase.initialize_app(config)

Web Interface

We are using a webpage created using HTML, CSS, and JS to display the defects in real time. The data updated in Firebase Realtime Database is updated on the webpage in real-time. The webpage displays various defects with their occurrences so that the operator can easily look for the particular issue.

Web Interface.png


The code for this project is developed using Python and Edge Impulse Python SDK. The entire code and assets are available in the github repository.


Click to Play

Download block output

Title Type Size
Image training data NPY file 68 windows
Image training labels JSON file 68 windows
Image testing data NPY file 16 windows
Image testing labels JSON file 16 windows
Object detection model TensorFlow Lite (float32) 83 KB
Object detection model TensorFlow Lite (int8 quantized) 56 KB
Object detection model TensorFlow SavedModel 189 KB
Object detection model Keras h5 model 90 KB

Clone project

You are viewing a public Edge Impulse project. Clone this project to add data or make changes.


Data collected
84 items

Project info

Project ID 140432
Project version 2
License Apache 2.0