Local Crop Classifier Study
Deep Learning

Local Crop Classifier Study

Agricultural deep learning models trained on perfect, uniform datasets fail catastrophically in real-world farm conditions where lighting, shadows, and occlusions are highly unpredictable.

The Solution

I manually captured and preprocessed 1,200+ photos of regional vegetables under varying wholesale market lighting conditions. I then compared six different convolutional network designs, evaluating lightweight depthwise-separable designs against heavier ResNet configurations. To ensure robustness, I built an OpenCV-based background segmenter and class-balancing filter to isolate organic structures in real-time.

  • Manually captured and preprocessed over 1,200 photos of regional vegetables (Karela, Parwal) in varying wholesale market lighting conditions
  • Evaluated accuracy and hardware latency trade-offs across 6 networks, including depthwise-separable designs
  • Wrote custom OpenCV filters to perform automatic background isolation and HSV color segmentation
  • Configured a Flask web interface to test real-time validation speeds and latency metrics

System Pipeline

Step 01

Camera Input

Chaotic wholesale market crop stream

Step 02

OpenCV Subtractor

Background leaf & shadow isolation

Step 03

HSV Segmenter

Vegetable color segment extraction

Step 04

PyTorch ResNet18

Deep transfer weights category inference

Step 05

Flask Server

Scored softmax metrics outputs

Engineering Trade-offs

Why?I traded absolute top-1 accuracy on pristine images for robust performance on noisy images by employing synthetic minority oversampling (SMOTE) and aggressive affine transformations. I chose depthwise-separable convolutions to guarantee the model could run on low-end hardware, even though it meant sacrificing some edge-case detection capabilities.

Proven Impact

%

Identified optimal network parameters that achieved 92% real-world accuracy while reducing inference latency by 45% compared to default ResNet configurations, making it viable for low-cost edge deployments.

The Constraints

Timeline
8 Weeks
Team
Solo Developer
Core Tech
PyTorch, OpenCV, Flask

Stack

PyTorchResNet18FlaskOpenCVPython