A sugarcane aphid target detection method based on lightweight YOLO v5

Through the lightweight YOLO v5 model, the existing pest detection model has solved the problem of low recognition accuracy and high computing resource requirements in complex farmland environments, and achieved high-precision and rapid detection of sugarcane aphids, which is suitable for mobile terminals.

CN114708231BActive Publication Date: 2025-09-02CHANGZHOU UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210371938.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-11
Publication Date
2025-09-02
Estimated Expiration
2042-04-11

AI Technical Summary

Technical Problem

The existing pest detection model is difficult to apply on large scale in agricultural pest detection under unstructured farmland backgrounds and complex natural light environments, especially in the identification and counting accuracy of extremely small pest targets, and the model parameters are large and the computing resource demand is high.

Method used

The lightweight YOLO v5 model is adopted, and the Focus module, C3 module and SPP module in the backbone network are replaced by the Stem module and ShuffleNetV2's Inverted Residual module, the neck network width is reduced, and the micro-scale detection layer is added. Combined with the Mosaic data enhancement method, the sugarcane aphid detection algorithm suitable for natural light environment in farmland was trained.

Benefits of technology

It realizes high-precision and rapid identification of sugarcane aphids on mobile terminals, reduces memory usage, improves the computing efficiency and generalization capabilities of the model, and is suitable for the changing natural light environment of farmland.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114708231B_ABST
    Figure CN114708231B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of target detection technology, and in particular to a sugarcane aphid target detection method based on a lightweight YOLO v5. The method comprises the following steps: S1: sugarcane aphid image acquisition; S2: image preprocessing; S3: data set creation; S4: lightweight improvement of the YOLO v5 model; and S5: inputting the data set for training to obtain the lightweight model. The method uses the Stem module and the Inverted Residual module of ShuffleNetV2 to reduce the neck network width to lightweight the YOLO v5 model. The method also removes large-scale detection layers and adds small-scale detection layers, enabling the network to better meet the detection requirements of densely packed small targets in sugarcane aphids. Compared with the original YOLO v5 model, the method has the advantages of high recognition accuracy, fast recognition speed, and low memory usage, facilitating model deployment on mobile terminals.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of target detection technology, and in particular to a sugarcane aphid target detection method based on lightweight YOLO v5. Background Art

[0002] Sorghum is often attacked by sugarcane aphids during its growth, endangering its healthy growth and causing frequent outbreaks, resulting in significant economic losses to sorghum yields each year. Therefore, rapid and accurate monitoring of aphids on sorghum leaves is necessary to develop effective prevention and control measures to reduce these losses. Traditional methods for detecting aphids still require field workers to observe the distribution of aphids on leaves and rely on manual counting to determine the number and severity of aphids on leaves and diagnose the pest and disease situation in the area. This method is labor-intensive and inefficient, and cannot quickly and accurately predict the occurrence of pests and diseases.

[0003] Early pest identification methods primarily relied on features like color, texture, and morphology, employing machine learning methods such as decision trees, gradient boosting, and support vector machines. These methods placed high demands on the pests' body shape, color, and other characteristics in the dataset, resulting in unstable identification results, low detection rates, and reliance on the unnatural, real-world farmland environment.

[0004] With the expansion of computing resources, deep learning has advanced rapidly, particularly in the field of image processing, providing a technical foundation for lightweight farmland pest detection. As deep learning technology matures, several excellent detection models have emerged in the field of object detection, such as SSD, Faster-RCNN, and YOLO. These high-performing object detection models extract features through convolutional neural networks and generally use anchor boxes to achieve object localization. Recently, some object detection algorithms without anchor boxes have emerged, such as CenterNet. However, these algorithms, when used without a priori frameworks for small objects such as pests, have shown unacceptable performance.

[0005] Existing pest detection methods usually use images taken under stable lighting or single environmental conditions (such as controlled lighting, greenhouses, and pest traps) as training datasets. [1] The improved Yolov4 method was used to detect olive fruit fly images taken in yellow traps, achieving an average accuracy of 96.68%; Hong et al. [2]Using the Faster-RCNN method, researchers detected images of pinocytosis pests captured indoors under four-way LED lighting, achieving an average accuracy of 80.2% to 89.8%. While this method offers high pest recognition accuracy, it suffers from low accuracy and poor robustness when detecting pests in unstructured farmland and complex natural lighting environments, particularly for the identification and counting of very small pest targets. Furthermore, the model's large number of parameters and the need for high-computing hardware hinder its widespread application in agricultural pest detection.

