DEV Community

Olalekan Fuad Elesin
Olalekan Fuad Elesin

Posted on • Originally published at Medium on

Using artificial intelligence to differentiate between human and synthetic hair wigs with Amazon…

Using artificial intelligence to differentiate between human and synthetic hair wigs with Amazon SageMaker

The hair extensions industry is a multi-billion dollar global industry. According to China Customs, China’s wig exports reached excess of $2 billion dollar, with US being the largest destination. However, wig manufacturers in China are moving focus from US to Africa.

Customer Problem Discovery

After speaking with a handful of ladies, one of the major challenges experienced by shoppers is Trust which is rooted in vendors selling synthetic hair (low quality) and human hair. Also speaking with vendors, it turns out that differentiating between both synthetic hair and human hair wigs can be challenging. One only knows when the hair is made or wig is bought and used. This appears like a classic task for Image Classification.

Implementation

In this tutorial, we will train an image classification model using Amazon SageMaker built-in algorithm. Images are organized in folders named for corresponding classes, human-hair and synthetic-hair.

images\_to\_classify

├── human-hair
│ ├── 1.jpg
│ ├── 2.jpg
| ├── 3.jpg
│ └── . . .
└── synthetic-hair
│ ├── 1.jpg
│ ├── 2.jpg
│ ├── 3.jpg
│ ├── . . .
└── . . .

The sample dataset was scraped from GlamorousHair.com and is available on Amazon S3.

Synthetic and Human Hair wig images. Courtesy: GlamorousHair.com

Hypothesis

If we are able to differentiate between synthetic and human hair wigs with images right before customers complete their purchase, then we can help customers can build trust with hair vendors. We will know that we succeeded if we achieve 65% validation accuracy with our machine learning model.

Jupyter Notebook available below:

OElesin/aws-samples

Hypothesis Validation

Based on the acceptance criterion defined above hypothesis, we can proceed to deploy our model into production. The deployment is completed with the Amazon SageMaker Endpoint.

First run, 10 epochs, with the following accuracy metrics:

  • Train accuracy: 1.000000
  • Validation-accuracy: 0.937500

We also trained on Spot instances saving 69.8% of the cost.

Further model improvements, Amazon SageMaker Automatic Model Tuning will be used. For real-life, constant retraining of the model and evaluation with Human-In-the-Loop with Amazon Augmented AI (Amazon A2I).

Conclusion

This is my first recipe with Amazon SageMaker Studio. A next step might be to train an image segmentation model to identify hair quality at pixel level.

I hope to share more with you. If you enjoyed reading this, kindly share and comment. You can reach me via email, follow me on Twitter or connect with me on LinkedIn. Can’t wait to hear from you!!

Top comments (0)