Full detailed explanation on how to create, transform, and infer a celebrity-look-alike demo with TensorFlow on an i.MX 8M Plus NPU integrated in a phyBOARD-Pollux

Image for post
Image for post
Photo by NASA on Unsplash

Info:

In this blog will talk in detail about how to create a celebrity-look-alike demo, and how to prepare it for the use on an embedded NPU. If you are only interested how to make a model run on the i.mx8M Plus NPU, please visit this article to save yourselves some time and get more details on post training quantization with different TensorFlow versions.

  • Overview
  • Prerequisites
  • The Celebrity-Look-Alike Demo
    Preparation
    — What are Embeddings
    — How are Embeddings Created
    Implementation in Code
    — Quantize Your Model to int8
    — Short Sidestep on How to Use Your Already Existing Model
    — Create a Database
    — Prepare the Data Set Further and Create a “Only Faces Fata Set”
    — Create Embeddings of Each Image in Your Database
    — Load the Embeddings from json
    — Live Stream Analysis
    — Loading the Model
    — Point to the Cascade Classifier
    — Set Pre-Processing Function
    Split Your Data
    — Setting the Video Pipeline
    Start the Live Stream
    — Call the Video Pipeline
    — Find Faces in the Live Stream
    After Button Press
    — Finding and Cropping Middle Face
    — Further Pre-Process Found Face
    — Compare the Embeddings
    — Plot…


Creating a Dataset for Celebrity Comparison with Creative Commons License Images and Tuning the Dataset to Perform Better

Image for post
Image for post
Photo by Matthew Henry on Unsplash

Table of Content

  • Introduction
    -
    Prerequisite
  • The Crawler
  • Using Deep Neural Network to Identify Miss-Matched Images
    -
    The Idea
    - The Results
    - The Code
  • Further Improvement

Introduction

When you want to create a data set to compare your face to the face of celebrities and run it for example on a phyBoard Pollux neural processing unit, like we did here, or any other aim where you would use images of e.g., celebrities, the good images are mostly not under a creative common license. We used a Bing image crawler to look for celebrity faces and had troubles when using the filter set to: commercial and reuse.


Preparing a TensorFlow Model to Run Inference on an i.MX 8M Plus NPU integrated in a phyBOARD-Pollux

Image for post
Image for post
image by Liam Huang and mikemacmarketing, CC

Table of contend

  • Introduction
    - Why does the NPU utilize int8 when most ANNs are trained in float32?
    - Prerequisite
  • Post training quantization with TensorFlow Version 2.x
    - First Method — Quantizing a Trained Model Directly
    - Second and Third Method — Quantize a Saved Model from *.h5 or *.pb Files
  • Converting with TensorFlow Versions below 2.0

Introduction

In this article, we will explain in this article which steps you have to take to transform and quantize your model with different TensorFlow versions. We are only looking into post training quantization.


Image for post
Image for post

Preamble

This tutorial explains every step in detail. I know the struggle of pre-assumed knowledge to well.

  • Install blobfuse on your DSVM with sudo apt-get install blobfuse
  • Create folder for blob on the DSVM with: mkdir ~/mycontainer
  • Mount blob into DSVM with:
sudo blobfuse ~/mycontainer --tmp-path=/mnt/resource/blobfusetmp --config-file=./fuse_connection.cfg -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o allow_other
  • Connect your Jupyter Notebook to the DSVM
  • Use Keras flow_from_directory() with the path pointing to the mounted blob
  • Save models into the same path via callback function

Introduction

In this tutorial I want to show how to connect your Azure Blob storage to your Azure DSVM to use it with your Jupyter notebook and e.g., Keras2.
I struggled to set up this connection to be able to use my uploaded images with the Keras ImageDataGenerator() function. Therefore, I want to show step by step how I achieved this. There might be better and more elegant ways. If you have one, please let me know. …

About

Jan Werth

Hi, I am a carpenter, electrical engineer and have over 10 years of experience in signal processing, machine- and deep learning. linkedin.com/in/jan-werth

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store