Insect grading and classifying method and device based on multi-task convolutional neural network
Through multi-task convolutional neural network and image enhancement technology, the problems of high manual identification cost and low accuracy of deep learning in insect identification are solved, and efficient and accurate insect identification and classification are achieved.
Patent Information
- Application Number
- CN202410915426.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-10-25
AI Technical Summary
Insect identification methods in the existing technology rely on manual identification, which is costly and inefficient. Deep learning methods have low identification accuracy and accuracy due to the limited number of training sets.
An insect hierarchical classification method based on multi-task convolutional neural network is adopted to perform image enhancement processing by obtaining the insect image to be recognized, and input the processed image into the pre-built recognition model, using feature extraction layer, feature fusion layer and classification The classification layer generates hierarchical classification results, combines the self-attention mechanism and Transformer structure, and optimizes the recognition model parameters to improve recognition accuracy.
The efficiency, precision and accuracy of insect identification are improved, labor costs are reduced, and more efficient insect identification and classification are achieved.
Smart Images

Figure CN118840604A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of insect identification, and in particular to a method and device for insect grading and classification based on a multi-task convolutional neural network. Background Art
[0002] Alien invasive insects can cause serious harm to my country's agriculture and forestry, and destroy my country's native biodiversity and ecological security. Therefore, accurate identification and identification of quarantine insects is particularly important. Traditional insect identification and identification methods are manual identification by experts, which has high requirements for the experience and professional knowledge of the identifiers, high labor costs, and low efficiency.
[0003] With the rapid development of artificial intelligence technology, insect recognition algorithms based on deep learning have been applied to the field of insect identification. However, due to objective conditions and the limited number of training sets, the recognition precision and accuracy are low. Summary of the invention
[0004] The present invention provides an insect grading and classification method and device based on a multi-task convolutional neural network, which is used to solve the defects of the prior art that the manual identification method is used for insect identification, which is high in cost and low in efficiency, and the deep learning method is used for insect identification, which has low identification precision and accuracy.
[0005] In a first aspect, the present invention provides an insect classification method based on a multi-task convolutional neural network, comprising: Acquire an insect image to be identified; Performing image enhancement processing on the insect image to obtain a processed insect image; Inputting the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model; The recognition model is obtained by training based on processed sample insect images and hierarchical classification labels of the sample insect images.
[0006] In some embodiments, the recognition model includes a feature extraction layer, a feature fusion layer, and a hierarchical classification layer; Correspondingly, the step of inputting the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model includes: Inputting the processed insect image into the feature extraction layer to obtain a plurality of feature vectors of the processed insect image output by the feature extraction layer; Inputting a plurality of feature vectors of the processed insect image into the feature fusion layer to obtain a fused feature vector of the processed insect image output by the feature fusion layer; The fused feature vector of the processed insect image is input into the hierarchical classification layer to obtain a hierarchical classification result corresponding to the insect image output by the hierarchical classification layer.
[0007] In some embodiments, the feature extraction layer includes a convolutional feature extraction layer and a self-attention feature extraction layer; Correspondingly, the processing of the insect image after processing is input into the feature extraction layer to obtain a plurality of feature vectors of the insect image after processing output by the feature extraction layer, including: Inputting the processed insect image into the convolutional feature extraction layer to obtain a first feature vector of the processed insect image output by the convolutional feature extraction layer; The processed insect image is input into the self-attention feature extraction layer to obtain a second feature vector of the processed insect image output by the self-attention feature extraction layer.
[0008] In some embodiments, the hierarchical classification layer includes a plurality of levels of classification layers; Correspondingly, the step of inputting the fused feature vector of the processed insect image into the hierarchical classification layer to obtain a hierarchical classification result corresponding to the insect image output by the hierarchical classification layer includes: The fused feature vector of the processed insect image is input into each level of classification layer to obtain the classification result of each level corresponding to the insect image output by each level of classification layer.
[0009] In some embodiments, performing image enhancement processing on the insect image to obtain a processed insect image includes: The insect image is subjected to geometric transformation, perspective transformation, color transformation and histogram equalization processing to obtain a processed insect image.
[0010] In some embodiments, the recognition model includes a Transformer structure based on a self-attention mechanism and a multi-task convolutional neural network.
[0011] In some embodiments, the process of determining the recognition model includes: Acquire a sample insect image, and determine a hierarchical classification label of the sample insect image; Performing image enhancement processing on the sample insect image to obtain a processed sample insect image; Inputting the processed sample insect image into a pre-built initial recognition model to obtain a hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model; Calculating a total loss function value based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images; Based on the total loss function value, the parameters of the initial recognition model are iteratively optimized to obtain the recognition model.
[0012] In some embodiments, the initial recognition model includes an initial feature extraction layer, an initial feature fusion layer, and an initial hierarchical classification layer; Correspondingly, the step of inputting the processed sample insect image into a pre-built initial recognition model to obtain a hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model includes: Inputting the processed sample insect image into the initial feature extraction layer to obtain a plurality of sample feature vectors of the processed sample insect image output by the initial feature extraction layer; Inputting a plurality of sample feature vectors of the processed sample insect images into the initial feature fusion layer to obtain a sample fusion feature vector of the processed sample insect images output by the initial feature fusion layer; The sample fusion feature vector of the processed sample insect image is input into the initial hierarchical classification layer to obtain the hierarchical classification prediction result corresponding to the sample insect image output by the initial hierarchical classification layer.
[0013] In some embodiments, based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images, calculating the total loss function value includes: Calculating a cross entropy loss function value based on the hierarchical classification prediction result corresponding to the sample insect image and the hierarchical classification label of the sample insect image; Based on the hierarchical classification prediction results corresponding to the sample insect image, determine whether any two adjacent classification prediction results belong to a subordinate relationship between a parent class and a child class, obtain a determination result, and calculate a dependency layer loss function value according to the determination result; The total loss function value is calculated based on the cross entropy loss function value and the dependent layer loss function value.
[0014] In a second aspect, the present invention provides an insect classification device based on a multi-task convolutional neural network, comprising: An acquisition unit, used for acquiring an image of an insect to be identified; A processing unit, used for performing image enhancement processing on the insect image to obtain a processed insect image; A recognition unit, used for inputting the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model; The recognition model is obtained by training based on processed sample insect images and hierarchical classification labels of the sample insect images.
[0015] The insect grading and classification method and device based on a multi-task convolutional neural network provided by the present invention obtain an insect image to be identified, perform image enhancement processing on the insect image to obtain a processed insect image, input the processed insect image into a pre-built recognition model, and obtain a grading and classification result corresponding to the insect image output by the recognition model, thereby improving the efficiency, precision and accuracy of insect identification and reducing labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 It is a flow chart of an insect classification method based on a multi-task convolutional neural network provided by an embodiment of the present invention; Figure 2 It is a schematic diagram of a process of inputting a processed insect image into a pre-built recognition model for hierarchical classification according to an embodiment of the present invention; Figure 3 is a flowchart of a process for determining a recognition model provided by an embodiment of the present invention; Figure 4 It is a structural schematic diagram of an insect grading and classification device based on a multi-task convolutional neural network provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] The terms "first", "second", etc. in the description of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more.
[0020] Figure 1 The following is a flow chart of the insect classification method based on a multi-task convolutional neural network provided by the embodiment of the present invention. Figure 1 As shown, a method for insect classification based on a multi-task convolutional neural network is provided, comprising the following steps: step 110, step 120 and step 130. The steps of the method flow are only a possible implementation of the present invention.
[0021] Step 110: Acquire an insect image to be identified.
[0022] Step 120: Perform image enhancement processing on the insect image to obtain a processed insect image.
[0023] It can be understood that by performing image enhancement processing on insect images, the quality of insect images can be significantly improved and the accuracy of insect recognition can be improved.
[0024] In some embodiments, performing image enhancement processing on the insect image to obtain a processed insect image includes: The insect image is processed by geometric transformation, perspective transformation, color transformation and histogram equalization to obtain a processed insect image.
[0025] Among them, geometric transformation is used to change the shape, size or position of an image without changing the image content.
[0026] Optionally, the geometric transformation includes scaling, horizontal and vertical flipping, cropping, occlusion, rotation, etc.
[0027] Among them, perspective transformation is used to correct or change the perspective effect of an image; in insect image processing, perspective transformation can be used to correct the perspective distortion caused by the camera angle or insect position, making the geometric shape of the insect more realistic and accurate.
[0028] Optionally, the perspective transformation matrix looks like this:
[0029]
[0030]
[0031] in, is the original image coordinate, are the transformed coordinates; is the rotation amount, is the translation amount.
[0032] Optionally, a perspective transformation matrix is used to perform perspective transformation on target points in the insect image.
[0033] Among them, color transformation is used to modify the color distribution in the image, adjust the hue, brightness, contrast or enhance specific color effects.
[0034] Among them, histogram equalization is a technology used to enhance image contrast, especially in the case of low local contrast. Histogram equalization refers to redistributing the pixel values of the image so that the grayscale level of the image is evenly distributed, thereby enhancing the global contrast of the image.
[0035] Step 130: input the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model; The recognition model is trained based on the processed sample insect images and the hierarchical classification labels of the sample insect images.
[0036] The hierarchical classification results include classification results at multiple levels, such as classification results at the family, genus, species, etc. levels.
[0037] The hierarchical classification labels include classification labels of multiple levels, such as classification labels at the family, genus, species and other levels.
[0038] In some embodiments, the recognition model includes a Transformer structure based on a self-attention mechanism and a multi-task convolutional neural network.
[0039] Among them, the core of Transformer is the self-attention mechanism, which calculates the attention weight by comparing each position in the input sequence with all other positions, so that the recognition model can learn the complex dependencies between different positions in the input sequence, which helps to deal with long-distance dependencies and capture more comprehensive and context-aware feature representations.
[0040] Among them, the multi-task convolutional neural network includes a shared feature extraction layer and multiple classification layers, which can simultaneously learn and optimize multiple classification tasks.
[0041] In an embodiment of the present invention, by acquiring an insect image to be identified, image enhancement processing is performed on the insect image to obtain a processed insect image, and the processed insect image is input into a pre-constructed recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model, thereby improving the efficiency, precision and accuracy of insect identification and reducing labor costs.
[0042] In some embodiments, the recognition model includes a feature extraction layer, a feature fusion layer, and a hierarchical classification layer.
[0043] Among them, the feature extraction layer usually includes multiple convolutional layers and pooling layers, which are used to generate a series of feature maps based on the input image.
[0044] Figure 2 A schematic diagram of a process for inputting a processed insect image into a pre-built recognition model for hierarchical classification provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, step 130 inputs the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model, including the following steps 131, 132 and 133.
[0045] Step 131: input the processed insect image into a feature extraction layer to obtain a plurality of feature vectors of the processed insect image output by the feature extraction layer.
[0046] Optionally, the multiple feature vectors include shape, texture, color and other feature vectors.
[0047] It can be understood that by inputting the processed insect image into the feature extraction layer, a plurality of feature vectors output by the feature extraction layer are obtained, which is helpful to distinguish different types of insects or identify various parts of insects.
[0048] In some embodiments, the feature extraction layer includes a convolutional feature extraction layer and a self-attention feature extraction layer; Correspondingly, the processed insect image is input into the feature extraction layer, and multiple feature vectors of the processed insect image output by the feature extraction layer are obtained, including: Inputting the processed insect image into a convolutional feature extraction layer to obtain a first feature vector of the processed insect image output by the convolutional feature extraction layer; The processed insect image is input into the self-attention feature extraction layer to obtain a second feature vector of the processed insect image output by the self-attention feature extraction layer.
[0049] The first feature vector includes low-level to mid-level visual features such as shape and texture; the second feature vector includes global semantic features in the insect image, such as the overall shape and posture of the insect and the connection between different parts.
[0050] It should be noted that through the convolutional feature extraction layer and the self-attention feature extraction layer, feature vectors of different aspects of the processed insect image can be obtained respectively. The convolutional feature extraction layer can capture local features and intermediate features, while the self-attention feature extraction layer can capture global features and semantic features. The combination of the two can extract more comprehensive and richer features, which can improve the ability to understand insect images.
[0051] Step 132: input multiple feature vectors of the processed insect image into a feature fusion layer to obtain a fused feature vector of the processed insect image output by the feature fusion layer.
[0052] Optionally, the first feature vector and the second feature vector are input into a feature fusion layer to obtain a fused feature vector of the processed insect image output by the feature fusion layer.
[0053] The calculation formula of the fused feature vector is as follows:
[0054] in, represents the fused feature vector, represents the second eigenvector, represents the first eigenvector, is the weight of the second eigenvector, is the weight of the first eigenvector.
[0055] It can be understood that by fusing multiple feature vectors of the processed insect image to obtain a fused feature vector, it is possible to integrate and utilize the information of different feature vectors, provide a more comprehensive and effective feature representation for the processed insect image, and improve the accuracy of insect recognition.
[0056] Step 133: input the fused feature vector of the processed insect image to the hierarchical classification layer to obtain a hierarchical classification result corresponding to the insect image output by the hierarchical classification layer.
[0057] Among them, the hierarchical classification layer can set different classification granularities as needed, for example, classification according to the classification levels of family, genus, and species.
[0058] Optionally, the hierarchical classification layer includes a softmax layer, which is used to normalize the output results of the previous layer and make the sum of the confidence of each item equal to 1.
[0059] It should be noted that the maximum value of the softmax layer output determines the predicted category. Based on the output distribution of the softmax layer, outliers can be identified and the category can be predicted. Since each classification output of each classification level before the softmax layer follows a normal distribution , so set the threshold in the probability density function:
[0060] When the output value is less than the set threshold, the classification result is judged as "uncertain", that is, it cannot be identified.
[0061] In the case where there is no subordinate relationship between the high-level classification result and the low-level classification result, the classification result will also be judged as "uncertain".
[0062] Optionally, the classification result output by the softmax layer is expressed as follows:
[0063] in, For the l The predicted category of the layer, For the The predicted category of the layer, is the output value of the layer before the softmax layer, To set the threshold.
[0064] It can be understood that by inputting the fused feature vector of the processed insect image into the hierarchical classification layer, it is possible to provide consistent and effective feature representation in classification tasks of different granularities, support multi-level insect classification tasks, and be suitable for complex and diverse insect classification scenarios.
[0065] In some embodiments, the hierarchical classification layer includes multiple levels of classification layers.
[0066] Correspondingly, the fused feature vector of the processed insect image is input into the hierarchical classification layer to obtain the hierarchical classification result corresponding to the insect image output by the hierarchical classification layer, including: The fused feature vector of the processed insect image is input into each level of the classification layer to obtain the classification result of each level corresponding to the insect image output by each level of the classification layer.
[0067] It should be noted that by inputting the fused feature vector of the processed insect image into each level of the classification layer, the classification results of each level corresponding to the insect image output by each level of the classification layer are obtained, which can provide detailed classification information at different levels and improve the precision and accuracy of insect identification.
[0068] Figure 3 A schematic diagram of a process of determining a recognition model provided by an embodiment of the present invention. In some embodiments, the process of determining a recognition model includes the following steps: Step 310: Obtain a sample insect image and determine a hierarchical classification label of the sample insect image; Step 320: performing image enhancement processing on the sample insect image to obtain a processed sample insect image; Step 330: input the processed sample insect image into a pre-built initial recognition model to obtain a hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model; Step 340: Calculate the total loss function value based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images; Step 350: Based on the total loss function value, iteratively optimize the parameters of the initial recognition model to obtain a recognition model.
[0069] Optionally, the sample insect images are subjected to geometric transformation, perspective transformation, color transformation and histogram equalization processing to obtain processed sample insect images, and the number of sample insect images is expanded through random parameter transformation.
[0070] Among them, the hierarchical classification prediction results include classification prediction results at multiple levels, such as classification prediction results at the family, genus, species and other levels.
[0071] Among them, the initial recognition model includes a Transformer structure based on the self-attention mechanism and a multi-task convolutional neural network.
[0072] In the embodiment of the present invention, by acquiring high-quality sample data, performing image enhancement processing on the sample data, and using the loss function to perform feedback optimization on the model parameters, the classification accuracy and generalization ability of the recognition model are effectively improved.
[0073] In some embodiments, the initial recognition model includes an initial feature extraction layer, an initial feature fusion layer, and an initial hierarchical classification layer; Correspondingly, the processed sample insect image is input into the pre-built initial recognition model to obtain the hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model, including: Inputting the processed sample insect image into the initial feature extraction layer to obtain a plurality of sample feature vectors of the processed sample insect image output by the initial feature extraction layer; Inputting a plurality of sample feature vectors of the processed sample insect images into an initial feature fusion layer to obtain a sample fusion feature vector of the processed sample insect images output by the initial feature fusion layer; The sample fusion feature vector of the processed sample insect image is input into the initial hierarchical classification layer to obtain the hierarchical classification prediction result corresponding to the sample insect image output by the initial hierarchical classification layer.
[0074] Optionally, in some embodiments, the initial feature extraction layer includes an initial convolutional feature extraction layer and an initial self-attention feature extraction layer; Correspondingly, the processed sample insect image is input into the initial feature extraction layer to obtain a plurality of sample feature vectors of the processed sample insect image output by the initial feature extraction layer, including: Inputting the processed sample insect image into the initial convolution feature extraction layer to obtain a first sample feature vector of the processed sample insect image output by the initial convolution feature extraction layer; The processed sample insect image is input into the initial self-attention feature extraction layer to obtain a second sample feature vector of the processed sample insect image output by the initial self-attention feature extraction layer.
[0075] Optionally, the initial hierarchical classification layer includes multiple levels of initial classification layers.
[0076] Correspondingly, the sample fusion feature vector of the processed sample insect image is input into the initial hierarchical classification layer, and the hierarchical classification prediction result corresponding to the sample insect image output by the initial hierarchical classification layer includes: The sample fusion feature vector of the processed sample insect image is input into the initial classification layer of each level, and the classification prediction result of each level corresponding to the sample insect image output by the initial classification layer of each level is obtained.
[0077] In some embodiments, based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images, the total loss function value is calculated, including: Based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images, the cross entropy loss function value is calculated; Based on the hierarchical classification prediction results corresponding to the sample insect images, it is judged whether any two adjacent classification prediction results belong to the subordinate relationship between the parent class and the child class, and the judgment result is obtained, and the dependency layer loss function value is calculated according to the judgment result; Based on the cross entropy loss function value and the dependent layer loss function value, the total loss function value is calculated.
[0078] Among them, the cross entropy loss function value is used to describe the distance between the probability distribution of the model prediction value and the true value; the dependency layer loss function value is used to constrain the hierarchical classification network.
[0079] Optionally, the cross entropy loss function value is calculated as follows:
[0080] in, For the l The cross entropy loss function value of the layer, Indicates l The probability value of the expected output of the jth sample in the layer, and It is the probability value of each category calculated and actually output by the recognition model through the softmax regression layer during training.
[0081] Optionally, the calculation formula of the dependency layer loss function value is as follows:
[0082] in, Represents the loss function value of the dependent layer, parameter There are two values. When the classification result does not satisfy the subordinate relationship between the parent class and the child class, If the value is 1, The value is e-1; when the classification result satisfies the subordinate relationship between the parent class and the child class, If the value is 0, The value is 0.
[0083] Optionally, the total loss function value is calculated as follows:
[0084] in, is the overall loss function value, which is obtained by weighted addition of the cross entropy loss function value of each classification level and the dependent layer loss function value. is the weight of the cross entropy loss function value, , The default value is 0.5, and its value can be adjusted according to the actual training situation.
[0085] It is understandable that by simultaneously learning multi-task classifications at different levels, the classification and recognition ability of the recognition model can be constrained, and feature learning can be performed for different classification levels respectively, thereby avoiding the occurrence of overfitting in the insect classification task.
[0086] The following is a description of an insect grading and classification device based on a multi-task convolutional neural network provided in an embodiment of the present invention. The insect grading and classification device based on a multi-task convolutional neural network described below and the insect grading and classification method based on a multi-task convolutional neural network described above can be referenced to each other.
[0087] Figure 4 A schematic diagram of the structure of an insect classification device based on a multi-task convolutional neural network provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the insect classification device 400 based on a multi-task convolutional neural network includes: An acquisition unit 410 is used to acquire an insect image to be identified; The processing unit 420 is used to perform image enhancement processing on the insect image to obtain a processed insect image; The recognition unit 430 is used to input the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model; The recognition model is trained based on the processed sample insect images and the hierarchical classification labels of the sample insect images.
[0088] Optionally, the recognition model includes a feature extraction layer, a feature fusion layer and a hierarchical classification layer; Correspondingly, the processed insect image is input into the pre-built recognition model to obtain the hierarchical classification result corresponding to the insect image output by the recognition model, including: Inputting the processed insect image into the feature extraction layer to obtain a plurality of feature vectors of the processed insect image output by the feature extraction layer; Inputting multiple feature vectors of the processed insect image into a feature fusion layer to obtain a fused feature vector of the processed insect image output by the feature fusion layer; The fused feature vector of the processed insect image is input into the hierarchical classification layer to obtain the hierarchical classification result corresponding to the insect image output by the hierarchical classification layer.
[0089] Optionally, the feature extraction layer includes a convolutional feature extraction layer and a self-attention feature extraction layer; Correspondingly, the processed insect image is input into the feature extraction layer, and multiple feature vectors of the processed insect image output by the feature extraction layer are obtained, including: Inputting the processed insect image into a convolutional feature extraction layer to obtain a first feature vector of the processed insect image output by the convolutional feature extraction layer; The processed insect image is input into the self-attention feature extraction layer to obtain a second feature vector of the processed insect image output by the self-attention feature extraction layer.
[0090] Optionally, the hierarchical classification layer comprises a plurality of levels of classification layers; Correspondingly, the fused feature vector of the processed insect image is input into the hierarchical classification layer to obtain the hierarchical classification result corresponding to the insect image output by the hierarchical classification layer, including: The fused feature vector of the processed insect image is input into each level of the classification layer to obtain the classification result of each level corresponding to the insect image output by each level of the classification layer.
[0091] Optionally, performing image enhancement processing on the insect image to obtain a processed insect image includes: The insect image is processed by geometric transformation, perspective transformation, color transformation and histogram equalization to obtain a processed insect image.
[0092] Optionally, the recognition model includes a Transformer structure based on a self-attention mechanism and a multi-task convolutional neural network.
[0093] Optionally, the process of determining the recognition model includes: Acquire a sample insect image and determine a hierarchical classification label of the sample insect image; Performing image enhancement processing on the sample insect image to obtain a processed sample insect image; The processed sample insect image is input into a pre-built initial recognition model to obtain a hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model; Calculate the total loss function value based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images; Based on the total loss function value, the parameters of the initial recognition model are iteratively optimized to obtain the recognition model.
[0094] Optionally, the initial recognition model includes an initial feature extraction layer, an initial feature fusion layer, and an initial hierarchical classification layer; Correspondingly, the processed sample insect image is input into the pre-built initial recognition model to obtain the hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model, including: Inputting the processed sample insect image into the initial feature extraction layer to obtain a plurality of sample feature vectors of the processed sample insect image output by the initial feature extraction layer; Inputting a plurality of sample feature vectors of the processed sample insect images into an initial feature fusion layer to obtain a sample fusion feature vector of the processed sample insect images output by the initial feature fusion layer; The sample fusion feature vector of the processed sample insect image is input into the initial hierarchical classification layer to obtain the hierarchical classification prediction result corresponding to the sample insect image output by the initial hierarchical classification layer.
[0095] Optionally, based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images, a total loss function value is calculated, including: Based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images, the cross entropy loss function value is calculated; Based on the hierarchical classification prediction results corresponding to the sample insect images, it is judged whether any two adjacent classification prediction results belong to the subordinate relationship between the parent class and the child class, and the judgment result is obtained, and the dependency layer loss function value is calculated according to the judgment result; Based on the cross entropy loss function value and the dependent layer loss function value, the total loss function value is calculated.
[0096] It should be noted here that the insect grading and classification device based on a multi-task convolutional neural network provided in an embodiment of the present invention can implement all the method steps implemented in the above-mentioned insect grading and classification method embodiment based on a multi-task convolutional neural network, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those of the method embodiment will not be described in detail here.
[0097] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0098] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0099] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for insect classification based on multi-task convolutional neural network, characterized in that: include: Acquire an insect image to be identified; Performing image enhancement processing on the insect image to obtain a processed insect image; Inputting the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model; The recognition model is obtained by training based on processed sample insect images and hierarchical classification labels of the sample insect images.
2. The insect classification method based on multi-task convolutional neural network according to claim 1 is characterized in that: The recognition model includes a feature extraction layer, a feature fusion layer and a hierarchical classification layer; Correspondingly, the step of inputting the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model includes: Inputting the processed insect image into the feature extraction layer to obtain a plurality of feature vectors of the processed insect image output by the feature extraction layer; Inputting a plurality of feature vectors of the processed insect image into the feature fusion layer to obtain a fused feature vector of the processed insect image output by the feature fusion layer; The fused feature vector of the processed insect image is input into the hierarchical classification layer to obtain a hierarchical classification result corresponding to the insect image output by the hierarchical classification layer.
3. The insect classification method based on multi-task convolutional neural network according to claim 2 is characterized in that: The feature extraction layer includes a convolutional feature extraction layer and a self-attention feature extraction layer; Correspondingly, the processing of the insect image after processing is input into the feature extraction layer to obtain a plurality of feature vectors of the insect image after processing output by the feature extraction layer, including: Inputting the processed insect image into the convolutional feature extraction layer to obtain a first feature vector of the processed insect image output by the convolutional feature extraction layer; The processed insect image is input into the self-attention feature extraction layer to obtain a second feature vector of the processed insect image output by the self-attention feature extraction layer.
4. The insect classification method based on multi-task convolutional neural network according to claim 2 is characterized in that: The hierarchical classification layer includes a plurality of levels of classification layers; Correspondingly, the step of inputting the fused feature vector of the processed insect image into the hierarchical classification layer to obtain a hierarchical classification result corresponding to the insect image output by the hierarchical classification layer includes: The fused feature vector of the processed insect image is input into each level of classification layer to obtain the classification result of each level corresponding to the insect image output by each level of classification layer.
5. The insect classification method based on multi-task convolutional neural network according to claim 1, characterized in that: The performing image enhancement processing on the insect image to obtain a processed insect image includes: The insect image is subjected to geometric transformation, perspective transformation, color transformation and histogram equalization processing to obtain a processed insect image.
6. The insect classification method based on a multi-task convolutional neural network according to any one of claims 1 to 5, characterized in that: The recognition model includes a Transformer structure based on a self-attention mechanism and a multi-task convolutional neural network.
7. The insect classification method based on multi-task convolutional neural network according to claim 1, characterized in that: The determination process of the recognition model includes: Acquire a sample insect image, and determine a hierarchical classification label of the sample insect image; Performing image enhancement processing on the sample insect image to obtain a processed sample insect image; Inputting the processed sample insect image into a pre-built initial recognition model to obtain a hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model; Calculating a total loss function value based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images; Based on the total loss function value, the parameters of the initial recognition model are iteratively optimized to obtain the recognition model.
8. The insect classification method based on multi-task convolutional neural network according to claim 7, characterized in that: The initial recognition model includes an initial feature extraction layer, an initial feature fusion layer and an initial hierarchical classification layer; Correspondingly, the step of inputting the processed sample insect image into a pre-built initial recognition model to obtain a hierarchical classification prediction result corresponding to the sample insect image output by the initial recognition model includes: Inputting the processed sample insect image into the initial feature extraction layer to obtain a plurality of sample feature vectors of the processed sample insect image output by the initial feature extraction layer; Inputting a plurality of sample feature vectors of the processed sample insect images into the initial feature fusion layer to obtain a sample fusion feature vector of the processed sample insect images output by the initial feature fusion layer; The sample fusion feature vector of the processed sample insect image is input into the initial hierarchical classification layer to obtain the hierarchical classification prediction result corresponding to the sample insect image output by the initial hierarchical classification layer.
9. The insect classification method based on multi-task convolutional neural network according to claim 7, characterized in that: Based on the hierarchical classification prediction results corresponding to the sample insect images and the hierarchical classification labels of the sample insect images, a total loss function value is calculated, including: Calculating a cross entropy loss function value based on the hierarchical classification prediction result corresponding to the sample insect image and the hierarchical classification label of the sample insect image; Based on the hierarchical classification prediction results corresponding to the sample insect image, determine whether any two adjacent classification prediction results belong to a subordinate relationship between a parent class and a child class, obtain a determination result, and calculate a dependency layer loss function value according to the determination result; The total loss function value is calculated based on the cross entropy loss function value and the dependent layer loss function value.
10. An insect classification device based on a multi-task convolutional neural network, characterized in that: include: An acquisition unit, used for acquiring an image of an insect to be identified; A processing unit, used for performing image enhancement processing on the insect image to obtain a processed insect image; A recognition unit, used for inputting the processed insect image into a pre-built recognition model to obtain a hierarchical classification result corresponding to the insect image output by the recognition model; The recognition model is obtained by training based on processed sample insect images and hierarchical classification labels of the sample insect images.
Citation Information
Cited By
Insect grading and classifying method and system based on multi-task convolutional neural network
CN120198940A
Insect hierarchical classification method and system based on multi-task convolutional neural network
CN120198940B
