DEV Community

Cover image for Building an AI hairstyle analyzer: why generating hairstyles was the easy part
Jammy Lee
Jammy Lee

Posted on

Building an AI hairstyle analyzer: why generating hairstyles was the easy part

AI image generation has gotten surprisingly good.

Give a model a portrait and a hairstyle description, and it can produce an image convincing enough to share within seconds.

When I started building HairstyleAnalysis.com, I assumed generation would be the hard part.

It wasn't.

The harder question was more practical:

Would this hairstyle actually suit me?

That question changed how I approached the product.

Rather than make another hairstyle generator, I began treating it as a tool that helps people make a decision.

Here are the product and engineering lessons I learned while building it.


People want more than an AI image

The first version of the workflow seemed obvious:

Upload selfie
    ↓
Choose hairstyle
    ↓
Generate image
    ↓
Download
Enter fullscreen mode Exit fullscreen mode

It works technically, but it does not resolve the whole problem.

Someone considering a new hairstyle usually wants answers to questions like:

  • What face shape do I have?
  • Would short hair suit me?
  • Should I keep my forehead exposed?
  • Should I try bangs?
  • Which hairstyles make my face look more balanced?
  • Which styles should I avoid?
  • What hair color works with my skin tone?
  • How do I explain the hairstyle I want to my barber or stylist?

The generated image helps, but it is only part of the decision.

The journey looks more like this:

Understand myself
    ↓
Discover suitable options
    ↓
Compare alternatives
    ↓
Visualize the result
    ↓
Make a decision
Enter fullscreen mode Exit fullscreen mode

The product is not generation itself. It is reducing uncertainty around a hairstyle decision.


Problem 1: Face shape classification is not enough

Many hairstyle recommendation systems start with face shape:

Oval face → hairstyle A
Round face → hairstyle B
Square face → hairstyle C
Enter fullscreen mode Exit fullscreen mode

That is easy to understand and implement. It is also incomplete.

Two people can have similar face shapes yet need very different recommendations because of their:

  • forehead proportions
  • hairline
  • hair density
  • hair texture
  • current hair length
  • facial proportions
  • styling habits
  • overall visual style

The problem is closer to this:

Face shape
+ Forehead
+ Hairline
+ Hair texture
+ Hair density
+ Current hairstyle
+ Facial proportions
+ Style direction
-----------------------
Hairstyle recommendations
Enter fullscreen mode Exit fullscreen mode

Once you write it down, the difference is obvious, but it changes the product architecture. The question is no longer:

"What class does this face belong to?"

It becomes:

"Given a set of visual characteristics, which options are likely to work best for this person?"

That calls for recommendations instead of classification alone.


Problem 2: Image models like to make people "better"

One of the stranger parts of AI hairstyle generation is that image models often try to improve everything.

Ask a model to change the hair and it may also change:

  • the jawline
  • the eyes
  • the nose
  • the skin
  • the age
  • the makeup
  • the lighting
  • even the perceived ethnicity

The result can look fantastic, but it may no longer look like the same person.

That may be fine for creative generation. It is a major failure for a product meant to inform a decision.

Imagine a user trying a haircut and thinking:

"This looks amazing on me."

What they may actually be seeing is:

New hairstyle
+ better skin
+ different facial structure
+ professional lighting
+ subtle beauty transformation
Enter fullscreen mode Exit fullscreen mode

They are judging an AI-enhanced version of themselves rather than the hairstyle.

For a consumer decision tool, preserving the person's identity can matter more than making the image beautiful.

A less polished image is more useful if it still looks like the user.


Problem 3: A beautiful output can still be a bad product

Suppose the AI returns this:

A highly realistic photo of the user with a new hairstyle.

Technically, that is a successful output. The user may still be left asking:

"Okay... so which hairstyle should I actually choose?"

That made the presentation nearly as important as the model. Instead of returning only generated images, I started experimenting with a structured visual analysis:

FACE ANALYSIS
- Face shape
- Forehead proportions
- Hair texture
- Hair density

BEST HAIRSTYLES
- Recommendation #1
- Recommendation #2
- Recommendation #3

NOT RECOMMENDED
- Style #1
- Style #2
- Style #3

HAIR LENGTH
- Short
- Medium
- Long

PARTING & FRINGE
- No bangs
- Curtain bangs
- Side part

HAIR COLOR
- Suggested colors
Enter fullscreen mode Exit fullscreen mode

The user should be able to see the result and understand which directions to explore.

That turns an AI-generated image into a decision aid.


My current mental model for the pipeline

At a high level, the workflow looks like this:

User uploads portrait
        ↓
Image validation
        ↓
Visual feature analysis
        ↓
Structured user attributes
        ↓
Hairstyle recommendation
        ↓
Recommendation ranking
        ↓
Prompt construction
        ↓
Image generation
        ↓
Identity / consistency checks
        ↓
Visual report composition
        ↓
Final recommendation
Enter fullscreen mode Exit fullscreen mode

Each step addresses a different part of the problem.

Image validation

Before doing anything expensive, the system has to decide whether an image is usable. For example:

  • Is there a visible face?
  • Is the face large enough?
  • Is the image too blurry?
  • Is the subject heavily occluded?
  • Are there multiple people?

