LookMate
Finds the landmarks of a face in a photo or webcam frame, labels its shape, suggests hairstyles and beards that suit it, and overlays them on the face.
- Python 80%
- JavaScript 17%
- CSS 3%
- HTML <1%
live from github.com/the-wilful-youth/LookMate, refreshed daily
The problem
Choosing a haircut or a beard usually starts with "what suits my face?", and most people don't know their face shape. LookMate puts a face into one of five shapes (oval, round, square, heart, oblong), gives style advice for that shape, and lets you preview a style on your own face before committing to it.
How it works
This describes the Streamlit version, which is the one that ran end to end (up to commit 755bdc9).
webcam frame or uploaded photo
-> MediaPipe FaceMesh: 468 landmarks
-> Keras classifier on a padded face crop
(falls back to a length / jaw-width ratio)
-> face shape
-> recommendation engine: advice + matching styles
-> pick a style -> PNG placed on landmarks, alpha-blended
-> frame shown in the browser
The webcam loop runs detection and the overlay on every frame. Advice lives in a rule table keyed by face shape, so recommendations are predictable and easy to edit, not learned.
Two decisions
A model, with geometry behind it. Face shape came from separate Keras models for male and female faces. If a model failed to load or threw an error, the code fell back to one ratio, face length to jaw width, cut at hand-picked thresholds (1.6, 1.4, 1.2). For a while the models were dropped completely in favour of geometry alone, for speed, and then brought back. The fallback kept the app working on any machine; the cost is that a fresh clone has no model files and silently uses the cruder rule.
Overlays from proportions, not a fitted transform. A hairstyle or beard is placed using five landmarks (forehead, chin, both cheeks, lips) and scaled as a fixed multiple of face width. A proper warp from landmark pairs would follow head tilt; fixed multiples don't, but they are simple and fast enough to run on every frame.
What broke
Beards sat too low on the chin. The fix (commit 755bdc9) moved the beard anchor up from +0.05 to −0.25 of face height and widened it from 0.9× to 1.1× of face width, and split hair sizing by gender. The numbers were tuned by eye, from feedback that literally said "more up".
Where it stands
The last change moved the project from Streamlit to a React front end and a FastAPI back end. That port was never finished: in the current code the detector is a placeholder that always answers "oval", and the React app has no try-on overlay yet. The working version is the Streamlit one in the history.