Cotton aphid quantity determination method and system and electronic equipment
By improving the YOLOv7-tiny network and introducing a coordinate attention mechanism, the problems of time-consuming, labor-intensive, and inaccurate cotton aphid detection were solved, enabling rapid and accurate detection and counting of cotton aphids and improving the performance of the detection model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHIHEZI UNIVERSITY
- Filing Date
- 2023-12-27
- Publication Date
- 2026-04-17
AI Technical Summary
Existing cotton aphid detection methods are time-consuming, labor-intensive, and inaccurate. In particular, they are easily affected by visual fatigue when counting cotton aphids, making it difficult to achieve rapid and accurate detection and counting.
An improved YOLOv7-tiny network was adopted, combined with the Coordinate Attention (CA) mechanism, to detect and count cotton aphid images using the training dataset. The combination of backbone network, CA network, neck network and head network was used to optimize feature extraction and detection performance.
It improves the accuracy and efficiency of cotton aphid quantity determination, enables rapid and accurate detection and counting of cotton aphids, and enhances the performance of the detection model.
Smart Images

Figure CN121884104A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cotton aphid detection, and in particular to a method, system, and electronic device for determining the number of cotton aphids. Background Technology
[0002] Cotton is a natural fiber crop and an important oilseed crop, playing a vital role in the economies of cotton-producing countries worldwide. However, cotton is highly susceptible to various pests during its growth, such as cotton aphids, cotton thrips, and cotton spider mites. These pests severely impact cotton yield and quality. Xinjiang, China, is one of the country's major cotton-producing regions, but cotton yield and quality in this area are significantly affected by pests like cotton aphids. Cotton aphids feed on cotton leaves and young shoots, leading to smaller and fewer leaves, delayed bud development, fewer bolls, and even stunted cotton plants. Furthermore, the honeydew excreted by cotton aphids provides a substrate for the growth of *Fungiformis glomeratus*, which grows by covering cotton leaves and inhibits photosynthesis, resulting in slow plant growth. Therefore, timely control of cotton aphids is essential to ensure cotton yield and quality. Currently, chemical pesticides are an effective and commonly used method for controlling cotton aphids. However, improper use of chemical pesticides can lead to increased resistance in cotton aphids, resulting in even more severe cotton aphid infestations. Furthermore, the overuse of chemical pesticides leads to increased pest control costs and severe environmental pollution. Therefore, a reasonable cotton aphid control process is as follows: investigate the cotton aphid infestation in the field to determine the extent of damage, and then control the dosage of chemical pesticides based on this damage. Since the number of cotton aphids is a crucial indicator of the severity of damage, and cotton aphids are mostly located on the underside of cotton leaves, investigators typically need to visually detect and count them. However, this traditional method of manual detection and counting is very time-consuming and labor-intensive. Moreover, prolonged work can cause visual fatigue, which affects the accuracy of aphid detection and counting. Therefore, it is necessary to develop a rapid and accurate method for cotton aphid detection and counting.
[0003] While deep learning-based object detection methods have been applied to pest detection research, studies using this method to detect cotton aphids are scarce. Traditional manual methods for detecting and counting cotton aphids are extremely time-consuming and labor-intensive, and prolonged use can lead to visual fatigue and inaccurate results. In recent years, deep learning-based object detection methods have been able to replace human vision, achieving rapid and accurate pest detection. In some pest detection studies, the introduction of attention mechanisms has often improved the pest detection performance of object detection models. As a recently proposed attention mechanism, Coordinate Attention (CA) is an attention mechanism that encodes channel relationships and long-range dependencies using precise location information, effectively improving the performance of object detection models. In the YOLOv7-tiny model structure, stage layers 2, 3, and 4 of the backbone network extract feature maps at three different scales. Since these three different scale feature maps are input into the neck network for feature aggregation, the feature extraction performance of the backbone network is closely related to the performance of the YOLOv7-tiny model. Because real cotton aphids are only a few millimeters long and occupy a very small percentage of pixels in a single image, their features are not obvious, making it difficult to accurately detect them. Summary of the Invention
[0004] The purpose of this invention is to provide a method, system, and electronic device for determining the number of cotton aphids, so as to improve the accuracy of cotton aphid detection.
[0005] To achieve the above objectives, the present invention provides the following solution:
[0006] A method for determining the number of cotton aphids includes:
[0007] Acquire images of cotton aphids in the area to be detected;
[0008] Based on the cotton aphid images, cotton aphid detection results are obtained using a cotton aphid detection model. The cotton aphid detection model is trained on an improved YOLOv7-tiny network using a training dataset. The training dataset includes labeled cotton aphid images used for training. The improved YOLOv7-tiny network comprises a backbone network, a CA network, a neck network, and a head network connected in sequence. The CA network includes a first CA module, a second CA module, and a third CA module.
[0009] Based on the cotton aphid detection results, the number of cotton aphids in the area to be tested is determined.
[0010] Optionally, the backbone network includes a trunk layer, a first stage layer, a second stage layer, a third stage layer, and a fourth stage layer connected in sequence;
[0011] The dry layer includes two CBL modules connected in sequence; the first stage layer includes an ELAN-tiny module; the second stage layer, the third stage layer, and the fourth stage layer each include a Max-Pooling module and an ELAN-tiny module connected in sequence; the ELAN-tiny module in the second stage layer is connected to the first CA module; the ELAN-tiny module in the third stage layer is connected to the second CA module; and the ELAN-tiny module in the fourth stage layer is connected to the third CA module.
[0012] Optionally, the neck network includes a first CBL module to a ninth CBL module, a first ELAN-tiny module to a fourth ELAN-tiny module, a first Concat module to a fourth Concat module, a first Upsample module, a second Upsample module, and an SPPFCSPC module;
[0013] The first CBL module is connected to the first CA module; the second CBL module is connected to the second CA module; the SPPFCSPC module is connected to the third CA module; the SPPFCSPC module, the third CBL module, the first Upsample module, the first Concat module, the first ELAN-tiny module, the fourth CBL module, the second Upsample module, the second Concat module, and the second ELAN-tiny module are connected sequentially; the first CBL module is connected to the second Concat module; the second CBL module is connected to the first Concat module; the second ELAN-tiny module is connected to the fifth and sixth CBL modules respectively; the sixth CBL module is connected to the third Concat module; the first ELAN-tiny module is connected to the third Concat module; the third Concat module is connected to the third ELAN-tiny module; the third ELAN-tiny module is connected to the seventh and eighth CBL modules respectively; the eighth CBL module and the SPPFCSPC module are both connected to the fourth Concat module; the fourth Concat module is connected to the fourth ELAN-tiny module; the fourth ELAN-tiny module is connected to the ninth CBL module.
[0014] Optionally, the head network includes three learning networks; the learning network includes an ImplicitA module, a convolutional layer, a BN layer, and an ImplicitM module connected in sequence.
[0015] Optionally, the improved YOLOv7-tiny network is trained using the training dataset, specifically including:
[0016] The labeled cotton aphid training images are input into the improved YOLOv7-tiny network to obtain prediction results;
[0017] Determine the true labels of the training cotton aphid images and the total loss of the prediction results;
[0018] The hyperparameters of the improved YOLOv7-tiny network are adjusted based on the total loss to obtain the cotton aphid detection model.
[0019] A cotton aphid population determination system, comprising:
[0020] The image acquisition module is used to acquire images of cotton aphids in the area to be detected;
[0021] The cotton aphid detection module is used to obtain cotton aphid detection results based on the cotton aphid images using a cotton aphid detection model. The cotton aphid detection model is trained on an improved YOLOv7-tiny network using a training dataset. The training dataset includes labeled cotton aphid images used for training. The improved YOLOv7-tiny network comprises a backbone network, a CA network, a neck network, and a head network connected in sequence. The CA network includes a first CA module, a second CA module, and a third CA module.
[0022] The counting module is used to determine the number of cotton aphids in the area to be detected based on the cotton aphid detection results.
[0023] An electronic device includes: a memory and a processor, wherein the memory stores a computer program, and the processor runs the computer program to cause the electronic device to perform the above-described method for determining the number of cotton aphids.
[0024] Optionally, the memory is a readable storage medium.
[0025] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0026] This invention relates to a method, system, and electronic device for determining the number of cotton aphids. The method involves acquiring images of cotton aphids in a region to be detected; obtaining cotton aphid detection results using a cotton aphid detection model based on the images; wherein the cotton aphid detection model is trained on an improved YOLOv7-tiny network using a training dataset; the training dataset includes labeled cotton aphid images for training; the improved YOLOv7-tiny network comprises a backbone network, a CA network, a neck network, and a head network connected in sequence; the CA network includes a first CA module, a second CA module, and a third CA module; and determining the number of cotton aphids in the region to be detected based on the cotton aphid detection results. This invention improves the accuracy of cotton aphid quantity determination. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 Flowchart of the method for determining the number of cotton aphids provided by the present invention;
[0029] Figure 2 This is a flowchart illustrating the cotton aphid quantity determination method of the present invention in practical application;
[0030] Figure 3 This is a schematic diagram of the YOLOv7-tiny network structure;
[0031] Figure 4 A schematic diagram of the improved YOLOv7-tiny network structure. Detailed Implementation
[0032] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0033] The purpose of this invention is to provide a method, system, and electronic device for determining the number of cotton aphids, so as to improve the accuracy of cotton aphid detection.
[0034] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0035] Example 1
[0036] like Figure 1 As shown, the method for determining the number of cotton aphids provided by the present invention includes:
[0037] Step 101: Obtain images of cotton aphids in the area to be detected.
[0038] Step 102: Based on the cotton aphid images, obtain cotton aphid detection results using the cotton aphid detection model; wherein, the cotton aphid detection model is obtained by training an improved YOLOv7-tiny network using a training dataset; the training dataset includes training cotton aphid images with labeled cotton aphids; the improved YOLOv7-tiny network includes a backbone network, a CA network, a neck network, and a head network connected in sequence; the CA network includes a first CA module, a second CA module, and a third CA module.
[0039] Step 103: Determine the number of cotton aphids in the area to be tested based on the cotton aphid detection results.
[0040] like Figure 2 As shown, the construction and application process of the cotton aphid detection model of the present invention is as follows:
[0041] S1: Use a camera (e.g., a smartphone camera) to acquire high-resolution images of cotton aphids under natural conditions (training cotton aphid images), and annotate the acquired high-resolution images of cotton aphids under natural conditions.
[0042] S2: Use three data augmentation methods—increasing brightness, decreasing brightness, and random angle rotation—to expand the size of the dataset.
[0043] S3: Divide the dataset into training dataset, validation dataset and test dataset in a ratio of 6:2:2.
[0044] S4: Train the improved YOLOv7-tiny object detection model based on the training set. Select YOLOv7-tiny as the baseline model. Figure 3 As shown, YOLOv7-tiny consists of three parts: a backbone network, a neck network, and a head network.
[0045] The YOLOv7-tiny backbone network consists of five layers: the backbone layer, stage 1 (first stage), stage 2 (second stage), stage 3 (third stage), and stage 4 (fourth stage). These five layers contain three modules: the CBL module, the ELAN-tiny module, and the Max-Pooling module. The CBL module comprises convolutional layers, batch normalization (BN) layers, and the LeakyReLU activation function. The ELAN-tiny module is a smaller version of the Efficient Layer Aggregation Network (ELAN), composed of multiple CBL modules. The Max-Pooling module is the maximum pooling layer in the network.
[0046] As an optional implementation, the dry layer includes two CBL modules connected in sequence; the first stage layer includes an ELAN-tiny module; the second stage layer, the third stage layer, and the fourth stage layer each include a Max-Pooling module and an ELAN-tiny module connected in sequence; the ELAN-tiny module in the second stage layer is connected to the first CA module; the ELAN-tiny module in the third stage layer is connected to the second CA module; and the ELAN-tiny module in the fourth stage layer is connected to the third CA module.
[0047] In practical applications, in the backbone network of YOLOv7-tiny, the trunk layer consists of two CBL modules, stage 1 consists of one ELAN-tiny module, and stage 2, stage 3 and stage 4 each consist of one Max-Pooling module and one ELAN-tiny module.
[0048] As an optional implementation, the neck network includes a first CBL module to a ninth CBL module, a first ELAN-tiny module to a fourth ELAN-tiny module, a first Concat module to a fourth Concat module, a first Upsample module, a second Upsample module, and an SPPFCSPC module.
[0049] The first CBL module is connected to the first CA module; the second CBL module is connected to the second CA module; the SPPFCSPC module is connected to the third CA module; the SPPFCSPC module, the third CBL module, the first Upsample module, the first Concat module, the first ELAN-tiny module, the fourth CBL module, the second Upsample module, the second Concat module, and the second ELAN-tiny module are connected sequentially; the first CBL module is connected to the second Concat module; the second CBL module is connected to the first Concat module; the second ELAN-tiny module is connected to the fifth and sixth CBL modules respectively; the sixth CBL module is connected to the third Concat module; the first ELAN-tiny module is connected to the third Concat module; the third Concat module is connected to the third ELAN-tiny module; the third ELAN-tiny module is connected to the seventh and eighth CBL modules respectively; the eighth CBL module and the SPPFCSPC module are both connected to the fourth Concat module; the fourth Concat module is connected to the fourth ELAN-tiny module; the fourth ELAN-tiny module is connected to the ninth CBL module.
[0050] In practical applications, the neck network of YOLOv7-tiny consists of multiple CBL modules, multiple ELAN-tiny modules, multiple Concat modules, multiple Upsample modules, and one SPPFCSPC module. The Concat module is a feature connection module. The Upsample module is a feature upsampling module. The SPPFCSPC module consists of multiple CBL modules, multiple Max-Pooling modules, and multiple Concat modules. The neck network of YOLOv7-tiny, composed of various modules, constructs both top-down and bottom-up paths, thereby achieving the fusion of features extracted from the last three layers of the backbone network.
[0051] As an optional implementation, the head network includes three learning networks; the learning network includes an ImplicitA module, a convolutional layer, a BN layer, and an ImplicitM module connected in sequence.
[0052] As the final part of the detector, the YOLOv7-tiny head network consists of multiple ImplicitA modules, multiple convolutional layers, multiple Batch Normalization (BN) layers, and multiple ImplicitM modules. In the YOLOv7-tiny head network, the ImplicitA modules enable the network model to learn implicit knowledge through addition, while the ImplicitM modules enable the network model to learn implicit knowledge through multiplication.
[0053] In YOLOv7-tiny, a coordinate attention (CA) mechanism was added to improve the network model. For example... Figure 4 As shown, compared to the original YOLOv7-tiny model structure, three CA modules are added to the front end of the neck network, that is, one CA module is connected after each of the three outputs of the backbone network. Each CA module optimizes the cotton aphid features extracted from the backbone network, thereby improving the performance of the YOLOv7-tiny model.
[0054] As an optional implementation, the improved YOLOv7-tiny network is trained using a training dataset, specifically including:
[0055] The labeled cotton aphid training images are input into the improved YOLOv7-tiny network to obtain prediction results.
[0056] Determine the true labels of the cotton aphid images used for training and the total loss of the prediction results.
[0057] The hyperparameters of the improved YOLOv7-tiny network are adjusted based on the total loss to obtain the cotton aphid detection model.
[0058] The hyperparameters for training the improved YOLOv7-tiny network were set as follows: the input image size was set to 3456×3456 pixels to preserve the cotton aphid features in the high-resolution image. The anchor points were optimized using the K-means clustering algorithm, resulting in the following anchor points: [[(10, 10), (12, 12), (13, 17)], [(17, 15), (17, 20), (22, 19)], [(27, 28), (64, 34), (37, 62)]]. The Intersection over Union (IoU) threshold for the Non-Maximum Suppression (NMS) algorithm was set to 0.5. A cosine decay method with preheating was used to change the learning rate, with an initial learning rate of 0.01. To improve model convergence and stability during training, the SGDM optimizer was used, with a momentum of 0.937 and a weight decay exponent of 0.0005. The training batch size is set to 2, and the total number of training epochs is 150. The loss function used consists of three parts: classification loss, bounding box regression loss, and object confidence loss. The calculation formula is as follows:
[0059] Loss = L cls +L bbox +L obj (1).
[0060] Where Loss is the total loss for each iteration during training, L cls It is classification loss, L bbox It is the bounding box regression loss, L bbox It is the target confidence loss.
[0061] Classification loss refers to the loss in classifying a sample. It is calculated using the binary cross-entropy loss function, with the following formula:
[0062]
[0063] Among them, L cls It is the classification loss, λ cls It is L cls The weighting coefficients, where N is the sample size. i Used to determine whether the true class of sample i is the predicted class (if the true class of the i-th sample is the predicted class, then y i The value of y is 1, otherwise y i The value of p is 0). i It is the probability value that the predicted sample i is the true class.
[0064] Bounding box regression loss is a set of Complete Intersection over Union (CIoU) losses between predicted bounding boxes and target bounding boxes, calculated as follows:
[0065]
[0066] Among them, L bbox is the bounding box regression loss, M is the number of predicted bounding boxes, and CIoU is the cross-union ratio between a set of predicted bounding boxes and the target bounding box.
[0067] The formula for calculating CIoU is as follows:
[0068]
[0069] Where b is the predicted bounding box, b gt It is the target bounding box, ρ 2 (b,b gt ) represents the square of the Euclidean distance between the center point of the predicted bounding box and the center point of the target bounding box, c 2 ν represents the square of the diagonal length of the smallest rectangle that simultaneously contains the predicted bounding box and the target bounding box. α is a positive trade-off parameter, and ν represents the consistency of the aspect ratios of the predicted bounding box and the target bounding box.
[0070] The formula for calculating α is as follows:
[0071]
[0072] Where b is the predicted bounding box, b gt ν represents the target bounding box, and ν indicates the degree of consistency between the aspect ratios of the predicted bounding box and the target bounding box.
[0073] The formula for calculating ν is as follows:
[0074]
[0075] Among them, w gt h represents the width of the target bounding box. gt represents the height of the target bounding box, w represents the width of the predicted bounding box, and h represents the height of the predicted bounding box.
[0076] The target confidence loss is the bias calculated by determining whether each sample contains the target. The target confidence loss is calculated using the binary cross-entropy loss function, as shown in the following formula:
[0077]
[0078] Among them, L obj This is the target confidence loss, where S is the number of all samples.i The value of z varies depending on whether the i-th sample contains a target (if the i-th sample contains a target, then z...). i The value of z is 1, otherwise z i The value of σ is 0). i It is the probability value that the i-th sample currently contains a target.
[0079] Train the network model using the dataset based on the set network training hyperparameters.
[0080] The metrics used include Average Precision (AP), mean Average Precision (mAP), number of model parameters, number of floating-point operations (FLOPs), frames per second (FPS), and R-squared. 2 The improved YOLOv7-tiny network was evaluated for its cotton aphid detection and counting performance using eight metrics: mean absolute error (mAP), mean absolute error (MAE), and root mean squared error (RMSE). During training, a total of 150 training epochs were performed. Model weights were saved every 10 epochs and tested against the evaluation metrics on the validation set. The model weights with the highest mAP values were selected for testing against the evaluation metrics on the test set, yielding the final network model evaluation results. Among these metrics, the number of model parameters reflects the model's size, FLOPs can be used to analyze the model's computational cost, and FPS can be used to analyze the model's inference speed.
[0081] AP measures the model's performance in detecting cotton aphids by the area under the precision-recall curve, calculated as follows:
[0082]
[0083] Where N represents the number of samples, P(k) represents the precision of sample k, and Δr(k) is the absolute value of the difference between the recall of the k-th sample and the recall of the (k-1)-th sample, Δr(k) = r(k) - r(k-1).
[0084] The mAP value is equal to the average AP values of all categories, and the calculation formula is as follows:
[0085]
[0086] Where m represents the number of categories, N represents the number of samples, P(k) represents the precision of sample k, and Δr(k) is the absolute value of the difference between the recall of the k-th sample and the recall of the (k-1)-th sample, Δr(k) = r(k) - r(k-1).
[0087] R 2 R is the coefficient of determination, used to measure how close the predicted value is to the actual value. 2 The closer the value is to 1, the closer the predicted value is to the actual value. R 2 The calculation formula is as follows:
[0088]
[0089] Where S represents the sample size, y i It represents the actual number of cotton aphids in the i-th image. This represents the predicted number of cotton aphids in the i-th image. It is the average number of cotton aphids in the image.
[0090] MAE, or Mean Absolute Error, is used to analyze the deviation between predicted and actual values. Furthermore, in most cases, MAE directly reflects the deviation between predicted and actual values. The formula for calculating MAE is as follows:
[0091]
[0092] Where S represents the sample size, y i It represents the actual number of cotton aphids in the i-th image. This represents the predicted number of cotton aphids in the i-th image.
[0093] RMSE, or Root Mean Square Error, is a metric used to analyze the deviation between predicted and actual values. Compared to MAE, RMSE focuses more on situations where there is a significant deviation between predicted and actual values. The formula for calculating RMSE is as follows:
[0094]
[0095] Where S represents the sample size, y i It represents the actual number of cotton aphids in the i-th image. This represents the predicted number of cotton aphids in the i-th image.
[0096] In the evaluation metrics of the COCO public dataset, a bounding box prediction is considered accurate as long as the IoU value between the predicted and ground truth bounding boxes is higher than 0.5. In this case, AP is referred to as AP-50, and mAP is referred to as mAP-50. In the collected cotton aphid images, cotton aphids occupy a very small proportion of pixels. Once the predicted bounding box has a small offset compared to the ground truth bounding box, the IoU value between the predicted and ground truth bounding boxes becomes very small. Therefore, in the cotton aphid detection task, it is not necessary for the predicted bounding box to be highly coincident with the target bounding box to be considered accurate. In the performance evaluation of YOLOv3, the mAP-50 metric is used as an important evaluation metric. Therefore, the AP-50 and mAP-50 metrics are used as evaluation metrics to improve the model's detection performance.
[0097] S5: Input the cotton aphid image to be detected into the trained improved Y0L0v7-tiny target detection model for detection, and generate the cotton aphid detection and counting results of the cotton aphid image.
[0098] This invention proposes an improved method for cotton aphid detection and counting based on YOLOv7-tiny, incorporating a Coordinate Attention (CA) mechanism to enhance the model. In the YOLOv7-tiny model structure, stage 2, stage 3, and stage 4 of the backbone network extract feature maps at three different scales. Since these feature maps at different scales are input into the neck network for feature aggregation, the feature extraction performance of the backbone network is closely related to the performance of the YOLOv7-tiny model. Because real-world cotton aphids are only a few millimeters long and occupy a very small percentage of pixels in a single image, their features are not readily apparent. To optimize the cotton aphid features extracted from the backbone network and improve the performance of the YOLOv7-tiny model, a CA module is added to improve the model. Compared to the original YOLOv7-tiny model structure, three CA modules are added to the front end of the neck network; that is, one CA module is connected after each of the three outputs of the backbone network. The performance of the YOLOv7-tiny model is improved by optimizing the cotton aphid features extracted from the backbone network through each CA module. The improved YOLOv7-tiny performs excellently in cotton aphid detection and counting, achieving an mAP-50 of 89.2%, an FPS of 10.0, and an R... 2 The results showed an accuracy of 0.9977, a MAE of 2.14, and an RMSE of 3.37. This invention provides a new method for the rapid and accurate detection and counting of cotton aphids in the field.
[0099] The cotton aphid quantity determination method, system, and electronic device of the present invention have the following advantages:
[0100] 1. This invention provides an automatic detection and counting method for cotton aphids based on the improved YOLOv7-tiny, which can realize the automatic detection and counting of cotton aphids in natural environment.
[0101] 2. This invention incorporates a coordinate attention (CA) mechanism into the YOLOv7-tiny target detection model, optimizing the cotton aphid features extracted by the YOLOv7-tiny backbone network, thereby improving the accuracy of cotton aphid detection and counting.
[0102] 3. The improved OCRNet of this invention can load existing pre-trained weights without additional cost, thus accelerating the network training convergence speed.
[0103] 4. This invention uses average precision (AP), mean average precision (mAP), number of model parameters, floating-point operations (FLOPs), and frames per second (FPS) to evaluate the cotton aphid detection performance of the improved YOLOv7-tiny model, thus more precisely distinguishing the effectiveness of the method in cotton aphid detection.
[0104] 5. This invention employs R-squared (R... 2 The improved YOLOv7-tiny model was evaluated using mean absolute error (MAE) and root mean squared error (RMSE) to assess its effectiveness in cotton aphid counting, allowing for a more nuanced assessment of the method's performance in this area.
[0105] 6. This invention uses the Auto Mixed Precision (AMP) training method to reduce GPU memory overhead during network training. This method allows high-resolution cotton aphid images to be input into the network model for normal training while preserving the detailed features of cotton aphids in the high-resolution images.
[0106] 7. This invention creates a labeled high-resolution cotton aphid image dataset.
[0107] Example 2
[0108] In order to execute the method corresponding to Embodiment 1 above and achieve the corresponding functions and technical effects, a cotton aphid quantity determination system is provided below, including:
[0109] The image acquisition module is used to acquire images of cotton aphids in the area to be detected.
[0110] The cotton aphid detection module is used to obtain cotton aphid detection results based on the cotton aphid images using a cotton aphid detection model. The cotton aphid detection model is trained on an improved YOLOv7-tiny network using a training dataset. The training dataset includes labeled cotton aphid images used for training. The improved YOLOv7-tiny network comprises a backbone network, a CA network, a neck network, and a head network connected in sequence. The CA network includes a first CA module, a second CA module, and a third CA module.
[0111] The counting module is used to determine the number of cotton aphids in the area to be detected based on the cotton aphid detection results.
[0112] Example 3
[0113] The present invention provides an electronic device, comprising: a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the cotton aphid quantity determination method of Embodiment 1.
[0114] Optionally, the memory is stored in a readable storage medium.
[0115] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0116] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for determining the number of cotton aphids, characterized by, include: Acquire images of cotton aphids in the area to be detected; Based on the cotton aphid images, cotton aphid detection results are obtained using a cotton aphid detection model. The cotton aphid detection model is trained on an improved YOLOv7-tiny network using a training dataset. The training dataset includes labeled cotton aphid images used for training. The improved YOLOv7-tiny network comprises a backbone network, a CA network, a neck network, and a head network connected in sequence. The CA network includes a first CA module, a second CA module, and a third CA module. Based on the cotton aphid detection results, the number of cotton aphids in the area to be tested is determined.
2. The cotton aphid number determining method according to claim 1, characterized by, The backbone network comprises a trunk layer, a first-stage layer, a second-stage layer, a third-stage layer, and a fourth-stage layer connected in sequence. The dry layer includes two CBL modules connected in sequence; the first stage layer includes an ELAN-tiny module; the second stage layer, the third stage layer, and the fourth stage layer each include a Max-Pooling module and an ELAN-tiny module connected in sequence; the ELAN-tiny module in the second stage layer is connected to the first CA module; the ELAN-tiny module in the third stage layer is connected to the second CA module; and the ELAN-tiny module in the fourth stage layer is connected to the third CA module.
3. The method for determining the number of cotton aphids according to claim 1, characterized in that, The neck network includes a first CBL module to a ninth CBL module, a first ELAN-tiny module to a fourth ELAN-tiny module, a first Concat module to a fourth Concat module, a first Upsample module, a second Upsample module, and an SPPFCSPC module; The first CBL module is connected to the first CA module; the second CBL module is connected to the second CA module; the SPPFCSPC module is connected to the third CA module; the SPPFCSPC module, the third CBL module, the first Upsample module, the first Concat module, the first ELAN-tiny module, the fourth CBL module, the second Upsample module, the second Concat module, and the second ELAN-tiny module are connected sequentially; the first CBL module is connected to the second Concat module; the second CBL module is connected to the first Concat module; the second ELAN-tiny module is connected to the fifth and sixth CBL modules respectively; the sixth CBL module is connected to the third Concat module; the first ELAN-tiny module is connected to the third Concat module; the third Concat module is connected to the third ELAN-tiny module; the third ELAN-tiny module is connected to the seventh and eighth CBL modules respectively; the eighth CBL module and the SPPFCSPC module are both connected to the fourth Concat module; the fourth Concat module is connected to the fourth ELAN-tiny module; the fourth ELAN-tiny module is connected to the ninth CBL module.
4. The method for determining the number of cotton aphids according to claim 1, characterized in that, The head network includes three learning networks; the learning network includes an ImplicitA module, a convolutional layer, a BN layer and an ImplicitM module connected in sequence.
5. The method for determining the number of cotton aphids according to claim 1, characterized in that, The improved YOLOv7-tiny network was trained using the training dataset, specifically including: The labeled cotton aphid training images are input into the improved YOLOv7-tiny network to obtain prediction results; Determine the true labels of the training cotton aphid images and the total loss of the prediction results; The hyperparameters of the improved YOLOv7-tiny network are adjusted based on the total loss to obtain the cotton aphid detection model.
6. A system for determining the number of cotton aphids, characterized in that, include: The image acquisition module is used to acquire images of cotton aphids in the area to be detected; The cotton aphid detection module is used to obtain cotton aphid detection results based on the cotton aphid images using a cotton aphid detection model. The cotton aphid detection model is trained on an improved YOLOv7-tiny network using a training dataset. The training dataset includes labeled cotton aphid images used for training. The improved YOLOv7-tiny network comprises a backbone network, a CA network, a neck network, and a head network connected in sequence. The CA network includes a first CA module, a second CA module, and a third CA module. The counting module is used to determine the number of cotton aphids in the area to be detected based on the cotton aphid detection results.
7. An electronic device, characterized in that, include: A memory and a processor, the memory being used to store a computer program, the processor running the computer program to cause the electronic device to perform the cotton aphid quantity determination method according to any one of claims 1-5.
8. The electronic device according to claim 7, characterized in that, The memory is a readable storage medium.