Pest detection and expelling method based on sound recognition

By extracting Mel spectrum features and optimizing the AST model for pest identification, and combining it with confidence threshold to trigger the sound waves of natural enemies, the problem of environmental pollution and low identification accuracy in traditional pest control is solved, achieving efficient and environmentally friendly pest control.

CN121122291APending Publication Date: 2025-12-12JIANGNAN UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511115704.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-11
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

Traditional agricultural pest control relies on chemical pesticides, leading to environmental pollution. Acoustic control methods suffer from inaccurate spectral feature extraction, low identification accuracy, and a lack of targeted repelling strategies.

Method used

Mel spectrum feature extraction technology is used to accurately capture the acoustic features of pests, the AST model is optimized for classification and identification, and the sound waves of natural enemies are triggered for precise intervention through confidence threshold.

Benefits of technology

It improves the accuracy of pest identification, reduces the false alarm rate in noisy environments, enables precise intervention on demand, and reduces chemical pesticide pollution and ecological damage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121122291A_ABST
    Figure CN121122291A_ABST
Patent Text Reader

Abstract

The invention discloses a method for detecting and expelling pests based on sound recognition, which comprises the following steps: acquiring original sound signals of the pests, preprocessing to obtain a Mel-frequency spectrum feature map, and normalizing to reduce environmental interference; inputting the normalized feature map into an AST model optimized by transfer learning, outputting pest category probability distribution, and taking a probability maximum value as a confidence coefficient to judge a target pest category; when the confidence exceeds a set threshold value, corresponding sound waves in a natural enemy sound library are matched according to pest types to be played in real time, the method effectively solves the problems that traditional linear frequency spectrum high-frequency features are lost and the noise false alarm rate is high, the pest recognition accuracy is remarkably improved, chemical pesticide is replaced with acoustic targeted intervention, and the method is suitable for popularization and application. The risks of environmental pollution and ecological damage are reduced, and precise insect expelling is achieved through biological acoustic interference.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of smart agriculture and acoustic pest control technology, and in particular to a method for detecting and repelling pests based on sound recognition. Background Technology

[0002] Traditional agricultural pest control has long relied on chemical pesticides, which not only causes environmental problems such as soil pollution and eutrophication of water sources, but also leads to the continuous enhancement of pesticide resistance in pests.

[0003] To reduce the use of chemical agents, acoustic control technology has gradually emerged. However, existing sound recognition solutions have significant drawbacks: In the signal processing stage, most methods directly use Fourier transform to generate linear spectrograms. Due to the redundancy of resolution in the low-frequency region and the loss of features in the high-frequency region, the linear spectrum cannot effectively capture the core acoustic markers of pests such as locust wing vibrations and cicada tympanic membrane vibrations. At the recognition algorithm level, the models rely on artificial feature design and are extremely sensitive to farmland wind and rain sounds, mechanical noise, etc., resulting in a high false alarm rate. Furthermore, small sample training makes it difficult for the models to adapt to regional pest variations. In terms of intervention mechanisms, existing equipment can only play fixed frequency sound waves and lacks dynamic matching between pest types and repelling strategies. For example, ultrasound is completely ineffective against non-acoustic Coleoptera pests and cannot distinguish between pests and beneficial insects such as bees. Summary of the Invention

[0004] Therefore, the purpose of this invention is to overcome the problems in the prior art, such as serious environmental pollution caused by reliance on chemical pesticides, inaccurate extraction of spectral features in traditional acoustic control methods, low accuracy in pest identification, and lack of targeted repelling strategies.

[0005] To address the aforementioned technical problems, this invention provides a method for detecting and repelling pests based on sound recognition, comprising the following steps: S1: Collect the original sound signals of pests to form an initial training set, preprocess the original sound signals of pests to obtain Mel spectrum feature maps, and normalize the Mel spectrum feature maps to obtain normalized Mel spectrum feature maps. S2: Optimize the pre-trained AST model to obtain an optimized model, input the normalized Mel-ray spectral feature map into the optimized model, perform pest classification and identification, and obtain the pest category and its corresponding confidence level; S3: When the confidence level exceeds the set threshold, select the corresponding natural enemy sound wave from the preset natural enemy sound library according to the pest category and play it to drive away the target pest.

