Traditional citrus fruit classification relied on weight-based sorting and manual inspection, often leading to inconsistencies in quality assessment. This research presents an optimized deep learning approach for classifying ripe, semi-ripe, and unripe tangerines using an enhanced YOLOv7-tiny convolutional object detection model. We integrate a custom-designed convolutional block attention module (CBAM) to improve feature extraction and classification performance. This proposed CBAM-enhanced model serves as the teacher in a knowledge distillation framework, guiding a compact student model to achieve high accuracy with significantly reduced computational demands.
The distillation process employs a composite loss function that includes Kullback–Leibler (KL) divergence to align soft probability distributions, mean squared error (MSE) to match intermediate feature maps, and cross-entropy for hard-label supervision. To further optimize the model, structured pruning removes redundant filters, and post-training quantization (PTQ) converts weights and activations from 32-bit floating-point to 8-bit integers, enabling deployment on resource-limited microcontrollers.
The final student model (with CBAM) achieves a classification accuracy of 95.97%, with only a 0.93% drop in accuracy compared to the original YOLOv7- tiny model with accuracy (96.9%). Moreover, the model size is reduced by 31 (from 11,945 KB to 385 KB), and inference latency decreases by 5.25 (from 27.3 ms to 5.2 ms), making it well-suitable for real-time embedded inference. The resulting student model (without CBAM) is trained on a tangerine orchard dataset and deployed on an STM32H743 ARM Cortex-M7 microcontroller, equipped with 2 MB flash memory, a 480 MHz processor, and a DCMI interface for real-time image processing.
Hassanzadeh, F. and Ershadi-Nasab, S. (2026). Real-Time Fine-Grained Tangerine Classification via Knowledge Distillation of an Optimized YOLOv7 Model on STM32H743 Microcontroller. Scientia Iranica, (), -. doi: 10.24200/sci.2026.67287.10541
MLA
Hassanzadeh, F. , and Ershadi-Nasab, S. . "Real-Time Fine-Grained Tangerine Classification via Knowledge Distillation of an Optimized YOLOv7 Model on STM32H743 Microcontroller", Scientia Iranica, , , 2026, -. doi: 10.24200/sci.2026.67287.10541
HARVARD
Hassanzadeh, F., Ershadi-Nasab, S. (2026). 'Real-Time Fine-Grained Tangerine Classification via Knowledge Distillation of an Optimized YOLOv7 Model on STM32H743 Microcontroller', Scientia Iranica, (), pp. -. doi: 10.24200/sci.2026.67287.10541
CHICAGO
F. Hassanzadeh and S. Ershadi-Nasab, "Real-Time Fine-Grained Tangerine Classification via Knowledge Distillation of an Optimized YOLOv7 Model on STM32H743 Microcontroller," Scientia Iranica, (2026): -, doi: 10.24200/sci.2026.67287.10541
VANCOUVER
Hassanzadeh, F., Ershadi-Nasab, S. Real-Time Fine-Grained Tangerine Classification via Knowledge Distillation of an Optimized YOLOv7 Model on STM32H743 Microcontroller. Scientia Iranica, 2026; (): -. doi: 10.24200/sci.2026.67287.10541