[0006] To address the challenges of existing pest detection models, which suffer from numerous parameters, complex networks, and high computational complexity, this paper proposes a lightweight sugarcane aphid detection algorithm. This model can be deployed on low-cost mobile devices and is suitable for identifying sugarcane aphids in the variable natural lighting conditions of farmland, ultimately enabling the scalability and intelligentization of sugarcane aphid detection systems.

[0007] [1]Mamdouh N,Khattab A.Yolo-based deep learning framework for olivefruit fly detection and counting[J].IEEE Access,2021,9:84252-84262.

[0008] [2]Hong SJ,Nam I,Kim SY,et al.Automatic pest counting from pheromone trap images using deep learning object detectors for matsucoccusthunbergianae monitoring[J].Insects,2021,12(4):342. Summary of the Invention

[0009] To address the shortcomings of existing algorithms, the present invention proposes a sugarcane aphid detection method based on lightweight YOLO v5, which is suitable for use in the variable natural lighting environment of farmland. The present invention has high recognition accuracy, fast recognition speed, and low memory usage, making it conducive to deployment on mobile platforms.

[0010] The technical solution adopted by the present invention is: a sugarcane aphid target detection method based on lightweight YOLO v5 includes the following steps:

[0011] S1: Sugarcane aphid image collection;

[0012] Furthermore, a camera was used to capture images of sorghum leaves with sugarcane aphids as experimental image data. The captured images included four light intensities: weak light, strong light, direct light, and diffuse light, which are suitable for the variable natural light conditions in farmland.

[0013] S2: image preprocessing;

[0014] Furthermore, the original image is segmented into several sub-images of a certain pixel size as the experimental data set; since sugarcane aphids are very small compared to the original image, the original image is segmented for such small targets;

[0015] S3: Create dataset;

[0016] Furthermore, LabelImg was used to manually label the sugarcane aphids in each image in the dataset, using the minimum bounding rectangle of the target as the ground truth box. 80% of the images in the prepared dataset were randomly selected as training data for the sugarcane aphid detection algorithm, and the remaining 20% ​​of the images were used as test data to test and verify the sugarcane aphid detection method proposed in the present invention.

[0017] S4: Lightweight improvement of YOLO v5 model;

[0018] Further, the following steps are included:

[0019] S41: Use the Stem module to replace the Focus module in the backbone network;

[0020] The Stem module is a cost-effective module that can effectively improve feature expression capabilities without increasing the amount of additional computation. The specific structure of the Stem module is to first use a 3x3 convolution with a stride of 2 for rapid dimensionality reduction. Then, it uses a two-branch structure: one branch uses a 1x1 convolution and a 3x3 convolution with a stride of 2, and the other branch uses a maximum pooling. Finally, the two branches are connected through Concat, and the output is subjected to a 1x1 convolution. After the image passes through the Stem module, it is downsampled by 4 times.

[0021] The Stem module uses a pooling strategy of 3x3 convolution with a stride of 2 and maximum pooling, while the combined pooling uses maximum pooling and mean pooling. The Stem module of the present invention can enrich the feature layer;

[0022] S42: Use the Inverted Residual module of ShuffleNetV2 to replace the C3 module, Conv module and SPP module in the backbone network;

[0023] The Inverted Residual module of ShuffleNet V2 is composed of two units. The incoming step size parameter controls whether to perform downsampling operation. Its specific structure is as follows:

[0024] When the stride is 1, the Inverted Residual module extracts features using repeated 1×1 convolutions and 3×3 depthwise convolutions, employing short-circuit connections to increase network depth. A Channel split operation is added before each short-circuit connection to split the input feature channel into two, effectively improving the computational efficiency of the convolutional neural network and reducing the number of parameters. After the two branches are connected via Concat, a Channel shuffle module is added to shuffle and rearrange each channel to mix features, improving the feature expression capability and detection accuracy of the convolutional neural network model. The application of Channel split and Channel shuffle reduces the computational complexity of the model, reduces the model's memory usage, and greatly improves the model's computational efficiency.