[0006] In one embodiment of the present invention, step S2, the method for obtaining the optimized model includes the following steps: S2.1: Use the pre-trained AST model as the base model, and freeze all parameters of the first N-1 Transformer encoder layers in the base model, including the parameters of the multi-head self-attention module, the layer normalization module, and the position embedding module, where N is the total number of Transformer encoder layers. S2.2: The publicly available general insect sound dataset is used as the fine-tuning training set. After preprocessing, it is input into the base model to obtain the prediction results. The cross-entropy loss function is used as the loss function for model training. S2.3: Calculate the descent gradient during the training of the base model based on the loss function, and fine-tune the parameters of the Nth Transformer encoder layer and the classification head based on the descent gradient to obtain an optimized model. The classification head consists of a layer normalization module and a linear projection layer.

[0007] In one embodiment of the present invention, the loss function is calculated as follows: , Where L is the loss function. For the fine-tuning training set, the first The true value of each sample For the model obtained from the fine-tuning training set, the first... The predicted value of a sample, wherein the true value refers to the actual class of each sample in the fine-tuning training set, and the predicted value refers to the predicted class obtained by the model.

[0008] In one embodiment of the present invention, the method for classifying and identifying pests in step S2 is as follows: inputting the normalized Mel-ray spectral feature map into the optimization model and outputting the probability distribution of pest categories; taking the maximum probability as the confidence level, and the corresponding identification result is the pest category.

[0009] In one embodiment of the present invention, step S1, the method for preprocessing the original audio signal data includes the following steps: S1.1: The original sound signal of the pest is divided into frames, and a window function is applied to each frame of the sound signal to obtain an optimized time-domain frame sequence; S1.2: Perform a Fast Fourier Transform on each frame of the time-domain signal in the time-domain frame sequence to convert the time-domain signal into a frequency-domain signal; S1.3: The frequency domain signal is processed by a Mel filter bank to generate a Mel spectrum feature map.

[0010] In one embodiment of the present invention, the method for obtaining the Mel spectrum feature map is as follows: after taking the logarithm of the energy output by the Mel filter bank, a discrete cosine transform is performed to extract frequency features and obtain the Mel spectrum feature map.

[0011] In one embodiment of the present invention, in step S1, the normalization process employs the following formula: , in, These are the eigenvalues ​​of the normalized Mel-frequency spectral feature map. These are the eigenvalues ​​of the Mel spectrum feature map. The feature mean of all samples in the initial training set. is the standard deviation of the features of all samples in the initial training set.

[0012] In one embodiment of the present invention, in step S3, the method for presetting the natural enemy sound library is as follows: extract natural enemy sound samples from open source datasets and collected insect sound samples, classify and store them according to the pest types corresponding to the natural enemy sound samples; create metadata for each natural enemy sound sample, the metadata including the natural enemy sound identifier, the corresponding pest type, and the storage path of the audio file.

[0013] The present invention also provides an electronic device comprising a processor, a memory, and a bus system, wherein the processor and the memory are connected via the bus system, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to implement the aforementioned method for detecting and repelling pests based on sound recognition.

[0014] In one embodiment of the present invention, the present invention also provides a computer storage medium storing a computer software product, the computer software product including a plurality of instructions for causing a computer device to execute the aforementioned method for detecting and repelling pests based on sound recognition.

[0015] Compared with the prior art, the above-described technical solution of the present invention has the following advantages: This invention uses Mel spectrum feature extraction technology to accurately capture the specific acoustic features of pests, solving the problem of high-frequency feature loss in traditional linear spectrum; classification and identification based on an optimized model reduces the false alarm rate in noisy environments; and targeted playback of natural enemy sound waves triggered by a confidence threshold enables precise intervention on demand, improving the efficiency of pest control, reducing chemical pesticide pollution and ecological damage, and providing a highly efficient, environmentally friendly, and sustainable pest control paradigm for smart agriculture. Attached Figure Description

[0016] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein... Figure 1 This is a flowchart illustrating the method for detecting and repelling pests based on sound recognition in an embodiment of the present invention. Figure 2 This is a neural network inference flowchart of the pest detection and repulsion method based on sound recognition in an embodiment of the present invention; Figure 3 This is a comparison chart showing the loss values ​​of the pest detection and repulsion method based on sound recognition in the embodiments of the present invention after training with and without a pre-trained model on the training sample set. Detailed Implementation

[0017] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.

