Rice insect pest detection method, device, equipment and medium

By updating the backbone network and detection head module of the YOLOv8n model, combining the receptive field attention convolution and mixed local channel attention mechanism, the problem of small targets and complex background in rice pest detection is solved, and more efficient and accurate pest detection is achieved .

CN119478515APending Publication Date: 2025-02-18SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411570963.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-06
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the prior art, due to the small target of rice pest detection and complex detection background, the detection effect of using the original low-parameter YOLOv8 model is poor, while using high-parameter detection will cause problems such as larger models.

Method used

Update the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model to receptive field attention convolution, add a hybrid local channel attention mechanism to the neck network, update the detection head module to the Dyhead detection head, and add small target detection head module to construct rice pest detection model.

Benefits of technology

The model's rice pest detection capability in complex contexts is improved, and the pest detection can be more accurately identified and located, which significantly improves the accuracy and reliability of the detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478515A_ABST
    Figure CN119478515A_ABST
Patent Text Reader

Abstract

The invention relates to a rice pest detection method, device and equipment and a medium, and the method comprises the steps: updating a CSPLayer2Conv convolution in a backbone network of an original YOLOv8n network model to a receptive field attention convolution, adding a mixed local channel attention mechanism in a neck network of the original YOLOv8n network model, updating an original detection head module to a Dyhead detection head, and carrying out the detection of the Dyhead detection head. A small target detection head module is added to construct a rice pest detection model; the to-be-detected rice image is input into the rice insect pest detection model trained to be in a convergence state, so that a target detection frame of rice insect pests in the to-be-detected rice image and a corresponding rice insect pest category are determined, and the target detection frame is used for indicating the position corresponding to the rice insect pests; and in response to the rice pest control instruction, the unmanned aerial vehicle sprays an insecticide corresponding to the rice pest category to a position corresponding to the rice pest so as to complete detection of the rice pest in the rice field. According to the application, efficient and accurate rice insect pest detection and killing treatment are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of agricultural production, and in particular to a rice pest detection method, a corresponding device, an electronic device and a computer-readable storage medium. Background Art

[0002] Rice pests are an important factor affecting global rice production and quality. Common pests include rice planthoppers, rice leaf rollers, and rice borers. These pests suck rice sap, feed on leaves and stems, causing the plants to wilt and break, and reducing yield and quality, causing significant economic losses to farmers.

[0003] YOLOv8 is the latest version of the YOLO (You Only Look Once) series of models, a deep learning model for object detection. The YOLO model is known for its efficient real-time detection capabilities. It has been evolving since it was first proposed, combining the advantages of previous generations of models and optimizing them in many aspects. YOLOv8 has made further improvements in network architecture, loss function, and training strategy, enhancing detection accuracy and speed. YOLOv8 also provides versions with different sizes and complexities, represented by the suffixes of "n, s, m, l, x". The "n" version is characterized by a small number of model parameters and fast processing speed, but poor accuracy; the "x" version is characterized by a large number of model parameters and high complexity, which can provide higher accuracy, but slow processing speed and require more computing resources. Compared with the previous versions v1 to v7, YOLOv8 uses a lighter network structure and advanced data enhancement technology, which can better handle objects of different scales and complex background environments. YOLOv8 performs well in various object detection tasks and is widely used in autonomous driving, security monitoring, drone monitoring and other fields.

[0004] Since rice pests pose a great threat to rice and their outbreaks are time-sensitive, accurate and timely detection is the key to preventing pests. Using YOLOv8 to detect rice pests is a good solution, but since the rice pest detection target is small and the detection background is complex, the detection effect of the original low-parameter YOLOv8 model is poor, while using high-parameter detection will cause major problems in the model and make it inconvenient to deploy the model.

[0005] To sum up, in the prior art, due to the small rice pest detection target and complex detection background, the detection effect of using the original low-parameter YOLOv8 model is poor, while the use of high-parameter detection will cause the model to be larger. The applicant has made corresponding explorations to solve this problem. Summary of the invention

[0006] The purpose of the present application is to solve the above-mentioned problems and to provide a rice pest detection method, a corresponding device, an electronic device and a computer-readable storage medium.

[0007] In order to meet the various objectives of this application, this application adopts the following technical solutions:

[0008] A rice pest detection method proposed to meet one of the purposes of this application comprises:

[0009] In response to an instruction to detect rice pests in a rice field, an image of rice to be detected containing rice pests is obtained from an onboard camera of a drone;

[0010] The CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model was updated to the receptive field attention convolution, a hybrid local channel attention mechanism was added to the neck network of the original YOLOv8n network model, the original detection head module was updated to the Dyhead detection head, and a small target detection head module was added to build a rice pest detection model;

[0011] Inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category, wherein the target detection frame is used to indicate a corresponding position of the rice pests;

[0012] In response to the rice pest control instruction, the drone sprays the pesticide corresponding to the rice pest category to the location corresponding to the rice pest to complete the detection of rice pests in the paddy field.

[0013] Optionally, the step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category includes:

[0014] The receptive field attention convolution dynamically generates features according to the size of the convolution kernel, and each convolution kernel has a corresponding receptive field to cover a specific area of ​​the input feature map;

[0015] A Group Conv method is used to extract features from the receptive field to determine receptive field features;

[0016] Apply average pooling to each receptive field feature to aggregate global information;

[0017] After average pooling, a 1x1 group convolution operation is performed to further process the receptive field features;

[0018] The output of the 1x1 group convolution is processed by Softmax to generate the importance weights of the features within each receptive field.

[0019] Optionally, the step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category includes:

[0020] In the hybrid local channel attention mechanism, local average pooling and global average pooling are used to process the input feature map to determine the local pooled features and the global pooled features, wherein the local average pooling is used to focus on the features of the local area, and the global average pooling is used to capture the statistical information of the entire feature map;

[0021] The features after local pooling and the features after global pooling are transformed through a 1D convolution.

[0022] The local pooled features are rearranged after 1D convolution and combined with the original input features through multiplication to enhance the focus on useful features;

[0023] The global pooled features are combined with the local pooled features through addition operations after 1D convolution and rearrangement to integrate the global context information in the feature map;

[0024] The feature map processed by local and global attention is restored to its original spatial dimension through unpooling operation again.

[0025] Optionally, the Dyhead detection head includes a scale-aware attention module, a space-aware attention module and a task-aware attention module.

[0026] Optionally, the step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category includes:

[0027] In the scale-aware attention module of the Dyhead detection head, the feature tensor F is processed by average pooling to extract global features;

[0028] 1x1 convolution is used to reduce the number of feature channels, and nonlinear transformation is performed through ReLU activation function and hard Sigmoid function to capture rice pests of different sizes;

[0029] In the spatial perception attention module, features are processed by offset learning and 3x3 convolution for spatial feature focusing to locate rice pests in complex backgrounds;

[0030] The features are processed through the fully connected layer, combined with the ReLU activation function and normalization operation, and the weights of each channel of the feature map are adjusted according to the rice pest detection task to identify the category and location of rice pests.

[0031] Optionally, the step of spraying the pesticide corresponding to the rice pest category to the location corresponding to the rice pest to complete the detection of rice pests in the paddy field includes:

[0032] Calling a rice pest detection model that has been trained to a convergence state, and performing target detection on the rice image to be detected based on the rice pest detection model to determine the number corresponding to different rice pest categories;

[0033] The dosage of the pesticide corresponding to the rice pest category is determined according to the quantity corresponding to the rice pest category, and the pesticide corresponding to the rice pest category is sprayed to the corresponding position of the rice pest to complete the detection of rice pests in the paddy field.

[0034] Optionally, the basic network architecture of the rice pest detection model is an improved YOLOv8n network model, and the rice pest categories include one or any multiple of rice leaf roller, striped stem borer, gray planthopper, rice stem borer, rice stem borer or green rice stink bug.

[0035] A rice pest detection device provided for another purpose of the present application comprises:

[0036] A rice image acquisition module is configured to respond to an instruction to detect rice pests in a rice field and acquire an image of rice to be detected containing rice pests from an onboard camera of a drone;

[0037] A detection model building module is set to update the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model to a receptive field attention convolution, add a hybrid local channel attention mechanism in the neck network of the original YOLOv8n network model, update the original detection head module to a Dyhead detection head, and add a small target detection head module to build a rice pest detection model;

[0038] a rice pest detection module, configured to input the rice image to be detected into a rice pest detection model that has been trained to a convergence state, so as to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category, wherein the target detection frame is used to indicate a position corresponding to the rice pest;

[0039] The rice pest control module is configured to respond to rice pest control instructions, and the drone sprays the pesticide corresponding to the rice pest category to the corresponding position of the rice pest to complete the detection of rice pests in the paddy field.

[0040] An electronic device provided to meet another purpose of the present application includes a central processing unit and a memory, wherein the central processing unit is used to call and run a computer program stored in the memory to execute the steps of the rice pest detection method described in the present application.

[0041] A computer-readable storage medium is provided to meet another purpose of the present application, which stores a computer program implemented according to the rice pest detection method in the form of computer-readable instructions. When the computer program is called and executed by a computer, the steps included in the corresponding method are executed.

[0042] Compared with the prior art, the present application aims at the problems that the detection target of rice pest is small, the detection background is complex, the detection effect of the original low-parameter YOLOv8 model is poor, and the use of high-parameter detection will cause the model to be larger. The present application includes but is not limited to the following beneficial effects:

[0043] First, the present application updates the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model to a receptive field attention convolution, adds a hybrid local channel attention mechanism to the neck network of the original YOLOv8n network model, updates the original detection head module to a Dyhead detection head, and adds a small target detection head module to build a rice pest detection model. The rice image to be detected is dynamically analyzed and enhanced in the receptive field attention convolution, so that the model's detection ability of rice pests in complex backgrounds is improved. This improvement enables the model to not only identify pests, but also locate them more accurately;