Poor input produces poor recommendations, regardless of the model.


Structured outputs make everything easier

I also learned not to pass freeform model responses directly from one step to another.

Instead of asking a model to return something like:

"The user seems to have an oval face with medium density straight hair and would probably suit..."

I prefer an output conceptually closer to this:

{
  "face_shape": "oval",
  "hair_texture": "straight",
  "hair_density": "medium",
  "forehead": "medium",
  "recommended_length": [
    "medium",
    "long"
  ],
  "recommended_styles": [
    {
      "name": "Curtain Layers",
      "reason": "Adds movement while maintaining balanced facial proportions"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Structured data gives the application more control. It makes it easier to:

  • rank recommendations
  • localize the product
  • generate consistent UI
  • regenerate individual sections
  • test recommendation quality
  • switch models later

This mattered even more as I expanded into more languages. When the model writes the final copy every time, localization gets messy fast. When the recommendation is structured, the presentation layer can handle the rest.


Consistency beats creativity

Image models are built to create variation. In a decision tool, users usually want the opposite.

Imagine uploading the same photo twice and receiving completely different advice:

Run 1:
Best hairstyle → French Crop

Run 2:
Best hairstyle → Medium Curtain Hair

Run 3:
Best hairstyle → Buzz Cut
Enter fullscreen mode Exit fullscreen mode

All three answers might be plausible, yet the product would feel unreliable.

This is a recurring issue in consumer AI products. A model may be probabilistic, but the product cannot feel random.

Use AI for judgment, but use software for consistency.

That means keeping as much deterministic logic as possible outside the generative model:

AI:
Extract visual attributes

Application logic:
Normalize attributes
Filter impossible options
Apply recommendation rules
Rank candidates

AI:
Explain the recommendation naturally
Enter fullscreen mode Exit fullscreen mode

An AI product does not need another prompt for every part of the job.


Users need reasons as well as recommendations

Compare these two outputs.

Version A

Recommended hairstyle: Textured Crop

Version B

Recommended hairstyle: Textured Crop

The added texture creates vertical volume while keeping the sides relatively compact, which can help create a more balanced facial silhouette.

The second is more useful because it gives the user a mental model.

They can bring that explanation to a stylist:

"I want more volume here, but I don't want too much width on the sides."

Tell users what to choose and why.

Explainability matters when the recommendation affects how someone will look in real life.


The model is only one layer of the product

It is easy to obsess over model selection.

Should I use Model A or Model B?

Should I switch to the newest image model?

Is this benchmark 8% better?

Those questions matter. After building the product, though, I have become more interested in everything around the model:

Model capability
× Input quality
× Prompting
× Product constraints
× Output consistency
× UX
× Trust
Enter fullscreen mode Exit fullscreen mode

If any one of those approaches zero, a good model will not save the product. A state-of-the-art image model in a confusing workflow still makes for a confusing product.


A better question for consumer AI products

This project changed the question I ask when I evaluate a new AI capability.

Instead of asking:

"What can this new model generate?"

I ask:

"What consumer decision used to be too difficult for software, but has suddenly become possible because of this model?"

Hairstyles are one example. The same pattern applies to:

  • interior design
  • clothing
  • makeup
  • glasses
  • hair colors
  • tattoos
  • furniture
  • landscaping
  • cosmetic treatments

In each case, users are not primarily looking for content. They are trying to make a real-world decision. Generative AI may reduce some of the uncertainty beforehand.

That is more interesting to me than generation for its own sake.


What I would do differently if I started again

If I rebuilt the project from scratch, I would spend less time chasing perfect generations at the start and focus earlier on three things.

1. Define the decision first

Before writing prompts or integrating models, define the uncertainty you are trying to remove:

What exact uncertainty am I removing for the user?

For this project:

Bad goal:
Generate hairstyle images.

Better goal:
Help someone decide what hairstyle to get.
Enter fullscreen mode Exit fullscreen mode

The wording looks like a small change, but it is not.


2. Design the output before the pipeline

Rather than start with the model and ask what I could display, I would design the ideal result first:

What would someone want to show their hairstylist?
Enter fullscreen mode Exit fullscreen mode

Then I would work backward. That leads to a better product architecture.


3. Treat AI output as unreliable input

AI models can produce surprisingly good answers and surprisingly strange ones.

Treat model output as you would any external API response:

Validate it.
Normalize it.
Constrain it.
Handle failures.
Enter fullscreen mode Exit fullscreen mode

Adding a language model does not remove the need for software engineering. It often increases it.


Where the project is now

I eventually turned these ideas into HairstyleAnalysis.com.

The product now explores related appearance decisions, including hairstyle analysis and hairstyle visualization. I am continuing to experiment with hair color and other visual recommendation experiences.

The central challenge is still the same: how do you turn increasingly capable generative models into something people can trust when making a decision?

I do not think the answer is simply better prompts or larger models. Product design, constraints, consistency, and a clear view of the decision the user is trying to make all matter.

If you are building consumer AI or image-generation products, I would love to hear how you approach these problems.


Top comments (0)