Fruit Fly Classification (Diptera: Tephritidae) in Images, Applying Transfer Learning
Erick Andrew Bustamante Flores, Harley Vera Olivera, Ivan Cesar Medrano Valencia, Carlos Fernando Montoya Cubas
TL;DR
This work tackles automated identification of two Tephritidae fruit fly species (Anastrepha fraterculus and Ceratitis capitata) by applying transfer learning to segmented dorsal images captured via a stereomicroscope and smartphone. A dataset of 572 balanced images was prepared after segmentation, cropping, and centering to 400×400, and three pretrained CNNs (VGG16, VGG19, Inception-V3) were trained with data augmentation and Grad-CAM for explainability. Inception-V3 achieved the best macro-F1 of $0.93$ with a fast classification time of $15.04$ seconds on 148-test images, and Grad-CAM showed its attention aligned with key morphological regions such as wings and thorax; however, generalization to web-sourced, uncontrolled images was limited (macro-F1 ≈ $0.69$). The study provides an original, reproducible dataset and a transfer-learning pipeline suitable for integration into automated monitoring systems, offering improved speed and accuracy for pest population assessment. Overall, Inception-V3 demonstrates strong potential for real-time, AI-assisted taxonomic classification in agricultural biosecurity contexts, with future work focusing on broader data diversity to enhance robustness.
Abstract
This study develops a transfer learning model for the automated classification of two species of fruit flies, Anastrepha fraterculus and Ceratitis capitata, in a controlled laboratory environment. The research addresses the need to optimize identification and classification, which are currently performed manually by experts, being affected by human factors and facing time challenges. The methodological process of this study includes the capture of high-quality images using a mobile phone camera and a stereo microscope, followed by segmentation to reduce size and focus on relevant morphological areas. The images were carefully labeled and preprocessed to ensure the quality and consistency of the dataset used to train the pre-trained convolutional neural network models VGG16, VGG19, and Inception-v3. The results were evaluated using the F1-score, achieving 82% for VGG16 and VGG19, while Inception-v3 reached an F1-score of 93%. Inception-v3's reliability was verified through model testing in uncontrolled environments, with positive results, complemented by the Grad-CAM technique, demonstrating its ability to capture essential morphological features. These findings indicate that Inception-v3 is an effective and replicable approach for classifying Anastrepha fraterculus and Ceratitis capitata, with potential for implementation in automated monitoring systems.