[0018] like Figure 1 As shown, the present invention provides a method for detecting and repelling pests based on sound recognition, comprising the following steps: S1: Collect the original sound signals of pests to form an initial training set, preprocess the original sound signals of pests to obtain Mel spectrum feature maps, and normalize the Mel spectrum feature maps to obtain normalized Mel spectrum feature maps. S2: Optimize the pre-trained AST model to obtain an optimized model, input the normalized Mel-ray spectral feature map into the optimized model, perform pest classification and identification, and obtain the pest category and its corresponding confidence level; S3: When the confidence level exceeds the set threshold, select the corresponding natural enemy sound wave from the preset natural enemy sound library according to the pest category and play it to drive away the target pest.

[0019] As can be seen from the above technical solution steps, this invention collects raw sound signals of field pests to construct an initial training set, generates a Mel spectrogram representing the acoustic characteristics of the pests after preprocessing, and then performs normalization processing; inputs the normalized feature map into a learned and optimized AST model, outputs the probability distribution of pest categories and extracts the confidence level, and identifies the pest category when the confidence level exceeds a set threshold; based on the identification results, indexes the data mapping relationship of the natural enemy sound library, plays the corresponding natural enemy sound waves, realizes behavioral interference and biological repulsion of target pests, and constructs a complete technical closed loop from accurate extraction of acoustic features, dynamic intelligent decision-making to biological targeted intervention.

[0020] Specifically, in step S1, the method for preprocessing the original audio signal data includes the following steps: S1.1: The original sound signal of the pest is divided into frames, and a window function is applied to each frame of the sound signal to obtain an optimized time-domain frame sequence; S1.2: Perform a Fast Fourier Transform on each frame of the time-domain signal in the time-domain frame sequence to convert the time-domain signal into a frequency-domain signal; S1.3: The frequency domain signal is processed by a Mel filter bank to generate a Mel spectrum feature map.

[0021] The collected raw signals of pests were processed in frames with a length of 10ms. A 5ms overlap area was set between adjacent frames. The overlap area can prevent errors and distortions in the sound signal in the subsequent feature analysis caused by the frame processing, and helps to balance the temporal resolution and spectral continuity.

[0022] When an audio signal is truncated and framed, energy leakage occurs. The truncation function is an infinitely wide function, while the audio signal has a finite bandwidth; therefore, the energy of the audio signal in the frequency range will be expanded after truncation. According to the sampling theorem, signal recovery is only possible if the sampling frequency exceeds twice the highest frequency of the signal. Therefore, regardless of the sampling frequency, aliasing will occur after truncation. At this point, by using a weighting function, i.e., a window function, to concentrate the energy in the main lobe, a signal closer to the true spectrum can be obtained, reducing energy leakage. Therefore, the Hamming window function, widely used in audio signal processing, is applied to each frame of the truncated audio signal. Considering the short and abrupt nature of insect sounds, a window length of 20ms is chosen to better preserve the frequency characteristics of the original audio signal. The Hamming window function formula is: , Where n represents the sampling point number and N represents the window length.

[0023] Furthermore, a Fast Fourier Transform (FFT) is performed on each frame of the windowed frequency signal to convert the time-domain signal into a frequency-domain signal. The formula for calculating the FFT is as follows: , in, This represents a discrete sound sequence obtained after sampling, where M represents the frame length. The output complex spectrum sequence is then... The amplitude spectrum of the signal is obtained by taking the modulus. .

[0024] The formula for converting the actual frequency scale to the Mel frequency scale is as follows: , in Represents Mel frequency, This represents the actual frequency, measured in Hz.

[0025] Next, the frequency domain signal is passed through a set of Mel filters, and the output energy of each filter is calculated.

[0026] Configure the triangular filter bank and calculate the output of each triangular filter after filtering the signal amplitude spectrum. The calculation formula is as follows: , in These represent the filter coefficients of the corresponding filter. Represents the number of filters. This represents the filtered output.

[0027] Furthermore, the method for obtaining the Mel spectral feature map is as follows: after taking the logarithm of the energy output of the Mel filter bank, a Discrete Cosine Transform (DCT) is performed to extract frequency features, resulting in the Mel spectral feature map (MFCC). The calculation formula is as follows: , Where Q is the order of the MFCC parameters, which is 13. These are the obtained MFCC parameters.

[0028] The natural logarithm of the output energy value of each Mel filter is taken to compress its dynamic range and enhance the significance of low-energy features. A DCT transform is performed on the logarithmic energy sequence to extract frequency features, and the Mel spectrum feature map is obtained as a representation of the sound features.

[0029] like Figure 2 As shown, the extracted feature data is further normalized and the model is trained.