[0025] When the stride is 2, the Inverted Residual module uses a downsampling unit block instead of Channelsplit. Instead, it directly uses the original input. Each feature channel is downsampled using a 3×3 depthwise convolution with a stride of 2. One branch adds a 1×1 convolution after the convolution, and the other branch adds a 1×1 convolution before and after. After the two branches are connected through Concat, the spatial size of the feature map is halved, but the number of channels is doubled. Finally, the Channel shuffle module is used to shuffle and rearrange each channel to mix features, improving the feature expression capability and detection accuracy of the convolutional neural network model.

[0026] The depthwise convolution is a convolution kernel responsible for one channel, and one channel is convolved by only one convolution kernel, that is, the convolution operation is performed independently on each channel of the input layer.

[0027] S43: Reduce neck network width;

[0028] The C3 and Conv modules in the neck network of YOLO v5 have a large number of convolution kernels, resulting in a large number of feature map channels. This consumes more cache space, slows down the execution, and affects the computational complexity of the entire network. To reduce the weight of the model, we reduced the number of convolution kernels in the C3 and Conv modules in the neck network of YOLO v5 in the configuration file to 128. This reduces the number of channels in the generated feature maps, reduces the network width, and reduces the number of model parameters and computational complexity, speeding up the model.

[0029] S44: Improved detection scale;

[0030] When the input image size is 640×640, the three detection scales corresponding to YOLO v5 are 20×20, 40×40, and 80×80 respectively. For the 20×20 detection scale, its receptive field is a 32×32 pixel area, which is mainly used to detect large objects, while the 40×40 detection scale has a 16×16 pixel area, which is mainly used to detect medium-sized objects. Finally, the 80×80 detection scale has a 8×8 pixel area, which is mainly used to detect small objects.

[0031] Sugarcane aphids photographed under natural light are distributed in various positions and corners of the leaves, and there are sugarcane aphid forms of different growth stages on the leaves, so the sugarcane aphids mapped into the image also have different sizes, especially the dense image containing multiple sugarcane aphid targets; since the single sugarcane aphid individual to be detected occupies a very small proportion of the input image, multiple downsampling will cause the loss of tiny target feature information extracted by the convolution layer during training, resulting in the inability to identify the tiny sugarcane aphid larvae; a dense image may contain many medium-scale, small-scale and micro-scale sugarcane aphid targets; the small-scale detection layer of YOLO v5 has poor applicability to these tiny sugarcane aphid larvae, and the large-scale detection layer is difficult to detect sugarcane aphids; in order to cope with complex dense scenes under natural light, the present invention uses YOLO v5 to detect small sugarcane aphids. The three detection scales of v5 are improved. Among these three detection scales, the detection scales of 40×40 and 80×80 for small and medium-sized objects are retained, the detection scale of 20×20 large objects is deleted, and the detection scale of 160×160 small objects is added. The micro-scale detection layer generates a feature map by fusing the lower spatial features extracted by the Stem module by reducing the dimensionality of the input image by 4 times with the deep semantic features. The new micro-scale detection layer forms a broader and more detailed detection network structure, which is more suitable for detecting small and dense sugarcane aphids in images of farmland under natural lighting scenes, allowing the network to better match the target to be detected.

[0032] S5: Input the dataset for training to obtain a lightweight model.

[0033] The Pytorch1.7.0 deep learning framework was used, and the training image size was set to 640×640; the learning rate, batch size, number of iterations, and number of categories were set to 0.001, 16, 500, and 1, respectively; the YOLOv5s model, the smallest of the four YOLO v5 models, was used to train the dataset; the mosaic enhancement method of YOLO v5 was used to enhance the dataset images; Mosaic data enhancement uses random scaling, random cropping, and random arrangement to splice four random images, and finally scales the spliced ​​images to the set input size and passes them into the model as new samples; the Mosaic data enhancement method enriches the target location distribution and amplifies small-sized targets to a certain extent, thereby improving the model training efficiency while improving the model's generalization ability; the dataset was input and trained to obtain a sugarcane aphid target detection model based on the lightweight YOLO v5.

[0034] Beneficial effects of the present invention:

[0035] The proposed sugarcane aphid detection method based on lightweight YOLO v5 uses the Stem module and the Inverted Residual module of ShuffleNetV2 to reduce the neck network width to lightweight the YOLO v5 model. At the same time, it removes the large-scale detection layer and adds a small-scale detection layer, making the network more suitable for detecting dense small targets in sugarcane aphids. Compared with the original YOLO v5 model, it has the advantages of high recognition accuracy, fast recognition speed, and low memory usage, which is conducive to the deployment of the model on mobile terminals. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 This is the overall flow chart of the sugarcane aphid target detection method based on lightweight YOLO v5;

