← All Case Studies

Skin AI BD

Advanced Medical Image Diagnostics

1. Core Problem & Scope

Dermatological tracking suffers from high visual variance, low training set availability, and steep computational resource constraints for deployment on localized mobile hardware. The scope was a multi-class skin condition classifier accurate enough to be clinically useful, small and fast enough to run inference directly on-device rather than requiring a round trip to a cloud GPU.

2. Comparative System Research

  • Full-size ResNet/EfficientNet trained from scratch — strong accuracy ceiling, but the parameter count and compute footprint are incompatible with the mobile edge-inference requirement.
  • Direct knowledge distillation to a small CNN — gets the size down, but plain CNN students without an attention mechanism underperformed on the fine-grained visual differences between condition classes in early trials.
  • DeiT with distillation tokens against a ResNet-101 teacher (chosen) — a data-efficient vision transformer specifically designed for distillation-based training, giving transformer-level representational capacity at a size and latency compatible with mobile inference after quantization.

3. Architectural Pipeline Layouts

Clinical Image Capture → Albumentations Augmentation → DeiT + ResNet-101 Teacher → Distillation Training → INT8 Quantization (TensorRT) → Edge Inference

A ResNet-101 teacher model, trained on the full available dataset, transfers its learned representations to a DeiT student via distillation tokens during training. Class imbalance — inherent to medical imaging datasets, where common conditions vastly outnumber rare ones — is addressed through Albumentations-based augmentation: synthetic artifact insertion, elastic transforms, and CLAHE contrast adjustment applied disproportionately to minority classes. The trained student is then post-training quantized to INT8 and compiled with TensorRT for edge inference.

4. Trade-off Engineering Logs

Why distillation instead of training the small model directly: Training a small model directly on a class-imbalanced, relatively limited medical imaging dataset underperformed the distillation approach by a wide margin in early experiments — the teacher's representations, learned from the same data but with far more capacity to generalize, transfer better than what the small model could learn on its own from raw labels.

INT8 over FP16 for the deployment target: FP16 alone didn't hit the latency budget on the target mobile hardware profile. INT8 was necessary, which meant accepting the calibration overhead and validating accuracy didn't regress meaningfully post-quantization — done via a held-out clinical validation set checked specifically after the quantization step, not just after training.

5. Scaling & Production Failures

The first quantization pass produced an unacceptable accuracy drop on the rarest classes — exactly the classes where clinical sensitivity matters most. Root cause traced to the calibration set not containing enough examples of minority classes, causing TensorRT to pick quantization ranges poorly suited to their activation distributions. Rebalancing the calibration set to over-represent minority classes relative to their natural frequency resolved the regression. A separate deployment issue arose from device fragmentation — INT8 support varies across mobile hardware generations — requiring a runtime capability check with an FP16 fallback path for devices without full INT8 support.