[0044] Secondly, the hybrid local channel attention mechanism in the rice pest detection model of the present application enables the model to better balance between local details and global context, thereby improving the overall accuracy of rice pest detection, especially in the detection task of small targets, which can significantly improve the accuracy and reliability of detection. The hybrid local channel attention mechanism plays a key role in the rice pest detection model, making the model more effective in pest identification under complex backgrounds;

[0045] Third, after the rice image to be detected is input into the Dyhead detection head, the model can more comprehensively understand and capture the detailed information in the image. These modules combine local and global information to effectively improve the detection accuracy, especially when facing small targets, ensuring the accurate detection and location of pests. This multi-level attention mechanism makes the rice field pest detection model perform better in complex environments;

[0046] Furthermore, the present application realizes efficient and accurate rice pest detection and control, which not only improves the yield and quality of crops, but also provides new ideas and solutions for agricultural modernization. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0048] Figure 1 An exemplary network architecture used in the rice pest detection method of this application;

[0049] Figure 2 This is an example diagram of rice pests in the embodiments of the present application;

[0050] Figure 3 This is a schematic diagram of a scatter heat map of the size of detected targets in a rice pest dataset in an embodiment of the present application;

[0051] Figure 4 Schematic diagram of the training results of different YOLOv8 networks in the embodiments of the present application;

[0052] Figure 5 Schematic diagram of the working structure of RFAConv in an embodiment of the present application;

[0053] Figure 6 A schematic diagram of the working structure of MLCA in an embodiment of the present application;

[0054] Figure 7 A schematic diagram of the DynamicHead detection head structure in an embodiment of the present application;

[0055] Figure 8 A schematic diagram of a model structure in which four DynamicHead detection heads are added in an embodiment of the present application;

[0056] Fig. 9 An exemplary network architecture of the improved YOLOv8n network model in the embodiments of the present application;

[0057] Fig.10 This is a principle block diagram of a rice pest detection device in an embodiment of the present application;

[0058] Fig.11 It is a schematic diagram of the structure of the computer device in the embodiment of the present application. DETAILED DESCRIPTION

[0059] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.

[0060] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0061] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.

[0062] It will be understood by those skilled in the art that the "client", "terminal" and "terminal device" used herein include both devices with wireless signal receivers, which are devices with only wireless signal receivers without transmission capabilities, and devices with receiving and transmitting hardware, which are devices with receiving and transmitting hardware capable of two-way communication on a two-way communication link. Such devices may include: cellular or other communication devices such as personal computers, tablet computers, which have single-line displays or multi-line displays or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service, personal communication system), which can combine voice, data processing, fax and / or data communication capabilities; PDA (Personal Digital Assistant, personal digital assistant), which may include a radio frequency receiver, pager, Internet / intranet access, web browser, notepad, calendar and / or GPS (Global Positioning System, global positioning system) receiver; conventional laptop and / or palmtop computers or other devices, which have and / or include a conventional laptop and / or palmtop computer or other device with and / or including a radio frequency receiver. The "client", "terminal" and "terminal device" used herein may be portable, transportable, installed in a vehicle (air, sea and / or land), or suitable for and / or configured to run locally, and / or in a distributed form, at any other location on the earth and / or in space. The "client", "terminal" and "terminal device" used herein may also be a communication terminal, an Internet terminal, a music / video playing terminal, for example, a PDA, a MID (Mobile Internet Device) and / or a mobile phone with a music / video playing function, or a smart TV, a set-top box and other devices.

[0063] The hardware referred to by the names such as "server", "client", and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann principle, such as a central processing unit (including an arithmetic unit and a controller), a memory, an input device, and an output device. The computer program is stored in its memory, and the central processing unit calls the program stored in the external memory into the internal memory for execution, executes the instructions in the program, and interacts with the input and output devices to complete specific functions.

[0064] It should be pointed out that the concept of "server" referred to in this application can also be extended to the case of server clusters. According to the network deployment principle understood by those skilled in the art, the servers should be logically divided. In physical space, these servers can be independent of each other but can be called through interfaces, or integrated into a physical computer or a set of computer clusters. Those skilled in the art should understand this flexibility, and should not use it to restrict the implementation of the network deployment method of this application.

[0065] Unless expressly specified, one or more technical features of the present application can be deployed on a server for implementation and accessed by a client through a remote call to obtain an online service interface provided by the server, or can be directly deployed and run on a client for access.

[0066] The neural network models referenced or may be referenced in this application, unless expressly specified, can be deployed on a remote server and remotely called on the client, or can be deployed and directly called on a client with sufficient device capabilities. In some embodiments, when it runs on the client, its corresponding intelligence can be obtained through transfer learning to reduce the requirements for the client's hardware operating resources and avoid excessive occupation of the client's hardware operating resources.

[0067] Unless explicitly specified, the various data involved in this application can be stored remotely on a server or on a local terminal device, as long as it is suitable for being called by the technical solution of this application.