[0037] Figure 2 This is the structure diagram of the sugarcane aphid target detection model based on YOLO v5;

[0038] Figure 3 This is a structural diagram of the sugarcane aphid target detection model based on lightweight YOLO v5 of the present invention;

[0039] Figure 4 This is the Stem module structure diagram;

[0040] Figure 5 This is the structure diagram of the Inverted Residual module of ShuffleNetV2;

[0041] Figure 6 This is a schematic diagram of the Channel shuffle channel rearrangement process;

[0042] Figure 7 This is the neck network structure diagram of the improved model;

[0043] Figure 8 This is a comparison chart before and after the improvement of the detection layer;

[0044] Figure 9 This is part of the training graph after Mosaic data enhancement;

[0045] Figure 10 This is a schematic diagram of target detection in sugarcane aphid images based on the lightweight YOLO v5 model. DETAILED DESCRIPTION

[0046] The present invention will be further described below in conjunction with the accompanying drawings and embodiments. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore only shows the components related to the present invention.

[0047] like Figure 1 As shown in FIG, a sugarcane aphid target detection method based on lightweight YOLO v5 includes the following steps:

[0048] S1: Sugarcane aphid image collection;

[0049] The images used in the experiment were taken from grain sorghum leaves with sugarcane aphids using a camera under natural lighting conditions in farmland (image resolution was 2448×3264); the vertical distance between the camera and the leaves was approximately 0.2 meters; the collected images included four light intensities: weak light (light intensity less than 20kLux), strong light (light intensity greater than 30kLux), direct light (taken between noon and 1:00 p.m. on a sunny day with a sun angle greater than 40°), and diffuse light (light intensity between 20Klux and 30Klux at the time of shooting).

[0050] S2: image preprocessing;

[0051] Since the original image resolution is large and the proportion of sugarcane aphids in the original image is too small, multiple downsampling will cause the target feature information of sugarcane aphids extracted by the convolutional layer to be lost during the training process, resulting in the inability to recognize the sugarcane aphids. Therefore, each collected sugarcane aphid image is cut into 4×4 sub-images with an image resolution of 612×816. 300 sub-images with clear sugarcane aphid targets are randomly selected as the dataset images for this study. The dataset images contain a total of 2443 sugarcane aphid targets.

[0052] S3: Create dataset;

[0053] The sugarcane aphids in each image in the dataset were manually labeled using LabelImg, with the minimum bounding rectangle of the target as the ground truth box. 80% (240 images, a total of 2230 aphid samples) of the prepared dataset were randomly selected as training data for the sugarcane aphid detection algorithm of the present invention, and the remaining 20% ​​(60 images, a total of 213 aphid samples) were used as test data to test and verify the sugarcane aphid detection method proposed in the present invention.

[0054] S4: Lightweight improvement of YOLO v5 model;

[0055] like Figure 2 As shown in the figure, the YOLO v5 model uses the C3 module as the backbone network for extracting image features, and adopts the FPN (Feature Pyramid Network) + PAN (Path Aggregation Network) structure as the neck network to better integrate the extracted features. The head network is composed of three scale detection heads: large, medium, and small to detect the target object.

[0056] The basic components of the target detection network based on YOLO v5 are as follows:

[0057] Focus module: Slices the input image to expand the input channel while retaining the complete image information, thereby retaining the complete image downsampling information for subsequent feature extraction, making feature extraction sufficient;

[0058] Conv module: consists of convolutional layer, batch normalization layer and SiLu activation function, used to extract image features;

[0059] C3 module: The main module for learning residual features. Its structure is divided into two branches. One uses multiple Bottleneck stacks and three standard convolutional layers, and the other only passes through a basic convolution module. The two branches are concat-operated and output features through a basic convolution module.

[0060] SPP (Spatial Pyramid Pooling) module: uses the maximum pooling method to fuse multi-scale features;

[0061] like Figure 3 As shown in the figure, based on the lightweight model structure of YOLO v5, the steps to improve the lightweight YOLO v5 model are as follows:

[0062] S41: Use the Stem module to replace the Focus module in the backbone network. The specific content is:

