Method and system for classifying species of necrophagous fly larvae

NL2041310B1Active Publication Date: 2026-06-22SUZHOU UNIV

Patent Information

Authority / Receiving Office
NL · NL
Patent Type
Patents
Current Assignee / Owner
SUZHOU UNIV
Filing Date
2025-10-12
Publication Date
2026-06-22

AI Technical Summary

Technical Problem

Existing methods for classifying necrophagous fly larvae species are labor-intensive, subjective, and prone to image quality issues, requiring expensive equipment and lacking robustness and generalization due to unbalanced sample distributions.

Method used

A method and system using multiscale normalization, dual-branch feature extraction, attention mechanisms, and weighted cross-entropy loss to enhance feature representation and adapt to image quality variations and sample imbalances.

Benefits of technology

Achieves high-precision and robust automated classification by effectively capturing local and global features, improving accuracy and generalization, especially under challenging conditions.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

U I T T R E K S E L Disclosed are a method and system for classifying species of necrophagous fly larvae, which can effectively overcome the problems of changeable image size and obvious noise interference in practical application, and enhance the perception ability of a model to different resolution and scale features through multiscale standardization processing and feature fusion mechanism. The introduced dual—branch feature extraction structure and a channelspatial attention mechanism can collaboratively capture local detailed features and global context information of larvae posterior surfaces, and. adaptively weight and. highlight feature regions that contribute the most to classification, significantly improving the representativeness of feature expression and discriminant power. The weighted cross—entropy loss function and label smoothing technology used effectively alleviate a model deviation that may be caused by the imbalance of category samples, improve the generalization performance and classification robustness of the model, and finally realize high—precision and high-efficiency automated classification and identification of fly larvae species. (+ Fig. l)
Need to check novelty before this filing date? Find Prior Art

Description

