Multi-scale pest type detection method and device and electronic equipment

By adding depth multi-scale convolution module and feature fusion module to the YOLOv8 model, combined with loss function optimization, the problem of difficulty in detecting multi-scale pests in the existing technology is solved, and efficient and accurate pest image detection is achieved, which is suitable for embedded device deployment. .

CN119274026APending Publication Date: 2025-01-07BEIJING RES CENT FOR INFORMATION TECH & AGRI
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411202079.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

Existing agricultural pest detection methods based on deep learning are difficult to meet the needs of detecting pest types with multi-scale characteristics, especially when there are many types of pest targets and large size differences between classes.

Method used

Adding depth multi-scale convolution module, scale sequence feature fusion module and feature encoding module to the network architecture of YOLOv8 model to build a pest image detection model, through multi-scale feature fusion and potential connection mining, combined with Inner-IoU and MPDIoU loss functions Training to achieve efficient detection of multi-scale pest images.

Benefits of technology

It realizes accurate detection of multi-scale pest images, retains high-resolution feature information to the maximum extent, improves detection accuracy and efficiency, and is suitable for embedded edge device deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119274026A_ABST
    Figure CN119274026A_ABST
Patent Text Reader

Abstract

The invention provides a multi-scale pest type detection method and device and electronic equipment, and the method comprises the steps: carrying out the preprocessing of collected pest images, so as to construct a pest image data set; based on a YOLOv8 model, constructing a pest image detection model; wherein a deep multi-scale convolution module is added in the trunk part of the network architecture of the YOLOv8 model; adding a scale sequence feature fusion module and a feature coding module to the neck part of the network architecture of the YOLOv8 model; training the pest image detection model to obtain a trained pest image detection model; and inputting the pest image data set into the trained pest image detection model to obtain a pest type detection result. By the adoption of the method, the problem that the multi-scale pest detection precision is limited in an existing pest image detection mode is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image detection technology, and in particular to a method, device and electronic equipment for detecting multi-scale pest species. Background Art

[0002] There are many types of agricultural pests, which reproduce quickly and can cause serious damage to crops in a short period of time. Therefore, pest monitoring and early warning are particularly important. The prerequisite for completing these tasks is to conduct timely and accurate detection and testing of crop pests.

[0003] At present, agricultural pest detection methods based on deep learning are mainly improved for small targets and high-density image features, and the types of detection are a small number of small target pests. However, the characteristics of agricultural pest targets are not only small scale and dense distribution, but also many types and large size differences between classes. The existing detection methods for pest images are difficult to meet the needs of detecting pest types with multi-scale features. Summary of the invention

[0004] The present invention provides a method, device and electronic device for detecting multi-scale pest species, which are used to solve the problem that the existing detection method for pest images is difficult to meet the demand for detecting pest types with multi-scale characteristics.

[0005] The present invention provides a method for detecting pest species at multiple scales, the method comprising: Preprocessing the collected pest images to construct a pest image dataset; Based on the YOLOv8 model, a pest image detection model is constructed; wherein, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model; a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model; Training a pest image detection model to obtain a trained pest image detection model; The pest image dataset is input into the trained pest image detection model to obtain pest species detection results.

[0006] According to a multi-scale pest species detection method provided by the present invention, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model, specifically comprising: Some C2f modules in the backbone part of the network architecture of the YOLOv8 model are replaced with the deep multi-scale convolution modules.

[0007] According to a multi-scale pest species detection method provided by the present invention, the pest image detection model is constructed based on the YOLOv8 model, and further includes: Add a P2 layer detection head to the detection head part of the network architecture of the YOLOv8 model.

[0008] According to a multi-scale pest species detection method provided by the present invention, the training of the pest image detection model to obtain the trained pest image detection model includes: A model loss function is constructed, and a pest image detection model is trained based on the model loss function, wherein the model loss function is constructed according to the Inner-IoU loss function and the MPDIoU loss function.