[0068] Those skilled in the art should be aware that, although the various methods of the present application are described based on the same concept and thus present commonality to each other, unless otherwise specified, these methods can be independently executed. Similarly, for each embodiment disclosed in the present application, they are all proposed based on the same inventive concept, therefore, concepts with the same expression, and concepts that are appropriately changed for convenience despite different expressions, should be understood as equivalent.

[0069] Unless the mutually exclusive relationship between the embodiments to be disclosed in this application is explicitly stated, the relevant technical features involved in each embodiment can be cross-combined to flexibly construct a new embodiment, as long as such combination does not deviate from the creative spirit of this application and can meet the needs of the prior art or solve certain deficiencies in the prior art. Those skilled in the art should be aware of this flexibility.

[0070] See also Figure 1 In one embodiment, the rice pest detection method of the present application comprises:

[0071] Step S10, responding to an instruction to detect rice pests in a rice field, obtaining an image of rice to be detected containing rice pests from an onboard camera of the drone;

[0072] The rice pest detection system can respond to the instruction of rice pest detection in the rice field, and obtain the rice image to be detected containing rice pests from the airborne camera of the drone; the rice pest categories include one or any multiple of rice leaf roller, striped stem borer, gray planthopper, rice borer, rice stem borer or rice green stink bug.

[0073] In some embodiments, a mobile phone or an airborne camera of a drone can be used to collect images of rice to be detected that contain rice pests, including six types of pests: rice leaf roller, striped stem borer, gray planthopper, rice borer, rice stem borer, and green stink bug. Select a time period with sufficient light to ensure that the captured images are clear enough, and slice the collected photos at the same time. Selecting the slicing operation not only facilitates data annotation, but also facilitates the neural network to better extract features. Then use Labelimg annotation software to annotate the image, such as Figure 2 As shown in the figure, after the labeling is completed, an XML file containing classification label information and coordinate information is generated. Then, the dataset is expanded using image augmentation methods such as random cropping, rotation, and random color to obtain a rice pest dataset. Finally, the XML file is converted into a txt file that can be used for model training. Figure 3 As shown in the figure, the dataset is divided into training set, test set and validation set in the ratio of 8.5:1:0.5.

[0074] In some embodiments, YOLOv8n is a lightweight target detection model in the YOLO family, designed to provide fast and accurate real-time detection. It is architecturally optimized for resource-limited devices such as mobile terminals and embedded systems. YOLOv8n combines advanced data enhancement techniques to handle object recognition at a variety of scales and conditions.

[0075] Furthermore, five network structures of YOLOv8 (YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x) were trained on the rice pest dataset. YOLOv8n was selected as the improved basic network by comparing the detection accuracy, detection speed, and model size. On the basis of YOLOv8n, improvement measures such as addition and replacement were made to the network. The specific process is as follows:

[0076] Select 640×640 pixels as the image size of the input model, select SGD as the optimizer of the model, set the initial optimizer learning rate to 0.01, weight decay to 0.0005, model training times to 200, batch size to 16. Train five YOLOv8 networks of different depths and widths: n, s, m, l, x, and the training results are shown in the figure. Figure 4 As shown in the figure, YOLOv8n is selected as the basic network architecture by evaluating the detection accuracy, detection speed, and model size of the training results.

[0077] The detection accuracy (AP), model size and detection speed are used to evaluate the model. The precision (P) refers to the ratio of all samples predicted as positive to true positives. The recall (R) refers to the ratio of all positive samples that are correctly predicted as positive. AP refers to the area of ​​the PR (precision recall) curve. The specific calculation formula is shown in the formula:

[0078]

[0079] TP: Correct positive, indicating that the prediction is positive, and if the prediction is correct, then the actual case is also a positive example;

[0080] TN: True negative, which means the prediction is negative, and the prediction is correct, so the actual example is also a negative example. FP: False positive, which means the prediction is positive, but the prediction is wrong, so the actual example is a negative example.

[0081] FN: False negative, which means the prediction is negative, the prediction is wrong, so it is actually a positive example.

[0082] Step S20, updating the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model to a receptive field attention convolution, adding a hybrid local channel attention mechanism to the neck network of the original YOLOv8n network model, updating the original detection head module to a Dyhead detection head, and adding a small target detection head module to build a rice pest detection model;

[0083] After obtaining the rice image to be detected containing rice pests from the drone's airborne camera, the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model is updated to the receptive field attention convolution, a hybrid local channel attention mechanism is added to the neck network of the original YOLOv8n network model, the original detection head module is updated to the Dyhead detection head, and a small target detection head module is added to build a rice pest detection model, wherein the basic network architecture of the rice pest detection model is the improved YOLOv8n network model.

[0084] In some embodiments, the original CSPLayer_2Conv convolution is replaced by the receptive field attention convolution (RFAConv) in the backbone network of the original YOLOv8n. The working structure of the receptive field attention convolution (RFAConv) is as follows: Figure 5 shown.