[0030] In step S1, the normalization process uses the following formula: , in, These are the eigenvalues ​​of the normalized Mel-frequency spectral feature map. These are the eigenvalues ​​of the Mel spectrum feature map. The feature mean of all samples in the initial training set. is the standard deviation of the features of all samples in the initial training set.

[0031] The extracted features are normalized to reduce the impact of different scenarios and different acquisition devices on the features.

[0032] Calculate the mean and standard deviation of all samples in the initial training set, and adjust the Mel spectrum feature map to a distribution with a mean of 0 and a variance of 0.5.

[0033] Furthermore, in step S2, the method for obtaining the optimized model includes the following steps: S2.1: Use the pre-trained AST (Audio Spectrogram Transformer) model as the base model, and freeze all parameters of the first N-1 Transformer encoder layers in the base model, including the parameters of the multi-head self-attention module, layer normalization module and position embedding module, where N is the total number of Transformer encoder layers. S2.2: The publicly available general insect sound dataset is used as the fine-tuning training set. After preprocessing, it is input into the base model to obtain the prediction results. The cross-entropy loss function is used as the loss function for model training. S2.3: Calculate the descent gradient during the training of the base model based on the loss function, and fine-tune the parameters of the Nth Transformer encoder layer and the classification head based on the descent gradient to obtain an optimized model. The classification head consists of a layer normalization module and a linear projection layer.

[0034] During the model training phase, training samples are first constructed using an international open-source pest dataset. The dataset is then divided into three subsets: a training set, a validation set, and a test set. The training set is used for actual parameter updates and feature difference learning, the validation set is used to evaluate model performance and detect overfitting, and the test set is used to verify the model's generalization ability on unknown data.

[0035] Subsequently, an AST model architecture was built, using a pre-trained model from the open-source AudioSet dataset as its foundation. During the input feature processing stage, the pre-generated Mel spectrogram was segmented into 16×16 block structures, ensuring each block maintained 6ms overlap in the temporal dimension. Each block was then flattened into a 768-dimensional one-dimensional embedding vector using a linear projection layer, and trainable positional embeddings of equal dimension were added to capture the 2D spatial structure of the audio spectrum.

[0036] The key fine-tuning strategy is to freeze all parameters of the first N-1 Transformer encoder layers in the model (including the multi-head self-attention module, layer normalization module, and position embedding module), and only fine-tune the parameters of the classification head composed of the normalization layer and the linear projection layer.

[0037] like Figure 3 As shown, this strategy retains the general spectral feature extraction capability obtained by the encoder pre-training, allowing the classification head to focus on learning pest-specific acoustic patterns. This reduces training time and effectively suppresses the risk of overfitting, achieving accurate mapping of the classification head output to specific pest categories.

[0038] The model extracts sound signal features through forward propagation and selects the cross-entropy loss function to calculate the loss between the model's predicted values ​​and the true values. The formula is as follows: , Where L is the loss function. For the fine-tuning training set, the first The true value of each sample For the model obtained from the fine-tuning training set, the first... The predicted value of a sample, wherein the true value refers to the actual class of each sample in the fine-tuning training set, and the predicted value refers to the predicted class obtained by the model.

[0039] In step S2.3, the method for fine-tuning the optimized model is as follows: the Adam optimization algorithm is used to dynamically adjust the parameters of the unfrozen layer, and the gradient values ​​of the current trainable parameters are calculated through backpropagation of the cross-entropy loss function; then, the first-order moment estimate and the second-order moment estimate are updated based on historical gradient data, the calculated moment estimate values ​​are subjected to bias correction processing, and the corrected moment estimate values ​​are used to update the parameters.

[0040] The results of the loss function are used by the optimizer to adjust the model weights and parameters, with Adam selected as the optimization algorithm.

[0041] Obtain the gradient at the current iteration step t. , The formula for calculating Adam is obtained by taking the derivative of the cross-entropy loss function with respect to the trainable parameters: , , in and This represents a hyperparameter, typically set to 0.9, used to calculate the first moment of the model parameters. (i.e., the mean of the gradient) and the second moment The exponential moving average of (i.e., the uncentered variance of the gradient).

[0042] because and Since these moments are all initialized as vectors, the Adam algorithm needs to correct them to reduce the bias in the initial estimate. The bias calculation formula is as follows: , ; Finally, update the parameters using the corrected moment values: , in, This represents the parameters to be optimized. This represents the learning rate, which is set to 0.00001. This represents a near-zero value added to prevent the divisor from being zero; it is generally... .