[0009] According to a multi-scale pest species detection method provided by the present invention, the deep multi-scale convolution module is specifically used for: Rearranging the shape of the input first feature map from the first arrangement to the second arrangement to obtain a second feature map; Performing a convolution operation on the second feature map using convolutions of multiple different convolution kernels, and stacking the results of the convolution operation to obtain a third feature map; After rearranging the shape of the third feature map from the second arrangement to the first arrangement, a 1×1 convolution operation is performed to obtain an output result of the deep multi-scale convolution module.

[0010] According to a multi-scale pest species detection method provided by the present invention, the collected pest images are preprocessed to construct a pest image dataset, including: Adjusting the pest image to a preset pixel resolution; and converting the adjusted pest image into a grayscale image; Get the continuous image area in the grayscale image that is less than or equal to the preset grayscale value.

[0011] Cropping the continuous image area, and adjusting the image coordinates of the cropped continuous image area to obtain a pre-processed pest image; Based on the preprocessed pest images, a pest image dataset is constructed.

[0012] The present invention also provides a multi-scale pest species detection device, the device comprising: An image processing unit, used for preprocessing the collected pest images to construct a pest image data set; A model building unit is used to build a pest image detection model based on the YOLOv8 model; wherein a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model; and a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model; A model training unit, used for training a pest image detection model to obtain a trained pest image detection model; The model application unit is used to input the pest image data set into the trained pest image detection model to obtain the pest species detection result.

