


Challenge
Quality checks in Sri Lankan salterns are done by eye under ambient light. It is slow, varies between inspectors and shifts, and leaves no quantitative record for export buyers. No annotated dataset of Sri Lankan salt crystals existed, and outdoor light, translucent crystals and specular glare make the problem hard for off-the-shelf models.
Approach
I built a dataset from field capture at Puttalam salterns: 650 images annotated in Label Studio and CVAT, expanded to 1,952 through augmentation. After benchmarking MobileNetV2, ResNet-50 and YOLOv8, I chose a YOLOv8 detector, exported it to ONNX and served it from a NestJS microservice with gRPC contracts, MongoDB persistence and Socket.io streaming to a Next.js operator dashboard. An HSV whiteness index and a class-weighted composite score turn detections into one actionable grade.
Results
On a held-out test set the model reached 99.41% precision, 99.14% recall and 99.37% mAP@0.5, catching 99.67% of impure salt, the class that matters most for product quality. The full pipeline runs in under 50 ms per frame at 5 FPS on CPU-only hardware, and the composite score tracks expert judgement with a Spearman correlation above 0.92.
