A Quick Guide on Preprocessing Facial Images for Neural Networks using OpenCV in Python

Covering face and eyes detection plus image straightening, cropping, resizing and normalization

Jaime Durán
yottabytes

--

Available in Spanish too | Disponible también en español

Currently I’m working on a computer vision problem involving facial classification. As you may know, that usually means applying Deep Learning, so a special preprocessing stage is required before injecting the images to our neural network.

It’s a very significant task in order to boost our model accuracy, and it can be easily accomplished by following a few simple steps. And for these we might use OpenCV: a highly optimized open source library for (real-time) computer vision applications, available in C++, Java and Python.

This is a brief article with the basic guidelines, examples and code for the stuff you’ll probably need to apply on every facial classification or recognition problem.

NOTE: all static images used in this article come from very known memes.

Image loading

We’ll use the imread() function to load an image, specifying the path to the file and the mode. This second parameter is important to run basic channel and…

--

--

Jaime Durán
yottabytes

Yet another data scientist with a blog. In fact I write two (uno en español)