Blog
Hair Recolor

Hair Segmentation for Realistic Virtual Hair Color Try On

Banuba provides a robust hair recognition tool optimized for real-time performance on mobile applications. Explore how hair segmentation works and how you can integrate it into your apps to allow users try on hair colors virtually.

hair segmentation for virtual hair color try on hero

Want to empower your app with hair segmentation? Explore our Beauty AR SDK and get in touch for a free trial!

Start Free Trial

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 hair 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 segmentation work?

The core of our hair 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 innaccuracy in hair segmentation 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:

hair segmentation banuba demo
  • '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 of hair 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 segmentation is realistic virtual hair-dyeing technology. Users can test hair color editor product in AR using their mobile or web camera.

hair recolor 26 releaseHair Segmentation For Real-Time Color Changer 

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 color photo and video editing appsHair Segmentation For Photo Processing

Automatic segmentation of hair 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:

  1.  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.
  2.  Download the files to compile the Demo app or integrate the SDK into your project.
  3.  Activate the token. With the SDK archive, you'll also receive the client token. See how to activate in for iOS and Android.  
  4.  Enable the recognize. Specify 'hair' in the recognizer method to test and implement this feature. Refer to the Documentation Tutorial.
  5.  Test example. You can also download and test our effect examples at the same section.
  6.  Upload custom hair textures. You can design and upload your own hair textures featuring realistic or exotic colors and add them to your app.

 

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.

Explore Beauty SDK

Top