Project Demo
Overview

Cover Image

Bridge Collapsed
Why localization?
Why do we want to localize the detection using an image classification model? Can’t we use the object detection model? Yes, we can use the object detection model but we would need to add bounding boxes to thousands of samples manually. Existing object detection models may not be a good choice to auto-annotate these cracks since they are trained on definite shape objects. Repurposing the classification model for localizing the detection saves a lot of effort and still would be able to identify the regions of interest.How does it work?
The CNN (convolutional neural networks) with GAP (Global Average Pooling) layers that have been trained for a classification task can also be used for object localization. GAP is a pooling operation designed to replace fully connected layers in classical CNNs. The idea is to generate one feature map for each corresponding category of the classification task in the last MLP conv layer. A GAP-CNN not only tells us what object is contained in the image - it also tells us where the object is in the image, and through no additional work on our part! The localization is expressed as a heat map (class activation map) where the color-coding scheme identifies regions that are relatively important for the GAP-CNN to perform the object identification task.Hardware Setup
Since we wanted to use compact and portable yet powerful hardware, we will be using a Texas Instruments SK-TDA4VM Starter Kit for edge AI vision systems. It is powered by a TDA4VM processor that enables 8 TOPS of deep learning performance and hardware-accelerated edge AI processing. Also, we would need a USB web camera and a monitor (for displaying inferencing results).
Hardware
Setup Development Environment
To install an Operating System, download the latest ti-processor-sdk-linux-sk-tda4vm-etcher-image.zip image and flash it to the SD card using the Balena etcher tool. After flashing, insert the SD card into the SD slot on the development board and turn on the power. We can view the boot log by connecting the UART cable to the computer and using a serial port communications program (CoolTerm or minicom) at a 115200 baud rate. We can use the same UART console to execute shell commands or we can connect an Ethernet cable to set up a remote ssh session. Since we will be using a custom TFLite model trained using the Edge Impulse Studio, we need to set up model compilation tools on a Linux machine. We are using a Ubuntu 18.04 Virtualbox guest on a macOS host. Please execute the commands below to set up the compilation environment.Data collection
The datasets were downloaded from Mendeley Data (Concrete Crack Images for Classification). The dataset contains various concrete surfaces with and without cracks. The data is collected from multiple METU Campus Buildings. The dataset is divided into negative and positive crack images for image classification. Each class has 20,000 images with a total of 40,000 images with 227 x 227 pixels with RGB channels.
Datasets
- Surface Crack Dataset: https://data.mendeley.com/datasets/5y9wdsg2zt/2
- COCO-Minitrain dataset: https://github.com/giddyyupp/coco-minitrain
Uploading data to Edge Impulse Studio
We need to create a new project to upload data to Edge Impulse Studio.
New Project
- Positive - surface with crack
- Negative - surface without crack
- Unknown - images from the 80 objects

Data Acquisition
Training
Go to the Impulse Design > Create Impulse page, click Add a processing block, and then choose Image, which preprocesses and normalizes image data, and optionally reduces the color depth. Also, on the same page, click Add a learning block, and choose Transfer Learning (Images), which fine-tunes a pre-trained image classification model on the data. We are using a 160x160 image size. Now click on the Save Impulse button.
Create Impulse

Feature Generation

Feature Explorer

Model Selection

Switch Expert Mode

Editor

Network

Confusion Matrix
Model Deployment
Now We can download the quantized model from the Edge Impulse Studio Dashboard.
Download Model

tflrt\_work\_flow
compile.py
) given below. The script uses a few calibration images borrowed from the training datasets.
- TFLite runtime as the top-level inference API for user applications
- Offloading subgraphs to C7x/MMA accelerator for accelerated execution with TIDL
- Runs optimized code on ARM core for layers that are not supported by TIDL

runtimes\_visualization
Run Inference
The TFLite model file and the artifacts are copied to the target (SK-TDA4VM Evaluation board). The inferencing application is a multithreaded Python script that offloads the display task to a dedicated thread. The heatmap is overlaid with the input images whenever a crack is detected. Some test run results’ images are given below.
crack\_localization
Live Demo
For the live demonstration in the field, we used a portable monitor with a built-in battery and a 5000mAh power bank which can supply a maximum of 3A current at 5V. The demo script (inference.py
) is executed using a Laptop over a UART console.

Conclusion
This project showcases an industrial use case for surface crack detection which can be used for predictive maintenance. The project has the following key characteristics.- Customize the pre-trained transfer learning model in the Edge Impulse Studio Expert Mode
- Demonstrate the use of a multi-output model trained using Edge Impulse
- Runtime heat-map visualization to localize the detected cracks.
- A scalable and portable solution