← Back to Writing
Computer VisionYOLOPyTorchMedical AI

90%+ Accuracy Acne Detection with YOLO: What Actually Worked

April 15, 2025·7 min read

Medical image AI gets a lot of hype. Here's the unglamorous version: how I actually got a YOLO-based acne segmentation model to 90%+ accuracy.

The dataset problem

The first problem with any medical imaging project is data. We had ~2,000 annotated images — enough to train, not enough to generalize without careful augmentation.

Key augmentations that helped: - Horizontal flip (skin is symmetric) - Color jitter (lighting varies massively across phone cameras) - Random crop with padding (faces appear at different scales) - Gaussian blur (simulates out-of-focus shots)

Augmentations that hurt: - Vertical flip (faces always have a fixed orientation — this confused the model) - Extreme rotation (same reason)

YOLO configuration

We used YOLOv8 for segmentation. Key config decisions:

model: yolov8m-seg.pt  # Medium, not large — overfits on 2k images
epochs: 150
patience: 20
imgsz: 640
batch: 16
lr0: 0.01
lrf: 0.01
mosaic: 0.5  # Reduced from default 1.0

The mosaic augmentation at full strength was creating unrealistic compositions that hurt validation performance. Halving it helped.

The 90% number

"90% accuracy" is a lazy metric for segmentation. What we actually measured: - **mAP50**: 0.91 (good) - **mAP50-95**: 0.74 (acceptable) - **Mask IoU**: 0.82 (the metric that actually matters for segmentation quality)

For the clinical use case — helping dermatologists assess severity, not replacing diagnosis — these numbers were sufficient.

Deployment

FastAPI served the model with a simple REST endpoint. React frontend handled webcam capture and image upload. Docker Compose tied it together.

The biggest deployment challenge wasn't the model — it was GPU memory. YOLOv8m needs ~4GB VRAM for inference. On the target deployment environment (shared GPU), we had to batch requests and queue them. Solved with a simple Redis queue and a worker process.

Lessons

  1. 1.Start with the smallest model that achieves your target metric
  2. 2.Measure the right thing (IoU, not accuracy)
  3. 3.Deployment constraints should inform model choice from day one

Working on something similar? I'm available for consulting and contracts.

Get in touch →