[navigation]
TL;DR:
- Hair segmentation allows devices to detect human hair in an image or video and apply effects to it;
- It is used in hair dye try-on, social media, photo/video editing apps, etc.
- Follow the instructions below to integrate this feature into your app.
What is hair segmentation?
Hair segmentation is an area of image segmentation application. It analyzes an image to create a pixel-wise mask for hair used to enable a variety of hair modification scenarios or accomplish classification tasks.
The most common applications of this technology is augmented reality (AR) scenarios allowing users to change their hair color in real-time or in photos. It can also be applied for hairstyle or hair color recognition as an initial step for personalized product recommendations.
Banuba Hair Segmentation Before-After Demo
How does hair recognition work?
The core of our detection and segmentation technology is a neural network which returns a binary output, tagging the image pixels to human hair or the background.
The algorithm produces a high-quality two-dimensional hair mask extracted from the input image that is well suited for AR applications, e.g. virtual hair recoloring apps or hairstyle simulators.
Hair dataset
Large hair datasets are hard to obtain, while accurate hair recognition requires high quality, ground data annotations including different hairstyles, hair lengths, and environmental factors. Additionally, one needs to take into account the nature of the images. The algorithms trained on studio-like photos will provide low quality results in real-world user surroundings with inaccuracy in hair makeover masks and hair color changer.
To address these issues, we assembled the balanced hair dataset and perform its ongoing training and improvement.
Our hair segmentation neural network features:
- 'Complex' hair detection tasks to train the neural network effectively on a relatively small initial dataset.
- A variety of settings including backgrounds and low lighting for accurate performance in the real-world user environment.
- Additionally labelled dataset of over 400 images with the most relevant hair recognition results used to assess the hair styles segmentation accuracy.
- Images taken with a selfie camera to ensure high quality performance on mobile devices.
- Hair texture dataset to train the technology to recognize the hair by its structure starting from hair follicles. It provides a more accurate detection results on the ends and enable realistic hair color editor. Hair makeover became reality starting from simple automatic segmentation in images and continuing with future development in hair recognition and hair styles editing datasets.
Use cases of hair segmentation
Hair segmentation finds its application is a variety of augmented reality apps, beauty solutions and hairstyle simulators.
Virtual hair color try on
One compelling application for hair color changer is realistic virtual hair-dyeing technology. Users can test hair color editor product in AR using their mobile or web camera.
Photo and video editing apps
Hair modification is a fun feature in photo and video editing apps. Unlike with e-commerce try on simulators, where you showcase real products, in entertainment apps, the hair recognition tool can be a creative add-on to other face transformation options like beautification or virtual makeup try on.
Hair Segmentation For Photo Processing
Automatic segmentation and hair editing can also be used in avatar apps to detect the user hair and generate a 3D hairstyle. You can integrate it into video chats, live streaming apps, entertainment or beauty editors, or simply as a creative feature of any augmented reality camera app.
Hair segmentation performance
|
Android mid Galaxy S7 |
Android top Google Pixel 3 XL |
iOS mid iPhone 6s |
iOS top iPhone 11 |
FPS (online performance) |
20 |
40 |
17 |
30 |
Speed, seconds (photo process) |
2 |
2 |
<1 |
<1 |
Note
The performance values are given for reference only and were obtained on fixed conditions. The state of device (running applications, battery life, enabled wi-fi, etc.), the environment (e.g. lighting) can somehow affect the actual performance results in your app.
Integration and set up
To integrate hair segmentation into your app:
- Get the latest trial version of Banuba Face AR SDK by submitting the website form. Along with hair segmentation, you'll be able to test other Face AR and Beauty AR features.
- Download the files to compile the Demo app or integrate the SDK into your project. You will receive them in the email.
- Activate the SDK. This is easy to do and takes only a few lines of code. Follow the instructions on our GitHub:
Using hair segmentation dataset, developers can excite users with realistic virtual hair dying experiences while our SDK optimized for mobile, ensures your app stays lightweight and function stably both on iOS and Android. Explore how you can distinguish your app with Beauty AR SDK.