[0063] The Stem module is a cost-effective module that can effectively improve feature expression capabilities without increasing the amount of additional computation. Figure 4As shown in the figure, the specific structure of the Stem module is to first use 3x3 convolution with a stride of 2 for rapid dimensionality reduction, and then use a two-branch structure: one branch uses 1×1 convolution and 3x3 convolution with a stride of 2, and the other branch uses a maximum pooling. This part is very similar to combined pooling. The Stem module uses a pooling strategy derived from the advantages of 3x3 convolution with a stride of 2 and maximum pooling (combined pooling uses maximum pooling and mean pooling) to enrich the feature layer. Finally, the two branches are connected through Concat and the output is subjected to 1×1 convolution. After passing through the Stem module, the image is downsampled by 4 times;

[0064] S42: Use the Inverted Residual module of ShuffleNetV2 to replace the C3 module, Conv module and SPP module in the backbone network;

[0065] ShuffleNetV2 is a lightweight neural network designed for mobile devices. It improves upon ShuffleNetV1 by following the four design guidelines for lightweight and efficient networks: using 1×1 convolution instead of 1×1 group convolution; introducing a new operation at the beginning of the module: Channel split; and using concatenation instead of addition in short-circuit connections.

[0066] The Inverted Residual module of ShuffleNet V2 is composed of two units. The step size parameter passed in controls whether to perform downsampling. Its specific structure is as follows: Figure 5 :

[0067] like Figure 5 As shown in Figure 1, when the stride is 1, the Inverted Residual module uses repeated 1×1 convolution and 3×3 depthwise convolution to extract features, and uses short-circuit connections to increase the network depth. A Channelsplit operation is added before each short-circuit connection to split the input feature channel into two, effectively improving the computational efficiency of the convolutional neural network and reducing the large number of parameters. Figure 6 As shown in the figure, after connecting the two branches via Concat, a Channel shuffle module is added to shuffle each channel to mix features, improving the feature representation capability and detection accuracy of the convolutional neural network model. The application of Channelsplit and Channel shuffle reduces the computational complexity of the model, reduces the model's memory usage, and greatly improves the model's computational efficiency.

[0068] like Figure 5As shown in Figure 2, when the stride is 2, the Inverted Residual module uses a downsampling unit block and no longer uses Channel split. Instead, it directly uses the original input. Each branch uses a 3×3 depthwise convolution with a stride of 2 for downsampling. One branch adds a 1×1 convolution afterwards, and the other branch adds a 1×1 convolution before and after. After the two branches are connected through Concat, the spatial size of the feature map is halved, but the number of channels is doubled. Finally, the Channel shuffle module shuffles and rearranges each channel to mix features, improving the feature expression ability and detection accuracy of the convolutional neural network model.

[0069] Depthwise convolution is a convolution kernel responsible for one channel, and one channel is convolved by only one convolution kernel, that is, convolution operation is performed independently on each channel of the input layer.

[0070] S43: Reduce neck network width;

[0071] like Figure 7 As shown in the figure, the improved model proposed in the present invention continues to use the FPN (feature pyramid network) + PAN (path aggregation network) structure of YOLO v5 as the neck network; the number of convolution kernels of the C3 module and the Conv module in the neck network part is large, and the number of feature map channels generated is large, which will take up more cache space, reduce the running speed, and affect the calculation amount of the entire network; in order to lightweight the model, the number of convolution kernels of the C3 module and the Conv module in the neck network part in the configuration file is reduced to 128, which can reduce the number of channels for generating feature maps, reduce the network width, reduce the number of parameters and calculation amount of the model, and speed up the model operation speed.

[0072] S44: Improve the detection scale, specifically:

[0073] When the input image size is 640×640, the three detection scales corresponding to YOLO v5 are 20×20, 40×40, and 80×80 respectively. For the 20×20 detection scale, its receptive field is a 32×32 pixel area, which is mainly used to detect large objects, while the 40×40 detection scale has a receptive field of 16×16 pixels, which is mainly used to detect medium-sized objects. Finally, the 80×80 detection scale has a receptive field of 8×8 pixels, which is mainly used to detect small objects.