[0085] First, RFA defines a design for convolution kernels, where these features are dynamically generated based on the kernel size. This means that each convolution kernel will have a corresponding receptive field that covers a specific area of ​​the input feature map; then the features of each receptive field are extracted through the Group Conv method. The Group Conv method is a fast and more parameter-efficient alternative. Then for each receptive field feature, average pooling is used to aggregate global information, which helps capture the statistical characteristics within the entire receptive field. After average pooling, a 1x1 group convolution operation is applied to further process the receptive field features, which helps feature interactions within the group. The output of the 1x1 group convolution is normalized by the Softmax function to generate the importance weights of the features within each receptive field. These weights reflect the importance of the features in the current task. After applying Softmax, the shape of the feature maps may need to be adjusted to ensure that they are compatible with subsequent network layers. Finally, the attention weights generated by Softmax are combined with the original receptive field features. In this way, each convolution kernel will get different weights according to its corresponding receptive field features, thus solving the problem of convolution kernel parameter sharing.

[0086] Through this series of operations, RFA can generate unique attention weights for each convolution kernel, allowing the network to pay more attention to important feature areas, thereby improving the detection effect of the model in complex backgrounds.

[0087] In a further embodiment, a hybrid local channel attention mechanism (MLCA) is added to the neck network (Neck) of the original YOLOv8n, the original detection head module is replaced by the Dyhead (Dynami cHead) detection head, and a small target detection head module is added. The process is as follows:

[0088] Adding a mixed local channel attention mechanism (MLCA) to the neck network (Neck) improves accuracy by combining channel and spatial attention at local and global levels.

[0089] The working structure of the hybrid local channel attention mechanism (MLCA) is as follows Figure 6 As shown:

[0090] The input feature map (C, W, H) is first processed by local average pooling (LAP) and global average pooling (GAP). Local pooling focuses on the features of the local area, while global pooling captures the statistical information of the entire feature map. Both the local pooled features and the global pooled features are transformed by a 1D convolution (Convd). The 1D convolution here is used to compress the feature channels while keeping the spatial dimension unchanged. After the 1D convolution, the features are rearranged (Reshape) to adapt to subsequent operations. The local pooled features are rearranged after 1D convolution and then combined with the original input features through a "multiplication" operation (X). This process is equivalent to a feature selection that strengthens the focus on useful features. After the global pooled features are 1D convolved and rearranged, they are combined with the local pooled features through an "addition" operation. This step incorporates global context information in the feature map. Finally, the feature map processed by local and global attention is restored to its original spatial dimension through an unpooling (UNAP) operation again.

[0091] In a further embodiment, a Dyhead (DynamicHead) detection head is used to replace the original detection head module. The structure of the Dyhead (DynamicHead) detection head is as follows: Figure 7 As shown. Scale-aware attention (π L ), spatial perception attention (π S ), and task-aware attention (π C ) correspond to different modules, each module is aimed at different dimensions of the feature tensor F (level L, space S, channel C).

[0092] The scale-aware attention module uses average pooling, 1x1 convolution, ReLU activation function, and hard Sigmoid function. The scale-aware attention can be expressed by the following formula:

[0093]

[0094] Among them, F is the feature tensor, σ is the activation function, S and C represent the spatial dimension and channel dimension of the feature respectively.

[0095] The spatial awareness attention module includes offset learning and 3x3 convolution. The spatial awareness attention can be expressed as:

[0096]

[0097] Among them, ω l,k is the learned weight, p k is the base sampling position, Δp k is the learned offset and K is the total number of sampled positions.

[0098] The task-aware attention module is processed through a fully connected layer, a ReLU activation function, and a normalization operation. Task-aware attention can be expressed as:

[0099] π C (F) = max{α(F)·F c +β(F),γ(F)·F c +δ(F)},

[0100] Among them, F c is the feature of a specific channel, α, β, γ, δ are the learned weights, which are calculated by a hyperfunction θ(·).

[0101] Based on the use of Dyhead (DynamicHead) detection head to replace the original detection head, considering that the rice pest detection target is small, a detection head is added to the P2 layer on the Backbone of YOLOv8 on the basis of the three detection heads. Because the Backbone of YOLOv8 is based on a pyramid structure, the upper layers have higher resolution and smaller receptive field, which enables the model to better capture the details of small-sized targets.

[0102] The model structure after adding four Dynami cHead (Dyhead) detection heads is shown below Figure 8 As shown, the specific added steps are:

[0103] The result of the CSPLayer_2Conv operation of the P3 layer in Backbone is combined with the upsampled value in the Neck layer and then the CSPLayer_2Conv operation is performed. Then the upsampling operation is combined with the result of the CSPLayer_2Conv operation of the P2 layer and then the CSPLayer_2Conv operation is performed. Then the Dynami cHead (Dyhead) detection head is connected for detection.

[0104] The improved YOLOv8n network model is named YOLOv8-RMD. The structure of the improved YOLOv8n network model is as follows Fig. 9 As shown, the improved YOLOv8n network model of the present application achieves a significant improvement in the accuracy of rice pest detection while increasing a small number of parameters based on the original model.