[0043] The optimization process updates only the parameters of the unfrozen layer, namely the Nth encoder layer and the classification head, in each iteration, and finally obtains the optimized model.

[0044] Further, in step S2, the method for classifying and identifying pests is as follows: input the normalized Mel-ray spectral feature map into the optimization model, output the probability distribution of pest categories; take the maximum probability as the confidence level, and the corresponding identification result is the pest category.

[0045] The preprocessed normalized Mel-frequency spectral feature map is input into the optimized AST model. Following the same principle as the input feature processing stage described above, the embedded vector is input into the Transformer encoder (parameters frozen through transfer learning). Deep acoustic features are extracted through a multi-head self-attention mechanism. The encoder output is passed through a normalization layer to the classification head (fine-tuning layer), generating a pest category probability distribution vector. Specifically, the classification head outputs a probability vector with a dimension equal to the total number of pest categories. Each element represents the predicted probability of the corresponding pest category. The maximum value in the probability vector is taken as the confidence score, and the corresponding pest category is the classification result.

[0046] The model to be evaluated is tested on the validation set. The classification feature map output by the model is normalized using the sigmoid function to obtain the predicted probability distribution of various pests. The category label with the highest probability value is selected as the final classification prediction result of the model. This prediction result is then compared item by item with the ground truth label of the sample.

[0047] For the multi-classification task (distinguishing between multiple pests) involved in this implementation method, the evaluation uses standard statistics based on the confusion matrix for quantitative analysis: True Positive (TP): The number of samples that the model correctly predicts as positive (i.e., the sample that is predicted as pest A and is actually pest A). False Positive (FP): The number of samples that the model incorrectly predicts as positive (i.e., predicted as pest A but actually other pests or non-pests). False Negative (FN): The number of samples that the model incorrectly predicts as the negative class (i.e., the sample is actually pest A but the model predicts it as another pest or a non-pest). True Negative (TN): The number of samples that the model correctly predicts as negative (i.e., samples that are actually other pests or non-pests, but the model also predicts as not being that pest). In multi-class classification, TN calculation needs to be applied to a specific class, that is, all samples that do not belong to that class and have not been predicted as that class.

[0048] Based on the above statistics, the core evaluation indicators are calculated as follows: Precision: Reflects the accuracy of prediction results. It refers to the proportion of samples that the model predicts to be positive, but which are actually positive. The formula is: ; Recall: Reflects the model's ability to identify positive samples. It refers to the proportion of true positive samples that are correctly predicted as positive by the model. The formula is: .

[0049] Overall evaluation value: The model performance is comprehensively evaluated by taking into account precision and recall (e.g., F1 score, as the harmonic average of the two) and combining them with other relevant indicators (such as accuracy, AUC, etc.).

[0050] By statistically analyzing the prediction results of all samples on the validation set, the evaluation index values ​​of the model for each pest category and overall were calculated. Finally, the model parameter states that performed best on the validation set were selected as the final model parameters for actual deployment, ensuring that the model has good generalization ability and practical recognition reliability.

[0051] As shown in Table 1, the actual evaluation results show that the model implemented in this way achieved high accuracy and recall in the classification task of 9 target pests on the test set, which fully verified the effectiveness of the model training method and evaluation strategy, as well as the reliability and practicality of the final deployed model.

[0052] Table 1:

[0053] Further, in step S3, the method for presetting the natural enemy sound library is as follows: extract natural enemy sound samples from open source datasets and collected insect sound samples, classify and store them according to the pest types corresponding to the natural enemy sound samples; create metadata for each natural enemy sound sample, the metadata including the natural enemy sound identifier, the corresponding pest type, and the storage path of the audio file.

[0054] The sounds of pests collected, detected, and classified in real time are stored in a MySQL relational database in the form of pest species, collection timestamp, and confidence level of model recognition, thus meeting the persistence requirements of real-time detection data.

[0055] Once the optimized model successfully identifies the sounds of pests, it saves the sounds and adaptively matches them with the natural enemies of the pests. Then, it plays the corresponding sounds of the natural enemies to interfere with the behavior of the pests and drive them away, thereby achieving the effect of preventing and controlling pests and diseases.

[0056] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0057] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0058] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0059] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0060] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.

Claims