[0074] The sugarcane aphids photographed under natural light are distributed in various positions and corners of the leaves, and there are sugarcane aphid forms of different growth stages on the leaves, so the sugarcane aphids mapped into the image also have different sizes, especially the dense image containing multiple sugarcane aphid targets; the single sugarcane aphid individual to be detected by the present invention accounts for a very small proportion of the input image, and multiple downsampling will cause the loss of tiny target feature information extracted by the convolution layer during training, resulting in the inability to identify the tiny sugarcane aphid larvae; a dense image may contain many medium-scale, small-scale and micro-scale sugarcane aphid targets; and the small-scale detection layer of YOLO v5 has poor applicability to these tiny sugarcane aphid larvae, while the large-scale detection layer is difficult to detect sugarcane aphids. In order to cope with complex dense scenes under natural light, such as Figure 8 As shown, this paper improves the three detection scales of YOLO v5. The 40×40 and 80×80 detection scales for small and medium-sized objects are retained, the 20×20 detection scale for large objects in the original model is removed, and a 160×160 detection scale for small objects is added. This microscale detection layer generates a feature map by fusing lower spatial features extracted by 4x downsampling of the input image using the Stem module with deep semantic features. This new microscale detection layer forms a broader and more detailed detection network structure, making it more suitable for detecting tiny, densely packed sugarcane aphids in images under natural lighting, allowing the network to better adapt to the target being detected.

[0075] S5: Input the data set to train and obtain a lightweight model;

[0076] The Pytorch 1.7.0 deep learning framework was used, and the training image size was set to 640 × 640. The learning rate, batch size, number of iterations, and number of categories were set to 0.001, 16, 500, and 1, respectively. The smallest YOLO v5 model among the four YOLO v5 models was used to train the dataset. Figure 9 As shown in the figure, the mosaic enhancement method of YOLO v5 is used to enhance the data set images. Mosaic data enhancement uses random scaling, random cropping, and random arrangement to stitch four random images together. Finally, the stitched images are scaled to the set input size and passed into the model as new samples. The mosaic data enhancement method enriches the position distribution of the target and amplifies small-sized targets to a certain extent, thereby improving the model training efficiency and generalization ability. The dataset is input and trained to obtain a sugarcane aphid target detection model based on the lightweight YOLO v5.

[0077] This paper uses precision (P), recall (R) and mean average precision (mAP) as relevant indicators for model performance evaluation; precision is used to measure the accuracy of model detection, that is, precision; recall is used to evaluate the comprehensiveness of model detection, that is, recall; single-category precision (AP) uses the integral method to calculate the area enclosed by the precision and recall curves and the coordinate axes; the mAP value can be obtained by adding the AP values ​​of a single category and then dividing it by the number of categories. The mAP value is generally calculated when IOU = 0.5, that is, mAP@0.5, where IOU is the intersection over union ratio, which is an important function for calculating mAP. The specific formula is as follows:

[0078]

[0079]

[0080]

[0081]

[0082]

[0083] In formula (1), A and B are the predicted box and the true box, respectively. The denominator is the intersection of the two boxes, and the numerator is the union of the two boxes. In formulas (2) and (3), TP is true positive: a positive target is predicted as positive; FP is false positive: a negative target is incorrectly predicted as positive; and FN is false negative: a positive target is incorrectly predicted as negative. In formula (4), P(r) is the smoothed precision and recall curve, and the integral operation is to calculate the area occupied by the smoothed curve. In formula (5), C is the number of categories, and APi represents the precision of the i-th category, where i is the sequence number. The number of categories in the present invention is 1.

[0084] The experimental results in Table 1 show that the lightweight model reduces the total number of parameters by 95.13% compared to the original model, takes up only 1.03MB of storage space, reduces inference time by 61.75%, and improves the mean average precision (mAP) by 0.9%.

[0085] Table 1 Comparison between the improved model and the original model

[0086]

[0087] This shows that the improved solution of the present invention not only reduces the weight of the model but also improves the accuracy and detection speed of the model. Figure 10This is a schematic diagram of the lightweight YOLO v5 model of the present invention for target detection in sugarcane aphid images. It can be seen that the present model also has good detection effects in dense sugarcane aphid images. Therefore, the sugarcane aphid target detection method proposed in the present invention for farmland natural lighting environments has the advantages of high recognition accuracy, fast recognition speed, and low memory usage, which is conducive to model deployment on mobile terminals.

[0088] With the above-described preferred embodiments of the present invention as a guide, and with reference to the above description, relevant personnel are fully capable of making various changes and modifications without departing from the technical scope of this invention. The technical scope of this invention is not limited to the contents of the specification and must be determined according to the scope of the claims.