[0105] In some embodiments, the network is improved for deployment, and a web application interface is built to detect rice field pests. The specific process is as follows:

[0106] Use the st.sidebar.file_uploader() function to load the image to be detected, and use the YOLO function of YOLOv8 to load the model we have trained in advance to recognize the imported photos. Then use the st.image() function to draw the recognized results on the loaded image to display the results. Each recognition function adds a conf parameter, which represents the confidence threshold of the recognition, and is adjusted by the st.sidebar.slider() function. Similarly, video recognition and real-time camera recognition are also implemented in this way.

[0107] Step S30, inputting the rice image to be detected into a rice pest detection model that has been trained to a convergence state, so as to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category, wherein the target detection frame is used to indicate the corresponding position of the rice pests;

[0108] After the rice pest detection model is constructed, the rice image to be detected is input into the rice pest detection model that has been trained to a convergence state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category, wherein the target detection frame is used to indicate the corresponding position of the rice pest;

[0109] In some embodiments, the step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category includes:

[0110] Step S301, the receptive field attention convolution dynamically generates features according to the size of the convolution kernel, and each convolution kernel has a corresponding receptive field to cover a specific area of ​​the input feature map;

[0111] Step S302: extracting features from the receptive field using a Group Conv method to determine receptive field features;

[0112] Step S303: applying average pooling to each receptive field feature to aggregate global information;

[0113] Step S304: After average pooling, a 1x1 group convolution operation is performed to further process the receptive field features;

[0114] Step S305: Perform Softmax processing on the output of the 1x1 group convolution to generate the importance weight of the features in each receptive field.

[0115] Through the above processing, the rice image to be detected is dynamically analyzed and enhanced in the receptive field attention convolution, which improves the model's ability to detect rice pests in complex backgrounds. This improvement enables the model to not only identify pests, but also locate them more accurately.

[0116] Furthermore, the step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category includes:

[0117] Step S3001: In the hybrid local channel attention mechanism, local average pooling and global average pooling are used to process the input feature map to determine the local pooled features and the global pooled features, wherein the local average pooling is used to focus on the features of the local area, and the global average pooling is used to capture the statistical information of the entire feature map;

[0118] Step S3002: The local pooled features and the global pooled features are transformed by a 1D convolution.

[0119] Step S3003: Rearrange the local pooled features using 1D convolution and combine them with the original input features through multiplication operations to enhance the focus on useful features;

[0120] Step S3004: After 1D convolution and rearrangement, the globally pooled features are combined with the locally pooled features through an addition operation to integrate the global context information into the feature map;

[0121] Step S3005: The feature map processed by local and global attention is restored to its original spatial dimension through the unpooling operation again.

[0122] Through the above processing, the hybrid local channel attention mechanism enables the model to better balance between local details and global context, thereby improving the overall accuracy of rice pest detection, especially in the detection task of small targets, which can significantly improve the accuracy and reliability of detection.

[0123] In summary, the hybrid local channel attention mechanism plays a key role in the rice pest detection model, making the model more effective in pest identification under complex backgrounds.

[0124] Furthermore, the step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category includes:

[0125] Step S3100: In the scale-aware attention module of the Dyhead detection head, the feature tensor F is processed by average pooling to extract global features;

[0126] Step S3200, using 1x1 convolution to reduce the number of feature channels, and performing nonlinear transformation through ReLU activation function and hardSigmoid function to capture rice pests of different sizes;

[0127] Step S3300: In the spatial perception attention module, features are processed by offset learning and 3x3 convolution to perform spatial feature focusing, so as to locate rice pests in a complex background;

[0128] Step S3400: Process the features through a fully connected layer, combine the ReLU activation function and the normalization operation, and adjust the weights of each channel of the feature map according to the rice pest detection task to identify the category and location of the rice pest.

[0129] After the rice image to be detected is input into the three attention modules in the Dyhead detection head, the model can more comprehensively understand and capture the detailed information in the image. These modules combine local and global information to effectively improve the detection accuracy, especially when facing small targets, ensuring the accurate detection and location of pests. This multi-level attention mechanism makes the rice field pest detection model perform better in complex environments.

[0130] Step S40, in response to the rice pest control instruction, the drone sprays the pesticide corresponding to the rice pest category to the location corresponding to the rice pest to complete the detection of rice pests in the paddy field.

[0131] After determining the target detection frame of the rice pest in the rice image to be detected and its corresponding rice pest category, the spraying drone can respond to the rice pest control instruction, and the drone sprays the pesticide corresponding to the rice pest category to the corresponding position of the rice pest to complete the detection of rice pests in the paddy field.

[0132] In some embodiments, the step of spraying the pesticide corresponding to the rice pest category to the location corresponding to the rice pest to complete the detection of rice pests in the paddy field includes:

[0133] Step S401, calling a rice pest detection model that has been trained to a convergence state, and performing target detection on the rice image to be detected based on the rice pest detection model to determine the number corresponding to different rice pest categories;

