website logo
← back to writing
Apr 2025 · 9 min read · AI / AWS

Dermatech-Compass: AI Skin Analysis with AWS Bedrock and Knowledge Bases

A walkthrough of building a multi-stage skin health analyser that takes a photo or video selfie, scores skin across three parameters, and generates personalised recommendations grounded in a curated knowledge base.

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

  1. Face analysis — Nova Pro vision model examines the image/video and returns a structured skin assessment.
  2. Skin scoring — Nova Micro scores hydration, texture, and aging on a 1–10 scale with a one-line explanation per parameter.
  3. Recommendations — A Knowledge Base RAG call generates 2 product recommendations and 1 dietary suggestion grounded in curated content.
STACK
Python · AWS Bedrock (Nova Pro + Nova Micro) · Bedrock Knowledge Base · Gradio · Docker · AWS Lambda · S3

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:

Each score comes with a one-line explanation, keeping the downstream step accurate.

DESIGN NOTE
Using Nova Micro for scoring (not Pro) saves significant cost at scale. The scoring task doesn't require vision capability — it's pure text-in, text-out — so there's no reason to pay for the larger model here.

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

What's Next


Source code: github.com/omishagupta/Dermatech-Compass