Why Skin Analysis?
Good skincare advice is surprisingly hard to come by. Dermatologist appointments are expensive and often booked out weeks in advance. Generic product recommendations from brands are obviously biased. And most AI chatbots giving skincare advice are doing it from training data alone, with no grounding in actual product or clinical knowledge.
I wanted to explore whether a combination of vision AI and retrieval-augmented generation could produce something genuinely useful — a credible first-pass analysis that tells you something real about your skin and points you toward the right kind of products and habits.
That's Dermatech-Compass. Three-stage pipeline: detect and analyse, score, recommend. Every stage runs on AWS Bedrock. The recommendations are grounded via a Knowledge Base rather than hallucinated from training data.
The Three-Stage Pipeline
- Face analysis — Nova Pro vision model examines the image/video and returns a structured skin assessment.
- Skin scoring — Nova Micro scores hydration, texture, and aging on a 1–10 scale with a one-line explanation per parameter.
- Recommendations — A Knowledge Base RAG call generates 2 product recommendations and 1 dietary suggestion grounded in curated content.
Stage 1: Face Detection and Skin Analysis
The first call goes to amazon.nova-pro-v1:0. The system prompt sets the role:
an AI-powered skin analyst specialising in hydration, texture, and aging detection.
The user prompt asks it to assess hydration, dark circles, acne, discolouration,
and signs of aging — and return estimated gender and age alongside findings.
If no qualifying face is detected, the model returns a single word: NOFACE.
This sentinel value propagates through the rest of the pipeline — each subsequent stage
checks for it and short-circuits cleanly rather than generating nonsense output.
Handling image vs video
The app supports both image uploads (numpy arrays from Gradio) and video uploads (file paths). Both get base64-encoded and slotted into the appropriate Bedrock content block. There's also a Lambda version triggered by S3 events — useful for async batch workflows where you don't want a user waiting for a response.
Stage 2: Skin Scoring
The analysis text goes to amazon.nova-micro-v1:0 — fast and cheap for a
scoring task that's pure text-in, text-out. Scores are returned on three parameters:
- Skin Hydration — how well-moisturised and plump the skin looks
- Texture Analysis — smoothness, evenness, presence of acne or scarring
- Skin Aging — wrinkles, puffiness, overall youthfulness
Each score comes with a one-line explanation, keeping the downstream step accurate.
Stage 3: Knowledge Base Recommendations
Instead of asking the model to generate recommendations from training data alone, the
final stage uses Bedrock's retrieve_and_generate API against a Knowledge Base.
The KB contains curated content about skincare ingredients, product categories, and dietary
factors. Bedrock retrieves the most relevant chunks, then uses them to ground the output.
Output is always: 2 product recommendations + 1 dietary suggestion + an AI disclaimer.
What I Learned
- RAG matters for recommendations. Early versions without the Knowledge Base produced generic advice. The grounded version gives specific ingredient guidance that varies based on input scores.
- The NOFACE sentinel pattern is underrated. A clear, propagatable signal for "this input is invalid" made error handling across three stages trivial.
- Nova Pro for vision, Nova Micro for text-only tasks. The cost difference is significant — for any task that doesn't require image understanding, drop down to Micro.
- Gradio's progress callback reduces perceived latency. Users tolerate a ~10s wait much better when they can see which stage is running.
What's Next
- Expand the Knowledge Base with ingredient-level data and skin type profiles.
- Add longitudinal tracking to show skin health trends over time.
- Integrate a product search API so recommendations link to purchasable products.
- Build a mobile wrapper that triggers the Lambda path directly from camera.
Source code: github.com/omishagupta/Dermatech-Compass