P2254 / NLpd METHOD AND SYSTEM FOR CLASSIFYING SPECIES OF NECROPHAGOUS FLY LARVAE TECHNICAL FIELD The present invention relates to the technical field of fly larvae species classification, and in particular to a method and system for classifying species of necrophagous fly larvae. BACKGROUND The species identification of necrophagous fly larvae is of great significance in the fields of forensic entomology, ecologi cal research and health and epidemic prevention. Traditional mor phological identification methods rely on professional technicians to observe the morphological characteristics of larvae by stere omicroscope, such as the morphological structure of posterior sur face, the number and arrangement of anterior spiracle, and the morphology of cephalopharyngeal skeleton, etc., and make fine measurements and comparisons. Although this method is classic, it has extremely high requirements for the professional experience of operators, is time-consuming and labor-intensive, and is suscepti- ble to subjective factors. With the development of technology, au- tomated authentication methods based on machine learning and deep learning have gradually become a research hotspot. Machine learn ing methods usually require manual selection and measurement of features (such as geometric morphometric features, and spectral features), and then use classifiers such as support vector machine (SVM) and random forest (RF) to distinguish species. This kind of method reduces the dependence on manual experience to a certain extent, but the feature extraction process may still introduce subjectivity, and the feature engineering itself is complex and timeconsuming, so the performance of the model largely depends on the quality and discrimination of the selected features. In addi tion, these methods usually need to rely on expensive professional equipment (such as highprecision scanners, and spectrometers) to obtain highquality feature data, limiting their popularity in largescale field applications. In recent years, deep learning technologies, especially con volutional neural networks (CNNs), have shown great advantages in image classification tasks due to their powerful endtoend fea ture learning capabilities. Previous studies have tried to apply CNN to the direct classification of insect species images, avoid ing complex artificial feature engineering. However, existing methods for insect classification based on deep learning still face several challenges. First of all, the performance of the mod el relies heavily on the quality of the training image. The fly larvae images collected in practical application scenarios often have problems such as different sizes, complex backgrounds, uneven lighting, and imperceptible noise interference introduced by the acquisition equipment or environment. These factors will signifi cantly reduce the robustness and classification accuracy of the model. Secondly, most methods use a single CNN architecture (such as visual geometry group network (VGG) and residual network (Res Net)), which has limited perception ability of global context in formation and multiscale features of images, and it is difficult to capture key local subtle features and global morphological fea tures of larval posterior surfaces at the same time. Furthermore, existing schemes usually lack dedicated preprocessing and feature enhancement modules designed for insect image features, and the model may not be able to fully learn discriminant features that are truly effective for classification, resulting in insufficient generalization ability. Finally, the samples collected in the nat ural environment may have the problem of unbalanced number of sam ples among classes, and if common models are not processed during training, it is easy to over-fit the majority classes, further af- fecting the recognition accuracy of minority classes. Therefore, there is an urgent need in this field for an in telligent classification scheme for fly larvae species that can effectively overcome image quality interference, adaptively fuse multiscale features, focus on key discriminative regions, and ad dress the problem of sample imbalance, to achieve highprecision and highrobustness automated identification. SUMMARY Objectives of the present invention are to provide a method and system for classifying species of necrophagous fly larvae to solve the problems existing in the prior art. To achieve the above objective, the present invention pro vides the following technical solutions. The present invention provides a method for classifying spe cies of necrophagous fly larvae, including: Sl, acquiring posterior surface images of fly larvae to be classified; S2, performing multiscale normalization processing on the images to generate a standardized image pyramid containing at least two different scales; S3, using feature extraction network to extract features of the image at each scale, and performing feature fusion to obtain a fused multiscale feature map; S4, applying an attention mechanism to the fused multiscale feature map, calculating a channel attention weight and a spatial attention weight, and performing weighted enhancement on the fea tures; and S5, performing species classification of fly larvae based on the weighted enhanced features, and outputting a classification result. Preferably, in step S2, the performing multiscale normaliza tion processing specifically includes: scaling the shortest side of an input image to a fixed size S; generating an image including at least a first scale SXS, a second scale KlXKl, and a third scale K2XK2 by downsampling and / or up-sampling the scaled image, where Kl<S<K2; and performing pixel value normalization on the image at each scale. Preferably, in step 83, the feature extraction network in cludes a local detail branch and a global context branch in paral lel; the local detail branch is a CNN, for extracting local detail features of the image; the global context branch is a visual Transformer network, for extracting global context features of the image; and a formula for feature fusion is: Ffused=a'Fiocai+(3f_a)'Eëiobai where Flmml is a local detail feature, anmai is a global con text feature, and d is a learnable fusion weight parameter. Preferably, in step S4, the attention mechanism is a channel spatial attention module (CSAM), and a calculation process in cludes: channel attention calculation: AC (F)=C5(MLE> (GAE> (F) ) +MLP (GMP (F) )) where GAP is global average pooling, GMP is global maximum pooling, MLP is multilayer perceptron, and 0 is a Sigmoid activa tion function; spatial attention calculation: AS(F)=o(Conv7X7([Fm@;Fmm])) where Favg and Fmax are average and maximum values of the fea ture map in a channel dimension, respectively, Conv7X7 is 7X7 con volution, and o is a Sigmoid activation function; and feature weightec1<3utput: Fatt=AC(Ffmwd)Q§As(Fmed)Q§Fmed where 69 represents elementbyelement multiplication. Preferably, in step S5, a classification process is imple mented using a fully connected layer and a Softmax function, and a loss function L used in model training is a sum of a weighted crossentropy loss function and an L2 regularization term: L=_ <l n)zi:12c:lwc'yic'109(ì71c)+ä'|igi|z where N is the number of samples, c is a category index, wC is a weight of category c, yi,C is a true label of a sample i, ÿi,C is a probability that the model predicts that the sample i belongs to the category c, 9 is a model parameter, and À is a regulariza tion coefficient. Preferably, the true label is smoothed during training: Yammth=(l_)'Y+E / C where y is an original onehot label vector, C is the total number of categories, and is a smoothing coefficient. The present invention also provides a system for classifying species of necrophagous fly larvae, including: an image acquisition module, configured to acquire posterior surface images of fly larvae to be classified; a multiscale processing module, configured to perform multi scale normalization processing on the images to generate a stand ardized image pyramid containing at least two different scales; a feature extractionfusion module, configured to use feature extraction network to extract features of the image at each scale, and perform feature fusion to obtain a fused multiscale feature map; an attention enhancement module, configured to apply an at tention mechanism to the fused multiscale feature map, calculate a channel attention weight and a spatial attention weight, and perform weighted enhancement on the features; and a classification output module, configured to perform species classification of fly larvae based on the weighted enhanced fea tures, and output a classification result. Preferably, the feature extractionfusion module includes a local detail extraction unit and a global context extraction unit in parallel; the local detail extraction unit is a CNN structure, and the global context extraction unit is a visual Transformer structure; and the module also includes a fusion unit capable of learning a weight parameter, and is used for performing the fusion operation. The present invention also provides an electronic device, in cluding a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor imple menting the steps of the above method when executing the computer program. The present invention also provides a computer-readable stor- age medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above method. Compared with the prior art, the present invention has the following beneficial technical effects: The present invention provides a method and system for clas sifying species of necrophagous fly larvae, which can effectively overcome the problems of changeable image size and obvious noise interference in practical application, and enhance the perception ability of a model to different resolution and scale features through multiscale standardization processing and feature fusion mechanism. The introduced dualbranch feature extraction structure and a channelspatial attention mechanism can collaboratively cap ture local detailed features and global context information of larvae posterior surfaces, and adaptively weight and highlight feature regions that contribute the most to classification, sig nificantly improving the representativeness of feature expression and discriminant power. The weighted crossentropy loss function and label smoothing technology used effectively alleviate a model deviation that may be caused by the imbalance of category samples, improve the generalization performance and classification robust ness of the model, and finally realize highprecision and high efficiency automated classification and identification of fly lar vae species. BRIEF DESCRIPTION OF DRAWINGS To explain the technical solutions of examples in the present invention or the prior art more clearly, the drawings needed in the description of the examples or the prior art are briefly in troduced below. Obviously, the attached drawings in the following description are only examples of the present invention, and other attached drawings can be obtained according to the provided draw- ings without creative efforts for those of ordinary skill in the art. FIG. I is a flowchart of a method for classifying species of necrophagous fly larvae provided by the present invention. DETAILED DESCRIPTION OF EXAMPLES Technical solutions in examples of the present invention will be described clearly and completely in the following with refer ence to the attached drawings in the examples of the present in vention. Obviously, all the described examples are only some, ra ther than all examples of the present invention. Based on the ex amples in the present invention, all other examples obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention. Objectives of the present invention are to provide a method and system for classifying species of necrophagous fly larvae, to solve the problems existing in the prior art. To make the above objectives, features and advantages of the present invention more obvious and easier to understand, in the following, the present invention will be further explained in de tail with the attached drawings and specific implementations. Example I: The example provides a method for classifying species of nec rophagous fly larvae, as shown in FIG. 1, which is a flowchart of the method of the present invention, and specifically includes the following steps: In step Sl: image acquisition and preprocessing. A stereo microscope, such as a Zeiss Stemi2000, paired with a digital camera, such as a Nikon D700, was used to acquire posteri or surface images of laboratorybred fly larvae. To ensure image quality, larvae were treated with 80°C hot water before collection and stored in 75% ethanol solution. One posterior surface image of each larva was collected as a sample. The collected original imag es have different sizes, so the size standardization process needs to be carried out first. In step 82: multiscale image normalization. An original size of an input image is denoted as (WC,HO), and the target shortest side length S=256 pixel is set. Scaling is performed according to an original proportion of the image: When min (W0,Hb)=WO, the scaled dimension is W}=S,Hf=%§; and When min (Wb,Hb)=Hb, the scaled dimension is H}=S,Wf=%ÿ On this basis, three scale image pyramids were generated by bicubic interpolation: with an original scale (256XZ56), down sampling scale (128X128) and upsampling scale (384X384). Pixel value normalization was performed on images at each scale, using the mean and standard deviation parameters of the ImageNet da taset: u=[0.485,0.456,0.406], o=[0.229,0.224,0.225], normalization formula is Imnm=£3i In step S3: multiscale feature extraction and fusion. A dualbranch feature extraction network was constructed, in which the local detail branch adopted a 4layer CNN, each layer contained 3X3 convolution kernels, batch normalization and ReLU activation functions, and the number of channels was 16, 32, 64, and 128. The global context branch adopted a visual Transformer structure, cut the image into l6Xl6 patches, and extracted global features through 4 layers of Transformer encoders (4 attention heads in each layer). Feature fusion adopted learnable weight pa rameters @ (an initial value was set to 0.5), and the fusion for mula is: Ffusedza'Fiocai+(jfq)'Eiobai where Flmml is a local detail feature, anmai is a global con text feature, and q is a learnable fusion weight parameter Through this fusion method, not only the subtle structural characteristics of the rear surface position were preserved, but also the global morphological context information was integrated. In step S4: attention mechanism enhancement. The CSAM is used for enhancing the fusion features. A calcu lation formula for channel attention is: AC(F)=O(MLP(GAP(F))+MLP(GMP(F))) where GAP is global average pooling, GMP is global maximum pooling, MLP is two fully connected layers, the first layer com pressed the number of channels to 1 / 16 of the original, and the second layer restored the original number of channels. A calcula tion formula for spatial attention is: AS(F)=o(Conv7X7([Fà@;EhæJ)) where FEM and Eh are mean and maximum feature maps on the channel dimensions, respectively. A final weighted feature is: Fattf4¥:(Ffused)59As(EEused)59Erused where 69 represents elementbyelement multiplication. This module can adaptively highlight the feature areas that contribute the most to classification and discrimination, and suppress irrel evant background interference. In step S5: classifier design and training. The global average pooling layer is used for converting a feature map into a feature vector, the Dropout layer (drop rate 0.5) and the fully connected layer are connected, and finally the category probability is outputted through the Softmax function. The training uses a weighted crossentropy loss function: L= (l / N) zi=1zc=1wc y -1og<9ic)+A-| IGI |2 where N is the number of samples, C is a category index, ac cording to the reciprocal calculation of the number of samples in each category in a training set, wc is a weight of category c, yiC is a true label of a sample i, ÿiC is a probability that the model predicts that the sample i belongs to the category C, 9 is a model parameter, and A is a regularization coefficient, taking 0.001. At the same time, label smoothing technology is adopted: ystf (1-6) 'We / C where y is an original onehot label vector, C is the total number of categories, and is a smoothing coefficient, taking 0.1. Using an AdamW optimizer, an initial learning rate is set to 1e4, a cosine annealing scheduling strategy is adopted, a batch size is 32, and 100 epochs are trained. The example provides a specific application example. For ex ample, 1500 images of the posterior surface of the third instar larvae were collected and divided into training sets, a validation set and a test set according to a ratio of 8:1:1. The training sets were expanded to 30,000 images through data enhancement (in cluding 20 enhancement methods such as rotation, flip, and color dithering). During the network training process, every 5 epochs were trained, the performance was evaluated on the verification set, and a learning rate was automatically reduced when the accuracy of the verification set no longer improves. The final model achieved a classification accuracy of 98.7% on the test set, which was about 5.2% higher than the traditional ResNet50 benchmark model. In particular, on the test samples with poor lighting conditions and slight blurring, the robustness of this method was particular ly outstanding, and the accuracy rate was 8.3% higher than that of the benchmark model. When the model was deployed, TensorRT was used for inference optimization, and realtime classification (processing 15 frames of images per second) was realized on the NVIDIA Jetson Nano em bedded device to meet the needs of rapid onsite identification. The system provides RESTfulAPI interface to support integration with existing laboratory information management systems. Example 2: The example provides a system for classifying species of nec rophagous fly larvae, including the following modules: An image acquisition module uses a USB digital microscope camera (such as DinoLiteAM7915MZT) for image acquisition, sup ports 2560 X 1920 resolution, and is equipped with a ringshaped LED light source to ensure even illumination. Image transmission adopts USB3.0 interface, and the highest frame rate can reach 30 fps. A multiscale processing module, based on OpenCV library, multiscale image processing pipeline is implemented, including image scaling, interpolation operation and normalization. This module supports dynamic adjustment of scale parameters, and can select to generate image pyramids of 24 scales according to dif ferent hardware configurations. A feature extractionfusion module uses PyTorch framework to implement a dualbranch network structure. The local detail branch adopts a lightweight CNN architecture, and the global context branch adopts a ViTTiny variant. The feature fusion layer adopts a learnable attention mechanism to dynamically adjust the contri bution weights of the two branches. An attention enhancement module: an efficient CSAM is imple mented, and grouped convolution and deep separable convolution are used to optimize computational efficiency. The module supports ex perimental comparison of multiple attention variants, including mainstream attention mechanisms such as squeeze-and-excitation (SE) and convolutional block attention module (CBAM). A classification output module contains model reasoning in terface and result postprocessing function. Realtime display of classification results and confidence evaluation are supported to provide visual display of classification results, including atten tion heat map generation and feature visualization. Example 3: The example provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, in which when the processor exe cutes the computer program, the steps of the method for classify ing species of necrophagous fly larvae according to Example 1 are realized. Example 4: The example provides a computerreadable storage medium, hav ing a computer program stored thereon, in which the computer pro gram, when executed by a processor, implements the steps of the method for classifying species of necrophagous fly larvae accord ing to Example l. It will be understood by those skilled in the art that exam ples of the present application may be provided as methods, sys tems, or computer program commodities. Therefore, the present ap plication may take the form of an entirely hardware example, an entirely software example or an example combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more com puterusable storage media (including, but not limited to, magnet ic disk storage, compact disc readonly memory (CDROM), optical storage, etc.) having computer-usable program codes contained therein. The solutions in the examples of the present application may be implemented in various computer languages, such as the ob jectoriented programming language Java, the transliteration scripting language JavaScript, etc. The present application is described with reference to flow charts and / or block diagrams of methods, devices (systems), and computer program products according to the examples of the present application. It is to be understood that each of flows and / or blocks of flow charts and / or block diagrams, and combinations of flows and / or blocks in the flow charts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine, so that the instructions, which, when executed by a processor of the computer or other programmable data processing device, produce an apparatus for implementing the functions specified in the flow or flows of the flow chart and / or the block or blocks of the block diagram. These computer program instructions may also be stored in a computerreadable memory that can direct a computer or other pro grammable data processing devices to function in a particular man ner, such that the instructions stored in the computerreadable memory produce an article of manufacture including instruction ap paratuses which implement the function specified in the flow or flows of the flowchart and / or the block or blocks of the block di agram. These computer program instructions may also be loaded onto a computer or other programmable data processing devices to cause a series of operational steps to be performed on the computer or other programmable devices to produce a computer implemented pro cess, so that the instructions, which, when executed on the com puter or other programmable devices, provide steps for implement ing the functions specified in the flow or flows of the flow charts and / or the block or blocks of the block diagram. Herein, specific examples are used to explain the principle and implementation of the present invention, and the description of the above examples is only used to help understand the method and its core idea of the present invention. At the same time, for those of ordinary skill in the art, many changes can be made in the specific implementations and application scopes according to the idea of the present invention. In summary, this description is not to be construed as limiting the present invention. C O N C L U S I E S l. Method of classification of species of fly larvae, with the feature that this method includes the following steps: Sl. Obtaining an image of the posterior spiracle culum of fly larvae to be classified; S2. Performing a multiscale normalization on the ge named image, where a normalized image pyramid is generated that includes at least two different scales; S3. Extracting features from each scale separately image using a feature extraction network, and the then merging these features to form a fused mul obtain tiscale characteristics map; S4. Applying an attention mechanism to the mentioned merged multi-scale feature map, with channel attention weights and spatial attention weights are calculated and the characteristics are accordingly enhanced by means of weighted elevation; 85. Classifying species of fly larvae based on of the features enhanced by weighted increase, and the gene run of a classification result. 2. Classification method for species of fly larvae according to conclusion l, characterized in that in step S2 the multi-scale norm lization specifically includes the following: scaling the shortest side of the input image to a fixed dimension S; the generation, by means of downsampling and / or upsampling of the scaled image, of images that are at least a first scale SXS, a second scale KlXKl and a third scale K2XK2 include, where Kl < s < K2; performing pixel value normalization for each scale image. 3. Classification method for species of fly larvae according to claim 2, characterized in that in step 53 the characteristic extraction network a parallel local detail branch and a global one context branch includes; where the mentioned local detail branch is a Convolutional Neural Network (CNN) is designed for extracting local detailed features of the image; where the said global context branch is a Visual Transformer Network is concerned, set up for extracting global con text features of the image; and where the feature fusion is performed in accordance with the following merger formula: FËused=U'Flocal+(]=_U)'Fglobalî where Flmml indicates local detail features, Fgkmal indicates the global context features, denotes a learnable fusion weight parameter. 4. Classification method for species of fly larvae according to claim 3, characterized in that in step S4 the attention mechanism a channel spatial attention module (CSAM), of which the calculation process includes the following: Channel attention calculation: AG(F)=o(MLP(GAP(F))+MLP(GMP(F))); where GAP indicates global average pooling, GMP indicates the global maximum pooling, MLP denotes a multilayer perceptron (MLP), and indicates the Sigmoid activation function; Spatial attention calculation: ;AS(F)=o(Conv7X7([Fm@;FmmJ)) where Favg and Fmax are the mean value and the indicate maximum value of the feature map in the channel dimension the, Conv7X7 denotes a 7X7 convolution, and indicates the Sigmoid activation function; Feature-weighted irttfeed: Fatt=Ac(Ffuä)QbAs(Fmed)QDFwed; Where QD denotes element-wise multiplication. 5. Classification method for species of fly larvae according to claim 1, characterized in that in step 85 the classification pro ces is performed using a fully connected layer and a Softmax function, where the used during model training loss function L is the sum of a weighted cross entropy loss function and an L2 regularization term: L=_ <l n)zi:12c:iwc'yic'109(ì7ic)+?\'|igi |z, where N denotes the number of samples, wcc indicates the class index, indicates the weight coefficient for class C, ch denotes the true label of sample i, ?Lc indicates the probability predicted by the model that sample i belongs to class c, @ indicates the model parameters, and À indicates the regularization coefficient. 6. Classification method for species of fly larvae according to conclusion 5, characterized in that during the training the true la bells are smoothed according to:; yf (1-6) awe / C where y denotes the original onehot label vector, C indicates the total number of classes, indicates the smooth coefficient. 7. Classification system for species of fly larvae, with the characteristic that the system includes: an image acquisition module, designed to obtain from an image of the posterior spiraculum of fly larvae which need to be classified; a multi-scale processing module, designed to perform of multi-scale normalization on the mentioned image in order to to generate a normalized image pyramid containing at least the st comprises two different parts; a feature extraction and fusion module designed for the individually extract features from each scale image using using a feature extraction network and for performing feature fusion to obtain a fused multi-scale feature map to acquire; an attention enhancement module, designed for applying of an attention mechanism on the aforementioned fused multiscales feature map, for calculating channel attention weights and spatial attention weights, and for the weighted reinforcement of the features; a classification output module, designed for the classification run of species of fly larvae based on the weighted enhancement of acquired characteristics and for generating a classification result. 8. Classification system for species of fly larvae according to claim 7, characterized in that the said feature extraction and fusion module a parallel local detail extraction unit and a global context extraction unit; where the said local the detail extraction unit of a Convolutional Neural Network (CNN); where the mentioned global context extraction unit concerns a Visual Transformer Network; and where the ge furthermore, the module referred to as a fusion unit with a learnable ge weight parameter includes, designed to carry out the merger editing. 9. Electronic device comprising a memory, a processor, and a computer program stored in said memory gen and executable on the named processor, with the characteristic that when the said processor executes the said computer program performs the steps of the method according to one of the claims 1 through 6 are realized. 10. Computer readable storage medium on which a computer program is stored stored, characterized in that, when the said computer pro gram executed by a processor, the steps of the me method according to any one of claims 1 to 6 are realized hurt. FIG.1< / l> < / l>