Claims

1. A sugarcane aphid target detection method based on lightweight YOLO v5, characterized in that: The following steps are involved: S1: Sugarcane aphid image collection; S2: image preprocessing; S3: Create dataset; S4: Lightweight improvement of YOLO v5 model; S41: Use the Stem module to replace the Focus module in the backbone network; S42: Use the Inverted Residual module of ShuffleNetV2 to replace the C3 module, Conv module and SPP module in the backbone network; The Backbone network includes: a Stem module cascaded with the first to sixth ShuffleNetV2 modules in sequence, wherein the first ShuffleNetV2 module is an Inverted Residual layer with a step size of 2, the second ShuffleNetV2 module is three Inverted Residual layers with a step size of 1, the third ShuffleNetV2 module is one Inverted Residual layer with a step size of 2, the fourth ShuffleNetV2 module is seven Inverted Residual layers with a step size of 1, the fifth ShuffleNetV2 module is one Inverted Residual layer with a step size of 2, and the sixth ShuffleNetV2 module is three Inverted Residual layers with a step size of 1; The Stem module is connected to the first Concat layer of the Neck network, the second ShuffleNetV2 module is connected to the second Concat layer of the Neck network, the fourth ShuffleNetV2 module is connected to the third Concat layer of the Neck network, and the sixth ShuffleNetV2 module is connected to the fourth Conv layer of the Neck network; the output features of the first stack of three C3 modules in the Neck network are connected to the 160×160 micro-scale detection layer; S43: Reduce neck network width; S44: Improved detection scale; Step S44 includes: the three detection scales corresponding to the lightweight YOLO v5 are 40×40, 80×80, and 160×160 respectively; S5: Input the dataset for training to obtain a lightweight model.

2. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1 is characterized in that, The step S1 includes: the collected image includes four light intensities: weak light, strong light, direct light and diffuse light.

3. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1, characterized in that: The step S2 includes: dividing the collected original image into a number of sub-images of a certain pixel size.

4. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1, characterized in that: The step S3 includes: manually labeling the sugarcane aphids in each image in the dataset using LabelImg, and using the minimum bounding rectangle of the target as the true frame during labeling.

5. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1, characterized in that: The step S41 includes: The Stem module structure first uses a 3×3 convolution with a stride of 2; then uses a two-branch structure, one branch uses a 1×1 convolution and a 3×3 convolution with a stride of 2, and the other branch uses a maximum pooling; finally, the two branches are connected through Concat, and the output is a 1×1 convolution. After the image passes through the Stem module, it is downsampled by 4 times.

6. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1, characterized in that: The step S42 includes: When the stride is 1, the Inverted Residual module extracts features using repeated 1×1 convolutions and 3×3 depthwise convolutions, using short-circuit connections to increase network depth. A Channel split operation is added before each short-circuit connection to split the input feature channel into two. After the two branches are connected through Concat, a Channel shuffle module is added to shuffle each feature channel to mix the features. When the stride is 2, the Inverted Residual module uses a downsampling unit block. Each feature channel is downsampled using a 3×3 depthwise convolution with a stride of 2. One branch adds a 1×1 convolution after the convolution, and the other branch adds a 1×1 convolution before and after the convolution. The two branches are connected by Concat. Finally, the Channel shuffle module is used to shuffle and rearrange each feature channel to mix the features. Depthwise convolution is a convolution kernel responsible for one channel, and one channel is convolved by only one convolution kernel.

7. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1, characterized in that: The step S43 includes: setting the number of convolution kernels of the C3 module and the Conv module of the neck network part in the YOLO v5 configuration file to 128.

8. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1, characterized in that: The 160×160 micro-scale detection layer generates a feature map by fusing the lower spatial features extracted by the Stem module by reducing the dimension of the input image by 4 times and the deep semantic features.

9. The sugarcane aphid target detection method based on lightweight YOLO v5 according to claim 1, characterized in that: The step S5 includes: using the Pytorch1.7.0 deep learning framework, setting the training image size to 640×640, and setting the learning rate, batch size, number of iterations, and number of categories to 0.001, 16, 500, and 1, respectively; and using the Mosaic enhancement method to perform data enhancement on the dataset images.

Citation Information

Patent Citations

  • Germinated potato image recognition method based on improved yolov5 model

    CN114120037A