Evaluation of deep convolutional neural network models for the identification of fly maggot species of forensic significance based on images of posterior spiracles

Of which at the third stage, the external morphology of the larvae is quite similar; thus, the morphological identification used to differentiate its genera or species usually includes the cephalopharyngeal skeleton, anterior spiracle, and posterior spiracles. The morphology of the posterior stigma is one of the important characteristics for identification. A typical morphology of the posterior part of the spiracle of third instar larvae has been shown in Fig. 2. Based on the optical microscope study, the posterior part of the spiracle of M. domestica clearly stood out from the others. On the other hand, the morphology of the posterior spiracle of C. megacephalus and A. rufifacies was quite similar. For C. megacephalus and C. rufifacies, the peritreme, a structure encircling the three spiracular openings (slits), was incomplete and the slits were straight, as shown in Figs. 2A, B, respectively. The complete peritreme encircling three slits was found in L.cuprina and M. domestica as shown in Figs. 2C, D, respectively. However, only the slits of M. domestica were curvy like the letter M (Fig. 2D). Their morphological characteristics found in this study were like the descriptions in previous reports23,24,25.

Figure 2

Morphology of the posterior spiracles of four different fly species after image color inversion; (A) Chrysomya (Achoetandrus) profanity(B) Megacephalic Chrysomya(VS) Lucilia cuprin(D) domestic musca.

For model training, four of the CNN models used for species-level identification of maggots provided 100% accuracy rates and 0% loss. The number of parameters (#Params), model speed, model size, macro precision, macro recall, f1 score and support value were also presented in Table 1. The result demonstrated that the AlexNet model offered the best performance for all indicators when compared. among four models. The AlexNet model used the fewest parameters while the Resnet101 model used the most. For model speed, the AlexNet model provided the fastest speed, while the Densenet161 model provided the slowest speed. For model size, the AlexNet model was the smallest, while the Resnet101 model was the largest, which matched the number of parameters used. Macro precision, macro recall, f1 score and support value of all models were the same.

Table 1 Comparison of model size, speed, and performance of each model studied (Bold text indicates best value in each category).

Like the training results presented in Supplementary Data (Fig. S1), all models provided 100% accuracy and 0% loss at the start of training (16. Therefore, we have focused on AlexNet results for the remainder of this article.

Using tSNE visualization, the AlexNet model can explicitly separate species into distinct groups based on features extracted from the model, as shown in Fig. 3. The four species were separated with overlapping data from C. megacephalus and C. rufifacies. This could be due to the similarity of the morphological characteristics of the two species24. This result indicated that the performance of the AlexNet model was equal to human practice.

picture 3
picture 3

tSNE visualization of the AlexNet model by penultimate feature dimensionality reduction (Test data is displayed in colors for different classes; yellow refers to the dataset of domestic muscagreen refers to the dataset of Lucilia cupringreenish blue refers to the dataset of Megacephalic Chrysomyaand dark purple refers to the dataset of Chrysomya (Achoetandrus) profanity).

The five AlexNet hidden convolutional layers on four sample posterior stigmata images were visualized as shown in Fig. 4. Within each layer, the posterior stigma of each species was randomly selected for visualization. Color images have been generated to clearly show the patterns. The multiple hidden layers could extract a rich hierarchy of patterns from the input image, including low-level, mid-level, and high-level patterns that can be observed. The lower layers extracted the detailed local patterns from the images, such as textures, margins and others. The complexity and variation of the visualized patterns increased with respect to the intermediate layers. Top layers extracted specific pattern features.

Figure 4
number 4

Visualization of hidden convolutional layers in AlexNet for four sample images (To clearly show the patterns, we generated the images in color; (A) Chrysomya (Achoetandrus) profanity(B) Megacephalic Chrysomya(VS) Lucilia cuprin(D) domestic musca).

The classification results (validation and test) for each image are displayed in confusion matrices (Fig. 5) that show how the predicted species (columns) correspond to the actual species (rows). Values ​​along the diagonal indicate the number of correct predictions, while values ​​off the diagonal indicate classification errors. Interestingly, no misclassifications were found after testing the model using the test images (Fig. 5A). Therefore, the results indicated that the predictions of the AlexNet model correspond to the classification of taxonomic experts. The confusion matrix showed misclassification between C. megacephalus and C. rufifacies (Fig. 5B), corresponding to the results of the tSNE visualization. When the model was tested with the externalized images, the classification accuracy for C. megacephalus, C. rufifacies, L. cuprinaand M. domestica was 94.94, 98.02, 98.35, 100%, respectively (Fig. 5B). The results of using the Heatmap program showed that the prediction accuracy of this model was still high (98.70–100%), depending on the image conditions (Fig. 6).

Figure 5
number 5

The confusion matrix obtained by the AlexNet model: (A) Commit (B) Test dataset.

Figure 6
number 6

Heatmap of AlexNet’s attention maps on sample images showing the prediction accuracy (98.70–100%) of this model for classifying each fly species under different image conditions.

The AlexNet model framework has been demonstrated in Fig. 7. This model consists of 5 convolutional layers (Conv1, Conv2, Conv3, Conv4 and Conv5) and 3 fully connected layers (FC6, FC7 and FC8).19. Convolutional layers extract the features, then fully connected layers combine the features to model the outputs. The example of the features of the images presented in the 5 convolutional layers has been shown in Fig. 4.

Picture 7
number 7

Interpretive architecture framework proposed for the deep learning model, AlexNet, in this study. The AlexNet model contains eight learned layers with weights (five convolutional layers and three fully connected layers), namely Conv1 as a convolutional layer which accepts an input image tensor (224 × 224 × 3) and performs a convolution to get the position and strength of the input image properties causing a tensor output (55×55×96), Conv2 as a convolutional layer which generates a tensor output (27×27×256), Conv3 as as a convolutional layer that creates a tensor output (13 × 13 × 384), Conv4 as a convolutional layer that creates a tensor output (13 × 13 × 384), Conv5 as a convolutional layer that creates a tensor output ( 13×13×256), FC6 as a fully connected layer (4096) which flattens the tensor output of Conv5 into a single vector by weight sharing, resulting in a tensor output (4096×1), FC7 as fully connected layer that performs the same actions as FC6 and generates a tensor output (4096 × 1), and FC8 as a fully connected layer to generate a tensor output ( 1000 × 1) which is the predicted result of iction and which contains 1000 neurons corresponding to the 1000 natural image classes .

Previously, CNNs have been successfully used to identify different cells or species11,12,13,14,15,16,17,18,26,27. This study also confirmed the effectiveness of CNNs in the identification of fly species.

Finally, we created a web application called “The Fly” using our classification model to identify maggot species. The web application is available at https://thefly.ai. Users can identify maggot species by uploading their posterior spiracle images and the result with associated probability percentage will then be displayed. This web application can be viewed and used on desktop and mobile browsers. In terms of limited performance, this web application was designed to identify only four species of fly maggots using images of posterior spiracles. This web application is the first step in the development of the automatic identification of fly species of the order Diptera. More images of these four species and other species should be studied in the future. Moreover, the results of this study will be applied to develop a functionality as a microservice for the identification of maggots in a mobile application called iParasites which is currently available on AppStore and GooglePlay. Nevertheless, we would like to project that taxonomic experts are still important and essential for the development of this AI-based automatic image identification system, as mentioned in a previous report.11.

Comments are closed.