[0134] Step S402: Determine the dosage of the pesticide corresponding to the rice pest category according to the number corresponding to the rice pest category, and spray the pesticide corresponding to the rice pest category to the position corresponding to the rice pest to complete the detection of rice pests in the paddy field.

[0135] The above steps achieve efficient and accurate rice pest detection and control, which not only improves the yield and quality of crops, but also provides new ideas and solutions for agricultural modernization.

[0136] As can be seen from the above embodiments, compared with the prior art, the present application aims at the problems that the detection target of rice pests is small, the detection background is complex, the detection effect of the original low-parameter YOLOv8 model is poor, and the use of high-parameter detection will cause the model to be larger. The present application includes but is not limited to the following

[0137] Beneficial effects:

[0138] First, the present application updates the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model to a receptive field attention convolution, adds a hybrid local channel attention mechanism to the neck network of the original YOLOv8n network model, updates the original detection head module to a Dyhead detection head, and adds a small target detection head module to build a rice pest detection model. The rice image to be detected is dynamically analyzed and enhanced in the receptive field attention convolution, so that the model's detection ability of rice pests in complex backgrounds is improved. This improvement enables the model to not only identify pests, but also locate them more accurately;

[0139] Secondly, the hybrid local channel attention mechanism in the rice pest detection model of the present application enables the model to better balance between local details and global context, thereby improving the overall accuracy of rice pest detection, especially in the detection task of small targets, which can significantly improve the accuracy and reliability of detection. The hybrid local channel attention mechanism plays a key role in the rice pest detection model, making the model more effective in pest identification under complex backgrounds;

[0140] Third, after the rice image to be detected is input into the Dyhead detection head, the model can more comprehensively understand and capture the detailed information in the image. These modules combine local and global information to effectively improve the detection accuracy, especially when facing small targets, ensuring the accurate detection and location of pests. This multi-level attention mechanism makes the rice field pest detection model perform better in complex environments;

[0141] Furthermore, the present application realizes efficient and accurate rice pest detection and control, which not only improves the yield and quality of crops, but also provides new ideas and solutions for agricultural modernization.

[0142] See also Fig.10 , a rice pest detection device provided to meet one of the purposes of the present application, includes a rice image acquisition module 1100, a detection model construction module 1200, a rice pest detection module 1300 and a rice pest control module 1400. Among them, the rice image acquisition module 1100 is configured to respond to an instruction to detect rice pests in a rice field, and obtain a rice image to be detected containing rice pests from an onboard camera of a drone; the detection model construction module 1200 is configured to update the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model to a receptive field attention convolution, add a mixed local channel attention mechanism to the neck network of the original YOLOv8n network model, update the original detection head module to a Dyhead detection head, and add a small target detection head module. block to construct a rice pest detection model; a rice pest detection module 1300, configured to input the rice image to be detected into the rice pest detection model that has been trained to a convergence state, so as to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category, wherein the target detection frame is used to indicate a position corresponding to the rice pest; a rice pest control module 1400, configured to respond to a rice pest control instruction, and the drone sprays the pesticide corresponding to the rice pest category to the position corresponding to the rice pest, so as to complete the detection of rice pests in the paddy field.

[0143] Based on any embodiment of this application, please refer to Fig.11 Another embodiment of the present application further provides an electronic device, which can be implemented by a computer device, such as Fig.11 As shown, a schematic diagram of the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. Among them, the computer-readable storage medium of the computer device stores an operating system, a database, and computer-readable instructions. The database may store a control information sequence. When the computer-readable instructions are executed by the processor, the processor can implement a rice pest detection method. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute the rice pest detection method of the present application. The network interface of the computer device is used to connect and communicate with a terminal. Those skilled in the art will understand that Fig.11The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0144] In this embodiment, the processor is used to execute Fig.10 The memory stores the program code and various data required to execute the above modules or submodules. The network interface is used to transmit data between user terminals or servers. The memory in this embodiment stores the program code and data required to execute all modules / submodules in the rice pest detection device of the present application, and the server can call the program code and data of the server to execute the functions of all submodules.

[0145] The present application also provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the rice pest detection method described in any embodiment of the present application.

[0146] The present application also provides a computer program product, including a computer program / instruction, which, when executed by one or more processors, implements the steps of the rice pest detection method described in any embodiment of the present application.

[0147] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments of the present application can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a computer-readable storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0148] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

[0149] In summary, the present application realizes efficient and accurate rice pest detection and control, which not only improves the yield and quality of crops, but also provides new ideas and solutions for agricultural modernization.

Claims

1. A rice pest detection method, characterized in that: include: In response to an instruction to detect rice pests in a rice field, an image of rice to be detected containing rice pests is obtained from an onboard camera of a drone; The CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model was updated to the receptive field attention convolution, a hybrid local channel attention mechanism was added to the neck network of the original YOLOv8n network model, the original detection head module was updated to the Dyhead detection head, and a small target detection head module was added to build a rice pest detection model; Inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category, wherein the target detection frame is used to indicate a corresponding position of the rice pests; In response to the rice pest control instruction, the drone sprays the pesticide corresponding to the rice pest category to the location corresponding to the rice pest to complete the detection of rice pests in the paddy field.