[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described methods when executing the program.

[0014] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any of the methods described above is implemented.

[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, any of the methods described above is implemented.

[0016] The present invention provides a multi-scale pest species detection method, device and electronic device. A pest image detection model based on a YOLOv8 model is constructed, and a deep multi-scale convolution module is added to the backbone part of the network architecture of the YOLOv8 model to realize multi-scale feature fusion of pest images; and a scale sequence feature fusion module and a feature encoding module are added to the neck part of the network architecture of the YOLOv8 model to explore the potential connection between feature maps of different scales, overlap feature maps at multiple scales, and retain the key high-resolution feature information and multi-scale features of pest images to the maximum extent, so that the constructed pest image detection model can meet the pest image detection requirements of multi-scale features. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 It is a schematic flow chart of a multi-scale pest species detection method provided by the present invention.

[0019] Figure 2 The figure is a schematic diagram of the principle of a pest image processing process provided by the present invention.

[0020] Figure 3 It is a schematic diagram of the principle of a pest image detection model provided by the present invention.

[0021] Figure 4 It is a schematic diagram of the principle of a detection method for a deep multi-scale convolution module provided by the present invention.

[0022] Figure 5 It is a flowchart of the working principle of a deep multi-scale convolution module provided by the present invention.

[0023] Figure 6 This is one of the principle schematic diagrams of a deep multi-scale convolution module provided by the present invention.

[0024] Figure 7 This is the second principle schematic diagram of a deep multi-scale convolution module provided by the present invention.

[0025] Figure 8 It is a schematic diagram of the principle of a scale sequence feature fusion module provided by the present invention.

[0026] Fig. 9 It is a schematic diagram of the principle of a three-feature encoding module provided by the present invention.

[0027] Fig.10 It is a schematic diagram of the principle of a loss function construction process provided by the present invention.

[0028] Fig.11 It is a structural schematic diagram of a multi-scale pest species detection device provided by the present invention.

[0029] Fig.12 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the descriptions used in this way can be interchanged where appropriate, so that the embodiments can be implemented in a sequence other than that illustrated or described in the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules that are clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The naming or numbering of the steps that appear in the present application does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The process steps that have been named or numbered can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved. The division of modules in this application is a logical division. There may be other division methods when it is implemented in actual applications. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection between units can be electrical or other similar forms, which are not limited in this application. In addition, the modules or submodules described as separate components may or may not be physically separated, may or may not be physical units, or may be distributed in multiple circuit units, and some or all of the units may be selected according to actual needs to achieve the purpose of the present application.

[0032] At present, traditional agricultural pest detection methods based on deep learning are mainly improved for small targets and high-density image features, and the types of detection are a small number of small target pests. However, the characteristics of agricultural pest targets are not only small scale and dense distribution, but also many types and large size differences between classes. The existing detection architecture for pest targets cannot meet the needs of detecting large-scale, multi-class and multi-scale feature datasets. If only the detection of tiny targets is optimized, it is not enough to fully enhance the performance of pest detection. This limitation is attributed to the limited capacity of neural networks, where excessive adjustment of parameters for small target features may impair the detection performance of larger targets. If the loss function during training is biased towards small targets, it may lead to insufficient learning of features representing larger targets. Adjusting the feature extraction layer to better adapt to small objects may lead to insufficient feature extraction of large objects.

[0033] Therefore, while improving the accuracy of pest detection, it is also necessary to ensure that the size of the model is not too large and the inference time is not too long. This is a requirement for model deployment based on embedded edge devices. Traditional two-stage algorithms such as Faster R-CNN have high computational overhead and low accuracy. The latest vision-based Transformer architecture model has many parameters and requires a lot of computing resources for training. Therefore, the inventors believe that for fast and efficient one-stage algorithms such as the YOLO series, if multi-scale algorithm design can be integrated while paying attention to small targets, achieving a balance between small target detection algorithms and multi-scale strategies is the key to comprehensively improving the detection performance of multiple types of pests.

[0034] Based on the above concept, the present invention proposes a multi-scale pest species detection method, device and electronic device to solve the problem that the existing detection method for pest images is difficult to meet the needs of detecting pest types with multi-scale features.

[0035] Figure 1 A schematic flow chart of a multi-scale pest species detection method provided by the present invention, the method comprising steps S101-S104.

[0036] Step S101, preprocessing the collected pest images to construct a pest image dataset.

[0037] Step S102, based on the YOLOv8 model, construct a pest image detection model; wherein, a deep multi-scale convolution module is added to the backbone part of the network architecture of the YOLOv8 model; and a scale sequence feature fusion module and a feature encoding module are added to the neck part of the network architecture of the YOLOv8 model.

[0038] Step S103: training the pest image detection model to obtain a trained pest image detection model.

[0039] Step S104, inputting the pest image dataset into the trained pest image detection model to obtain pest species detection results.

[0040] In an embodiment of the present invention, RGB images of pests under a standard background can be collected by a light-induced pest monitoring device to obtain collected pest images, and the pest images are preprocessed to construct a pest image dataset. At the same time, in view of the problem that many types of pests are small in size and have many scales, a pest image detection model is constructed based on the YOLOv8 model; and in the training stage, a loss function is constructed to optimize the model parameters of the pest image detection model to obtain a trained pest image detection model. Part of the data in the pest image dataset is used as test data and input into the trained pest image detection model to obtain the pest species detection results.

[0041] In step S101, the collected pest images are preprocessed to construct a pest image dataset, which specifically includes: The pest image is adjusted to a preset pixel resolution; the adjusted pest image is converted into a grayscale image; a continuous image area in the grayscale image that is less than or equal to a preset grayscale value is obtained, the continuous image area is cropped, and the image coordinates of the cropped continuous image area are adjusted to obtain a preprocessed pest image; a pest image dataset is constructed based on the preprocessed pest image.

[0042] For example, the size of the collected RGB images is uniformly adjusted to a pixel resolution of 4000×3000 to enhance the detection of small-sized objects. At the same time, the original RGB images are converted into grayscale images to obtain continuous image areas below the set grayscale value. Figure 2 As shown in (a), the cropping coordinates A (x1, y1), B (x2, y2) of the RGB image are obtained. Finally, the redundant black background is removed according to the cropping coordinates to reduce interference, and the image coordinates of the cropped continuous image area are corrected according to the coordinate values ​​and the original RGB image size. The effect is shown in Figure 2 (b) shows the pest image after the collected pest image is preprocessed.

[0043] In a possible implementation, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model, specifically including: replacing some C2f modules in the backbone of the network architecture of the YOLOv8 model with deep multi-scale convolution modules.

[0044] like Figure 3 As shown in FIG. 1 , a deep multi-scale convolution module, abbreviated as C2f-DMS, is used to replace the third and fourth C2f modules in the YOLOv8 model. The deep multi-scale convolution module in the embodiment of the present invention can finely process features at various scales, thereby being superior to the original C2f module and realizing detailed multi-scale feature fusion. The principle is as follows Figure 4 The deep multi-scale convolution module replaces the second convolution operation in the Bottleneck module in the C2f module with a deep multi-scale convolution operation to achieve the effect of the module. For a detailed description of the principle, please refer to the specific content of the following embodiment.

[0045] Figure 5 A schematic flow chart of the working principle of a deep multi-scale convolution module provided by the present invention includes steps S501-S503.

[0046] Step S501 is used to rearrange the shape of the input first feature map from a first arrangement to a second arrangement to obtain a second feature map.

[0047] Step S502 is used to perform a convolution operation on the second feature map using convolutions of multiple different convolution kernels, and stack the results of the convolution operation to obtain a third feature map.

[0048] Step S503 is used to rearrange the shape of the third feature map from the second arrangement to the first arrangement, and then perform a 1x1 convolution operation to obtain an output result of the deep multi-scale convolution module.

[0049] Specifically, in step S501, see Figure 6 As shown, the rearrange function is used to rearrange the input feature map X from the shape of (batch_size, group * channels, height, width) to the shape of (batch_size, channels, height, width, groups). Among them, batch_size represents the batch size, group represents the number of groups, channels represents the number of channels, and height and width represent the height and width of the feature map respectively.

[0050] In step S502, see Figure 6 As shown, the number of channels of the feature map is divided by 4 to ensure that each convolution will have a channel subset to process. 1x1, 3x3, 5x5, 7x7 convolutions are performed on the 4 channel subsets respectively and the results are stacked.

[0051] Specifically, in step S503, see Figure 7 As shown in the figure, the stacked convolution output is restored and arranged into a format suitable for further processing (batch_size, groups * channels, height, width). The processed output is then subjected to a 1x1 convolution, which allows the information on different channels to be linearly combined, thereby combining the features of the four channels previously divided.

[0052] Through the above steps S501-S503, the receptive field is considered from a local to a global perspective, so that the deep multi-scale convolution module can respond to pest targets of various sizes. In an embodiment of the present invention, the size of the four convolution kernels is a hyperparameter, which can be determined by experiment according to the characteristics of the data set. In addition, the deep multi-scale convolution module uses 1x1 convolution to integrate features of different scales by merging channels from various feature maps, and performs feature fusion purposefully. Not only does it enhance the ability of the deep multi-scale convolution module to perceive features at multiple scales, but it also compresses the number of parameters and improves the computational efficiency of the model.

[0053] In the following, the specific principle of adding a scale sequence feature fusion module and a feature encoding module to the neck part of the network architecture of the YOLOv8 model in an embodiment of the present invention is described.

[0054] Scale sequence feature fusion module: It is used to explore the potential connections between feature maps of different scales, overlap feature maps at multiple scales, and use 3D convolution technology to extract feature sequences, thereby maximally retaining key high-resolution feature information for small target detection. Figure 8 As shown in Figure 1, the process of the scale sequence feature fusion module is as follows: (1) Use a 1x1 convolution kernel to adjust the number of channels of the two underlying feature maps to 256; (2) Match the size through nearest neighbor interpolation and align with the highest level feature map; (3) Use the unsqueeze operation to expand the dimension of each feature map and convert the three-dimensional tensor [height, width, channel] into a four-dimensional tensor [depth, height, width, channel]; merge these four-dimensional feature maps along the depth dimension to form a three-dimensional feature map for further convolution; (5) Finally, the scale sequence feature is extracted through three-dimensional convolution, batch normalization and SiLU activation function.

[0055] Three feature encoding modules: Fig. 9 The structure of the three feature encoding modules is shown. Before feature encoding, the convolution module is first used to adjust the number of feature channels so that the large-scale features are consistent with the current medium-scale features. After the convolution module processes the large-scale feature map (Large), its number of channels is adjusted to 1C, and then a hybrid structure of maximum pooling and average pooling is used for downsampling, which is conducive to maintaining the high-resolution features of the pest image. For the small-scale feature map (Small), the convolution module is also used to adjust the number of channels, and then the nearest neighbor interpolation method is used for upsampling, which helps to maintain the richness of local features of low-resolution images and prevent the loss of small target feature information. Finally, the feature maps of the same size, large, medium, and small, are convolved once and then spliced ​​on the channel size to maximize the retention of multi-scale features.

[0056] In a possible implementation, building a pest image detection model based on the YOLOv8 model also includes: adding a P2 layer detection head to the detection head part of the network architecture of the YOLOv8 model.

[0057] In the YOLOv8 architecture, the input image is downsampled at multiple levels to produce multi-scale feature maps (such as P2, P3, P4, etc.), and each scale of the feature map is responsible for detecting objects of different volumes. The initial YOLOv8 model is equipped with P3, P4, and P5 level detection heads, which facilitate multi-scale object detection, but may not perform well when detecting smaller objects. To enhance small-scale object detection, we added a P2 layer detection head. As an earlier feature mapping layer in the network, the P2 layer has a higher spatial resolution, making it more suitable for detecting small objects. Figure 3 There are four detection heads, namely P2, P3, P4 and P5, which are combined with the three-feature encoding module mentioned above to enhance the detection performance of small targets.

[0058] In step S103, the pest image detection model is trained to obtain a trained pest image detection model. For details, please refer to the following embodiment.

[0059] In this example, a multi-scale pest image detection model was constructed using Python on the Ubuntu 16.04 Linux operating system platform, and two NVIDIA RTX 3090 GPUs were used to train the model. The batch size on a single GPU is 24, 640*640 pixel images, the minimum batch size is 8, the initial learning rate of the model is set to 0.01, and the number of training rounds is 300 batches. The acceleration environment is CUDA10.2 and CUDNN7.6.5, the development environment is Visual Studio 2019, and the Opencv3.4.0 library is used.

[0060] In a possible implementation, training a pest image detection model to obtain a trained pest image detection model includes: constructing a model loss function, and training the pest image detection model based on the model loss function, wherein the model loss function is constructed according to an Inner-IoU loss function and an MPDIoU loss function.

[0061] In an embodiment of the present invention, the loss function in the network is modified, and MPDinner-IoU, which is a combination of inner-IoU and MPDIoU, is used as the model loss function.

[0062] The construction process of the MPDinner-IoU activation function calculation formula is as follows:

[0063] =

[0064] = 1 − =1+

[0065] The real box and anchor box are denoted as Bgt and B respectively. Fig.10 , the center points of the real box and the auxiliary real box are ( , ) represents the center point of the anchor box and auxiliary anchor box. , ). The width and height of the real box are expressed as , the width and height of the anchor box are denoted as w and h respectively. The variable "ratio" corresponds to the scaling factor and is usually in the range of [0.5, 1.5]. ( , ),( , ) represents the coordinates of the upper left and lower right points of the real box, ( , ),( , ) represents the coordinates of the upper left and lower right points of B.

[0066] in, Indicates the x coordinate of the left boundary of the ground-truth box. Indicates the y coordinate of the right boundary of the ground-truth box. Indicates the y coordinate of the top border of the real box. Indicates the y coordinate of the bottom boundary of the real box. Indicates the x coordinate of the left boundary of the anchor box. Indicates the x coordinate of the right boundary of the anchor box. Indicates the y coordinate of the top edge of the anchor box. Indicates the y coordinate of the bottom boundary of the anchor box. The difference between the minimum width and height of the intersection area of ​​the auxiliary real box and the auxiliary anchor box, that is, the width and height of the intersection area. It is the joint area of ​​the auxiliary ground-truth box and the auxiliary anchor box. The IoU of the auxiliary ground-truth box and the auxiliary anchor box is calculated on the area of ​​the intersection area. It is the square of the distance between the top left corner vertices of the ground truth box and the anchor box. It is the square of the distance between the lower right corner vertices of the ground truth box and the anchor box. The formula takes into account the IoU between the two boxes and the distance between the vertices on both sides of the box. Combined with and . is based on The bounding box loss function of , that is, the model loss function.

[0067] In an embodiment of the present invention, the network initial parameters and the model loss function are set, part of the data in the pest image dataset is used as the training dataset and the verification dataset as input, the model is trained, and a trained pest image detection model is generated.

[0068] The present invention can achieve the following beneficial effects by adopting the above method: 1. By constructing a pest image detection model based on the YOLOv8 model, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model to realize the multi-scale feature fusion of pest images; and a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model to explore the potential connections between feature maps of different scales, overlap feature maps at multiple scales, and maximize the retention of key high-resolution feature information and multi-scale features of pest images, so that the constructed pest image detection model can meet the pest image detection needs of multi-scale features.

[0069] 2. In order to deal with small targets with multi-scale features, the present invention introduces a feature fusion neck and combines it with the small target detection layer. By fusing features at multiple scales, it retains key high-resolution feature information while maintaining the richness of local features of low-resolution images, thereby strengthening the fusion of global and local features of the target.

[0070] 3. Using MPDinner-IoU, a combination of inner-IoU and MPDIoU, as the model loss function to replace the loss function in the traditional method can better adapt to the characteristics of the data set and improve the geometric correction capability.

[0071] A multi-scale pest species detection device provided by the present invention is described below. The multi-scale pest species detection device described below and the pest species identification method described above can correspond to each other.

[0072] like Fig.11 FIG. 1 is a schematic diagram of a multi-scale pest detection device provided by the present invention, and the device includes: The image processing unit 1110 is used to pre-process the collected pest images to construct a pest image dataset.

[0073] The model construction unit 1120 is used to construct a pest image detection model based on the YOLOv8 model; wherein a deep multi-scale convolution module is added to the backbone part of the network architecture of the YOLOv8 model; and a scale sequence feature fusion module and a feature encoding module are added to the neck part of the network architecture of the YOLOv8 model.

[0074] The model training unit 1130 is used to train the pest image detection model to obtain a trained pest image detection model.

[0075] The model application unit 1140 is used to input the pest image dataset into the trained pest image detection model to obtain the pest species detection result.

[0076] In a possible implementation, the model construction unit 1120 includes: a first construction subunit, configured to replace part of the C2f modules in the backbone of the network architecture of the YOLOv8 model with the deep multi-scale convolution module.

[0077] In a possible implementation, the model construction unit 1120 further includes: a second construction subunit, configured to add a P2 layer detection head to the detection head part of the network architecture of the YOLOv8 model.

[0078] In a possible implementation, the model training unit 1130 is further used to construct a model loss function and train the pest image detection model based on the model loss function, where the model loss function is constructed according to the Inner-IoU loss function and the MPDIoU loss function.

[0079] In a possible implementation, the deep multi-scale convolution module is specifically used to: The shape of the input first feature map is rearranged from the first arrangement to the second arrangement to obtain a second feature map; a convolution operation is performed on the second feature map using convolutions of multiple different convolution kernels, and the results of the convolution operation are stacked to obtain a third feature map; after rearranging the shape of the third feature map from the second arrangement to the first arrangement, a 1x1 convolution operation is performed to obtain the output result of the deep multi-scale convolution module.

[0080] In a possible implementation, the image processing unit 1110 is specifically used to obtain a continuous image area in a grayscale image that is less than or equal to a preset grayscale value, crop the continuous image area, and adjust the image coordinates of the cropped continuous image area to obtain a preprocessed pest image; and construct a pest image dataset based on the preprocessed pest image.

[0081] Fig.12 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.12As shown, the electronic device may include: a processor 1210, a communications interface 1220, a memory 1230 and a communication bus 1240, wherein the processor 1210, the communications interface 1220, and the memory 1230 communicate with each other through the communication bus 1240. The processor 1210 may call the logic instructions in the memory 1230 to execute a multi-scale pest species detection method, the method comprising: Preprocessing the collected pest images to construct a pest image dataset; Based on the YOLOv8 model, a pest image detection model is constructed; wherein, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model; a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model; Training a pest image detection model to obtain a trained pest image detection model; The pest image dataset is input into the trained pest image detection model to obtain the pest species detection results.

[0082] In addition, the logic instructions in the above-mentioned memory 1230 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.

[0083] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute a multi-scale pest species detection method provided by the above methods, the method includes: Preprocessing the collected pest images to construct a pest image dataset; Based on the YOLOv8 model, a pest image detection model is constructed; wherein, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model; a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model; Training a pest image detection model to obtain a trained pest image detection model; The pest image dataset is input into the trained pest image detection model to obtain the pest species detection results.

[0084] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform a multi-scale pest species detection method provided by the above methods, the method comprising: Preprocessing the collected pest images to construct a pest image dataset; Based on the YOLOv8 model, a pest image detection model is constructed; wherein, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model; a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model; Training a pest image detection model to obtain a trained pest image detection model; The pest image dataset is input into the trained pest image detection model to obtain the pest species detection results.

[0085] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0086] Through the description of the above implementation modes, those skilled in the art can clearly understand that each implementation mode can be implemented by means of software plus a necessary general hardware platform, or of course by hardware. Based on such an understanding, the above technical solution can essentially or in other words be embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting pest species at multiple scales, characterized in that: The method comprises: Preprocessing the collected pest images to construct a pest image dataset; Based on the YOLOv8 model, a pest image detection model is constructed; wherein, a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model; a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model; Training a pest image detection model to obtain a trained pest image detection model; The pest image dataset is input into the trained pest image detection model to obtain pest species detection results.

