Of which at the third instar, the external morphology of larvae is quite similar; thus, the morphological identification used to differentiate between its genera or species, generally includes cephalophalyngeal skeleton, anterior spiracle, and posterior spiracles. The morphology of the posterior spiracle is one of the important organs for identification. A typical morphology of the posterior spiracle of third stage larvae was shown in Figure 2. Their morphological characteristics were like the descriptions in the previous reports [15–16]. Based on studying under light microscopy, the posterior spiracle of M. domestica was clearly distinguished from the others. On the other hand, the morphology of the posterior spiracle of C. megacephala and A. rufifacies was quite similar.
For model training, four of the CNN models used for species-level identification of fly maggots provided 100% accuracy rates and 0% loss. Params, model speed, macro precision, macro recall, f-1 score, support value, and model size were also presented in Table 1. As the results in Figure 3 presented, all models provided 100% accuracy and 0% loss in the early stage of training (<10 epochs). This may be due to the training and testing processes with cropping specific portion of the fly images by using our custom object detection model. Moreover, all images were from the laboratory strains, which their variation of morphological characteristics may be less than wild type. Therefore, training time was short, and accuracy of the model was high. Of the four models tested, AlexNet demonstrated a good balance between performance and speed. This model can proceed the system the fastest and its model size is the smallest. The speed and accuracy of AlexNet make it useful for web-based and mobile applications that rely on both speed and reliable predictions. Speed is a factor in user satisfaction and will be important for future development such as video-based applications [14]. Therefore, we focus on the AlexNet results for the remainder of this article.
Table 1
Comparison of model size, speed, and performance of each studied model (The text in bold indicates the best value in each category.)
Model | #Params (million) | Model speed (sec) | Model size (mb) | Macro precision | Macro recall | f1-score | support |
Resnet101 | 44.6 | 246.0 | 170.96 | 1.00 | 1.00 | 1.00 | 3388 |
Densenet161 | 14.2 | 326.4 | 55.33 | 1.00 | 1.00 | 1.00 | 3388 |
Vgg19_bn | 20.6 | 210.0 | 78.67 | 1.00 | 1.00 | 1.00 | 3388 |
AlexNet | 2.7 | 10.8 | 10.58 | 1.00 | 1.00 | 1.00 | 3388 |
The AlexNet model can separate species explicitly into distinct groupings based on characteristics extracted from the model (Figure 4). The results showed that some data of C. megacephala overlapped the data of C. rufifacies. The visualization of the hidden convolutional layers in four example images of AlexNet is clearly shown in Figure 5.
The classification results (validation and test) for each image are displayed in the confusion matrices (Figure 6) which show how predicted species (columns) correspond to the actual species (rows). The values along the diagonal indicate the number of correct predictions, whereas off-diagonal values indicate misclassifications. Interestingly, no misclassification was found after testing the model by using the test images (Figure 6A). Therefore, the results indicated that the predictions of AlexNet model match the taxonomic expert classification. To confirm the results of this study, we tested this model with other images from outsources (internet and personal contact) and visualized the results using the PyTorch CNN visualizations [17]. The confusion matrix showed misclassification between C. megacephala and C. rufifacies (Figure 6B), corresponding to the results of tSNE visualization. When the model was tested with the outsource images, the accuracy of the classification for C. megacephala, C. rufifacies, L. cuprina, and M. domestica was 94.94, 98.02, 98.35, 100%, respectively (Figure 6B). The results from using the Heatmap program showed that the prediction accuracy of this model was still high (99.30-100%), depending on image conditions (Figure 7). The Framework of AlexNet model was demonstrated in Figure 8. Previously, CNNs have been used successfully to identify different cells or species [6, 8, 14, 18–19]. This study also confirmed the efficiency of CNNs in identifying fly species.
Finally, we created a web application called “The Fly” by using our classification model for identifying species of fly maggots. The web application is available at https://thefly.ai. Users can identify species of fly maggot by uploading their images of posterior spiracles and the result with associated probability percentage will then be shown. This web application can be accessed and used on both desktop and mobile browsers. In terms of performance limitations, this web application was designed to identify only four species of fly maggot using images of posterior spiracles. This web application is the beginning step of the development of automatic species-identification for fly species in Order Diptera. More images of these four species and other species must be studied in the future. In addition, the results from this study will be applied to develop a feature as a microservice for the identification of fly maggots in a mobile application called iParasites which is currently available on AppStore and GooglePlay. We, nonetheless, wish to project that taxonomic experts are still important and critical for the development of this automatic identification by AI-based imaging system as mentioned in a previous report [20].