1. A method for detecting and repelling pests based on sound recognition, characterized in that, Includes the following steps: S1: Collect the original sound signals of pests to form an initial training set, preprocess the original sound signals of pests to obtain Mel spectrum feature maps, and normalize the Mel spectrum feature maps to obtain normalized Mel spectrum feature maps. S2: Optimize the pre-trained AST model to obtain an optimized model, input the normalized Mel-ray spectral feature map into the optimized model, perform pest classification and identification, and obtain the pest category and its corresponding confidence level; S3: When the confidence level exceeds the set threshold, select the corresponding natural enemy sound wave from the preset natural enemy sound library according to the pest category and play it to drive away the target pest.

2. The method for detecting and repelling pests based on sound recognition according to claim 1, characterized in that: In step S2, the method for obtaining the optimized model includes the following steps: S2.1: Use the pre-trained AST model as the base model, and freeze all parameters of the first N-1 Transformer encoder layers in the base model, including the parameters of the multi-head self-attention module, the layer normalization module, and the position embedding module, where N is the total number of Transformer encoder layers. S2.2: The publicly available general insect sound dataset is used as the fine-tuning training set. After preprocessing, it is input into the base model to obtain the prediction results. The cross-entropy loss function is used as the loss function for model training. S2.3: Calculate the descent gradient during the training of the base model based on the loss function, and fine-tune the parameters of the Nth Transformer encoder layer and the classification head based on the descent gradient to obtain an optimized model. The classification head consists of a layer normalization module and a linear projection layer.

3. The method for detecting and repelling pests based on sound recognition according to claim 2, characterized in that: The formula for calculating the loss function is as follows: , Where L is the loss function. For the fine-tuning training set, the first The true value of each sample For the model obtained from the fine-tuning training set, the first... The predicted value of a sample, wherein the true value refers to the actual class of each sample in the fine-tuning training set, and the predicted value refers to the predicted class obtained by the model.

4. The method for detecting and repelling pests based on sound recognition according to claim 1, characterized in that: In step S2, the method for classifying and identifying pests is as follows: input the normalized Mel-frequency spectrum feature map into the optimization model, output the probability distribution of pest categories; take the maximum probability as the confidence level, and the corresponding identification result is the pest category.

5. The method for detecting and repelling pests based on sound recognition according to claim 1, characterized in that: Step S1, the method for preprocessing the original audio signal data includes the following steps: S1.1: The original sound signal of the pest is divided into frames, and a window function is applied to each frame of the sound signal to obtain an optimized time-domain frame sequence; S1.2: Perform a Fast Fourier Transform on each frame of the time-domain signal in the time-domain frame sequence to convert the time-domain signal into a frequency-domain signal; S1.3: The frequency domain signal is processed by a Mel filter bank to generate a Mel spectrum feature map.

6. The method for detecting and repelling pests based on sound recognition according to claim 5, characterized in that: The method for obtaining the Mel spectrum feature map is as follows: after taking the logarithm of the energy output of the Mel filter bank, perform discrete cosine transformation to extract frequency features and obtain the Mel spectrum feature map.

7. The method for detecting and repelling pests based on sound recognition according to claim 1, characterized in that: In step S1, the normalization process uses the following formula: , in, These are the eigenvalues ​​of the normalized Mel-frequency spectral feature map. These are the eigenvalues ​​of the Mel spectrum feature map. The feature mean of all samples in the initial training set. is the standard deviation of the features of all samples in the initial training set.

8. The method for detecting and repelling pests based on sound recognition according to claim 1, characterized in that: In step S3, the method for presetting the natural enemy sound library is as follows: extract natural enemy sound samples from open source datasets and collected insect sound samples, classify and store them according to the pest types corresponding to the natural enemy sound samples; create metadata for each natural enemy sound sample, the metadata including the natural enemy sound identifier, the corresponding pest type, and the storage path of the audio file.

9. An electronic device, characterized in that, The electronic device includes a processor, a memory, and a bus system, wherein the processor and the memory are connected via the bus system, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to implement the method for detecting and repelling pests based on sound recognition as described in any one of claims 1 to 8.

10. A computer storage medium, characterized in that, The computer storage medium stores a computer software product, the computer software product including a plurality of instructions for causing a computer device to execute the method for detecting and repelling pests based on sound recognition as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Pest repellent method and device

    CN104738024A

  • Borborygmus recognition method and device

    CN116687438A

  • Chicken flock state inspection monitoring system and method

    CN119989281A

  • Underwater sound target radiation noise classification method

    CN120164481A