2. The rice pest detection method according to claim 1, characterized in that: The step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category comprises: The receptive field attention convolution dynamically generates features according to the size of the convolution kernel, and each convolution kernel has a corresponding receptive field to cover a specific area of ​​the input feature map; A Group Conv method is used to extract features from the receptive field to determine receptive field features; Apply average pooling to each receptive field feature to aggregate global information; After average pooling, a 1x1 group convolution operation is performed to further process the receptive field features; The output of the 1x1 group convolution is processed by Softmax to generate the importance weights of the features within each receptive field.

3. The rice pest detection method according to claim 1, characterized in that: The step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category comprises: In the hybrid local channel attention mechanism, local average pooling and global average pooling are used to process the input feature map to determine the local pooled features and the global pooled features, wherein the local average pooling is used to focus on the features of the local area, and the global average pooling is used to capture the statistical information of the entire feature map; The features after local pooling and the features after global pooling are transformed through a 1D convolution. The local pooled features are rearranged after 1D convolution and combined with the original input features through multiplication to enhance the focus on useful features; The global pooled features are combined with the local pooled features through addition operations after 1D convolution and rearrangement to integrate the global context information in the feature map; The feature map processed by local and global attention is restored to its original spatial dimension through unpooling operation again.

4. The rice pest detection method according to claim 1, characterized in that: The Dyhead detection head includes a scale-aware attention module, a space-aware attention module and a task-aware attention module.

5. The rice pest detection method according to claim 2, characterized in that: The step of inputting the rice image to be detected into a rice pest detection model that has been trained to a convergent state to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category comprises: In the scale-aware attention module of the Dyhead detection head, the feature tensor F is processed by average pooling to extract global features; 1x1 convolution is used to reduce the number of feature channels, and nonlinear transformation is performed through ReLU activation function and hard Sigmoid function to capture rice pests of different sizes; In the spatial perception attention module, features are processed by offset learning and 3x3 convolution for spatial feature focusing to locate rice pests in complex backgrounds; The features are processed through the fully connected layer, combined with the ReLU activation function and normalization operation, and the weights of each channel of the feature map are adjusted according to the rice pest detection task to identify the category and location of rice pests.

6. The rice pest detection method according to claim 1, characterized in that: The drone sprays the pesticide corresponding to the rice pest category to the location corresponding to the rice pest to complete the step of detecting rice pests in the paddy field, including: Calling a rice pest detection model that has been trained to a convergence state, and performing target detection on the rice image to be detected based on the rice pest detection model to determine the number corresponding to different rice pest categories; The dosage of the pesticide corresponding to the rice pest category is determined according to the quantity corresponding to the rice pest category, and the pesticide corresponding to the rice pest category is sprayed to the corresponding position of the rice pest to complete the detection of rice pests in the paddy field.

7. The rice pest detection method according to any one of claims 1 to 6, characterized in that: The basic network architecture of the rice pest detection model is an improved YOLOv8n network model, and the rice pest categories include one or more of rice leaf roller, striped stem borer, gray leaf hopper, rice stem borer, rice stem borer or green rice stink bug.

8. A rice pest detection device, characterized in that: include: A rice image acquisition module is configured to respond to an instruction to detect rice pests in a rice field and acquire an image of rice to be detected containing rice pests from an onboard camera of a drone; A detection model building module is set to update the CSPLayer_2Conv convolution in the backbone network of the original YOLOv8n network model to a receptive field attention convolution, add a hybrid local channel attention mechanism in the neck network of the original YOLOv8n network model, update the original detection head module to a Dyhead detection head, and add a small target detection head module to build a rice pest detection model; a rice pest detection module, configured to input the rice image to be detected into a rice pest detection model that has been trained to a convergence state, so as to determine a target detection frame of rice pests in the rice image to be detected and its corresponding rice pest category, wherein the target detection frame is used to indicate a position corresponding to the rice pest; The rice pest control module is configured to respond to rice pest control instructions, and the drone sprays the pesticide corresponding to the rice pest category to the corresponding position of the rice pest to complete the detection of rice pests in the paddy field.

9. An electronic device, comprising a central processing unit and a memory, characterized in that: The central processing unit is used to call and run the computer program stored in the memory to execute the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: It stores a computer program implemented according to the method described in any one of claims 1 to 7 in the form of computer-readable instructions, and when the computer program is called and executed by a computer, the steps included in the corresponding method are executed.

Citation Information

Patent Citations

  • Rice pest detection method and device based on improved YOLOv5s model

    CN117496325A

  • Rice disease and pest detection method and system based on improved YOLOv8

    CN117710820A

  • Pavement disease detection method based on improved YOLOv8 model

    CN117788950A

  • Detection and identification method for electronic component

    CN118736303A

  • Aluminum material surface defect detection method for enhancing multi-scale feature extraction and target detection

    CN118799268A