AYAhmed Yazıcı
← All projects

Case 03 / Computer vision

Segmenting visible pigmentation, pixel by pixel.

A PyTorch U-Net for binary masks of visible dark spots and melasma-like pigmentation in facial images, supported by a complete training, evaluation, and inference pipeline.

  1. 01 / LABELAnnotate imagesMore than 5,000 images marked manually
  2. 02 / LEARNTrain U-NetRGB images paired with binary masks
  3. 03 / PREDICTGenerate masksProbability maps, thresholds, and overlays
  4. 04 / CHECKEvaluate errorsDice, IoU, precision, recall, and per-image review
Dataset preparation
5,000+images manually annotated
Reported test Dice
0.7286at probability threshold 0.5
Reported test IoU
0.5939on the project test set
01 / THE TASK

Find regions, not just a label.

A classification score can say that pigmentation is present, but it cannot show its location. This project predicts a binary mask so the visible regions can be compared with manual annotations at pixel level.

Dataset preparation included manually annotating more than 5,000 images. That work matters because the model learns the boundary and coverage of regions from the masks supplied to it.

02 / PIPELINE

From images to inspectable masks.

The network uses a four-stage U-Net encoder and skip-connected decoder with bilinear upsampling, a 64-channel base width, one output channel, and 640 × 640 RGB input. Training combines binary cross-entropy and Dice loss.

  • Paired image-mask loading keeps training and evaluation examples aligned.
  • Evaluation calculates aggregate Dice, IoU, precision, recall, and F1.
  • Per-image IoU ranking helps locate examples where the model and annotation disagree.
  • Inference can produce a binary mask and a red overlay for one image or a directory.
  • The repository includes inference weights and an optional API that processes uploaded images in memory.
03 / RESULTS & EXAMPLES

Look at both agreement and failure.

The repository reports evaluation on a 200+ image test set at a probability threshold of 0.5.

MetricReported valueWhat it captures
Dice0.7286Overlap between predicted and reference masks
IoU0.5939Intersection over union of mask regions
Precision0.7619How much predicted area matches the reference
Recall0.7525How much reference area is found
F10.7571Balance of precision and recall
Original face image, reference mask, predicted mask, and overlay for a higher-agreement example
Example with IoU 0.7468 and Dice 0.8551.
Original face image, reference mask, predicted mask, and overlay showing over-segmentation and missed regions
Challenging example with IoU 0.2717 and Dice 0.4273.

Example image source: dark spots — v1_clean_640_dark_spots, CC BY 4.0. Prediction grids and metrics are from this project.

04 / LIMITATIONS

Segmentation is not diagnosis.

These metrics describe performance on the project's test set and do not establish reliability across all lighting, image quality, skin tones, or capture conditions. Individual examples show that agreement can vary substantially, with over-segmentation and missed regions in difficult images.

Scope. This model is intended for computer-vision research and education. It is not a medical device or diagnostic tool. The annotated training data are not distributed in the repository.