Detect Hair Color
Let’s learn how to detect hair color in a digital image.
Introduction
Our hair is a salient element of our overall appearance and plays a key role in facial analysis. Accurate detection and segmentation of the hair region under unconstrained conditions remains challenging for the following reasons:
- Poor lighting conditions
- Crowded background
- Hairstyle and color variations
The segmentation of the hair region provides cues during the face recognition process and is valuable to many domains like:
- Augmented reality applications, such as hair modeling.
- Biometric recognition applications, such as detecting the presence of a human when their back is turned to the camera.
Objective
This lesson will explore how to exploit a pretrained ONNX model for hair segmentation. We’ll develop a Python utility that detects the color of the segmented hair region.
Dependencies
We’ll be using the following external Python libraries.
Library | Version |
onnxruntime | 1.9.0 |
MediaPipe | 0.8.9 |
opencv-python | 4.4.0.46 |
scikit-learn | 1.0.1 |
NumPy | 1.19.4 |
webcolors | 1.11.1 |
filetype | 1.0.7 |
Let’s code this utility!
Before exploring the ...