2. The multi-scale pest species detection method according to claim 1, characterized in that: Add a deep multi-scale convolution module to the backbone of the YOLOv8 model's network architecture, including: Some C2f modules in the backbone part of the network architecture of the YOLOv8 model are replaced with the deep multi-scale convolution modules.

3. The multi-scale pest species detection method according to claim 1, characterized in that: The method of constructing a pest image detection model based on the YOLOv8 model also includes: Add a P2 layer detection head to the detection head part of the network architecture of the YOLOv8 model.

4. The multi-scale pest species detection method according to claim 1, characterized in that: The training of the pest image detection model to obtain the trained pest image detection model includes: A model loss function is constructed, and a pest image detection model is trained based on the model loss function, wherein the model loss function is constructed according to the Inner-IoU loss function and the MPDIoU loss function.

5. The multi-scale pest species detection method according to claim 2, characterized in that: The deep multi-scale convolution module is specifically used for: Rearranging the shape of the input first feature map from the first arrangement to the second arrangement to obtain a second feature map; Performing a convolution operation on the second feature map using convolutions of multiple different convolution kernels, and stacking the results of the convolution operation to obtain a third feature map; After rearranging the shape of the third feature map from the second arrangement to the first arrangement, a 1×1 convolution operation is performed to obtain an output result of the deep multi-scale convolution module.

