All work

Stanford CS 129 · Course project under Andrew Ng

Bridging skin tone classification with fair cosmetics recommendation.

Skincare recommenders usually rank products by visible concerns like acne or dryness and leave skin tone out, so the same product can be recommended to someone it will leave with a white cast. I built a pipeline that predicts Fitzpatrick skin type from a photo with a fine-tuned ResNet50, then ranks about 8,500 Sephora products with an ingredient scoring system weighted for that skin type.

Context
CS 129, Stanford, solo project
Model
Fine-tuned ResNet50, six-class
Data
Fitzpatrick17k, FairFace, Sephora
Stack
PyTorch, torchvision, scikit-learn, pandas

Problem

Skin tone changes how a product behaves on skin. Mineral filters and reflective particles can leave a white cast on deeper skin, and some actives raise the risk of post-inflammatory hyperpigmentation. Yet most AI skincare tools classify conditions or ask for a predefined skin type, and never model tone.

Dermatology models also tend to perform worse on skin they rarely saw in training. Adamson and Smith (JAMA Dermatology, 2018) trace this to datasets drawn mostly from lighter skin, which is why this project treats fairness as part of the problem from the first dataset onward.

Approach

Recent work splits into clinical skin analysis with deep learning and AI product recommenders that classify conditions before suggesting products (Lee et al., 2024; Hanchinal et al., 2024). Few combine the two, and fewer model how ingredients interact with different skin. This project joins them: a learned skin tone prediction feeds a structured, interpretable ranking built on cosmetic chemistry (Draelos, 2016).

How it works

Seven steps, from a photo to a ranked shelf. Step through them, or let the first one play.

Data

  • 12,222Fitzpatrick17k images after cleaning, split 70 / 10 / 20 into train, validation and test
  • 100K+FairFace faces, mapped to Fitzpatrick types with a heuristic from the labels FairFace provides
  • 75 / 25FairFace to Fitzpatrick17k in each training batch, trading diversity against label accuracy
  • 224 × 224input size, normalized with ImageNet statistics
  • 1,500images per epoch, sampled by class to temper imbalance
  • 8,500Sephora products from Kaggle, each with its ingredient list

Augmentation: horizontal flips, rotations, and color jitter on brightness, contrast, saturation and hue.

Model and ranking

Classifier

ResNet50, fine-tuned end to end

Each image becomes a 2,048-number feature vector capturing texture, color distribution and lighting. A linear layer and a softmax give a probability for each of the six types. Training used cross-entropy, Adam at a learning rate of 0.001, learning rate scheduling, and early stopping.

Recommender

Ingredient compatibility, by skin type

Each ingredient adds to four dimensions: reflectivity, pigment depth, irritation potential and dullness, weighted by its position in the list. Type-specific multipliers then reweight each dimension, so reflectivity counts more on deeper skin. Lower scores are better.

ŷ = softmax(W h + b)

Concern(P) = Σj wj · cj

Score(P, f) = αf · Reflectivity + βf · Pigment + γf · Irritation + δf · Dullness

Results

The classifier reached 45.8% validation and 37.3% evaluation accuracy on six classes, where chance is 16.7%. Most errors fall between neighboring types, which reflects how continuous skin tone really is. Accuracy held steady across gender but ranged from 38% to 52% across ethnic groups, so dataset composition still shaped the model.

On the recommendation side, the scoring produced compatibility scores for over 70% of products, enough to filter and rank the shelf for each predicted type.

F1 score by Fitzpatrick type

1,000 FairFace validation images. Type III, the best represented, scores highest.

Type I
0.20
Type II
0.26
Type III
0.53
Type IV
0.17
Type V
0.39
Type VI
0.36
Per-class metrics
TypePrecisionRecallF1Images
Type I0.1680.2500.20164
Type II0.2470.2820.26378
Type III0.4410.6690.531284
Type IV0.5000.0990.165294
Type V0.3360.4600.388202
Type VI0.4770.2920.36272

Overall accuracy 37.3%, macro F1 0.319, weighted F1 0.339.

Recommendations by skin type

The same shelf, ranked for each type. Pick a type to see the best, middle and weakest foundation and sunscreen from the project's results.

What I learned

Labels set the ceiling.

Fitzpatrick types sit on a continuous spectrum, and the labels are subjective, so adjacent types blur. Better architectures matter less than clearer label definitions and more balanced data.

Domain knowledge makes it explainable.

A hybrid of learned features and ingredient chemistry gives a reason behind every ranking, which a purely data-driven recommender cannot.

Fairness has to be measured.

Adding FairFace improved diversity, yet accuracy still varied by 14 points across ethnic groups. Reporting it by group is what made the gap visible.

Next steps.

Vision transformers, multi-task learning across skin tone and skin conditions, a larger ingredient database validated with dermatologists, and user feedback to personalize further.

Poster

Research poster: Beauty, but Make it Tech. Bridging Skin Tone Classification with Fair Cosmetics Formulation and Recommendation, covering motivation, approach, data, model, results, and per-skin-type product recommendations
Click to open the poster at full size.