6. The method according to claim 1, characterized in that The preprocessing of the collected pest images to construct a pest image dataset includes: Adjusting the pest image to a preset pixel resolution; and converting the adjusted pest image into a grayscale image; Get the continuous image area in the grayscale image that is less than or equal to the preset grayscale value. Cropping the continuous image area, and adjusting the image coordinates of the cropped continuous image area to obtain a pre-processed pest image; Based on the preprocessed pest images, a pest image dataset is constructed.

7. A multi-scale pest species detection device, characterized in that: The device comprises: An image processing unit, used for preprocessing the collected pest images to construct a pest image data set; A model building unit is used to build a pest image detection model based on the YOLOv8 model; wherein a deep multi-scale convolution module is added to the backbone of the network architecture of the YOLOv8 model; and a scale sequence feature fusion module and a feature encoding module are added to the neck of the network architecture of the YOLOv8 model; A model training unit, used for training a pest image detection model to obtain a trained pest image detection model; The model application unit is used to input the pest image data set into the trained pest image detection model to obtain the pest species detection result.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the multi-scale pest species detection method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the multi-scale pest species detection method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the multi-scale pest species detection method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Small target detection method and system based on improved YOLOv8 structure

    CN120356060A

  • A small target detection method and system based on an improved YOLOv8 structure

    CN120356060B