Improved YOLOv7-tiny-based citrus fruit yield estimation method

By improving the YOLOv7-tiny model, combined with the Biformer double-layer routing attention mechanism and the PConv module, the problems of low detection accuracy and high computational load in the citrus fruit yield estimation method are solved, and lightweight and high-precision citrus fruit detection is achieved, reducing the cost The error in yield estimation improves the accuracy of citrus yield prediction.

CN118711055AInactive Publication Date: 2024-09-27GUILIN UNIVERSITY OF TECHNOLOGY

Patent Information

Application Number
CN202410748958.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing citrus fruit yield estimation methods have long counting cycles, high labor costs, large errors, low efficiency, and low detection accuracy in complex scenarios. They cannot meet the needs for lightweight and high-precision detection, especially in edge devices that lack GPU computing power. On the real-time monitoring task.

Method used

Using the improved YOLOv7-tiny model, by adding the Biformer double-layer routing attention mechanism, replacing ordinary convolutions with GSConv and VoVGSCSP modules, and using the PConv module in the backbone network, combined with manual annotation and data enhancement, the network calculation amount and error are reduced. Improve detection accuracy.

Benefits of technology

The YOLOv7-tiny network realizes lightweight and high-precision target detection, reduces yield estimation errors, improves the accuracy of citrus yield prediction, and provides a more efficient technical means for citrus yield estimation and information counting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118711055A
    Figure CN118711055A
Patent Text Reader

Abstract

The invention provides an improved YOLOv7-tiny citrus fruit yield estimation method, belongs to the field of computer image recognition and agricultural intelligent monitoring, and provides the following improved method for solving the problem that existing network detection precision and detection speed are unbalanced: a Biformer double-layer routing attention mechanism is added behind a space pooling pyramid, and the detection speed of the space pooling pyramid is increased; the method comprises the following steps: replacing common convolution with GSConv in a neck network, introducing a VoVGSCSP module, and replacing a simplified ELAN efficient layer aggregation network with PCConv in a backbone network so as to improve the detection precision and reduce the calculated amount of a network model; and then based on network identification counting and manual counting, combining a regression model to construct a yield estimation prediction model. The invention provides a rapid and accurate citrus fruit yield estimation method which can be applied to portable equipment such as a mobile phone for real-time identification, counting errors can be reduced, counting precision can be improved, and a new thought is provided for development of a fruit yield estimation technology in a complex environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of computer image recognition and agricultural intelligent monitoring, and in particular to a citrus fruit yield estimation method based on improved YOLOv7-tiny. Background Art

[0002] In citrus production, pre-harvest yield estimation is a necessary task to evaluate fruit quality, planting technology, and reflect market supply and demand, and is crucial to guiding agricultural production. Traditional yield estimation methods use manual sampling, which has a long counting cycle, high labor costs, large errors, low efficiency and high labor intensity. At present, researchers distinguish between fruits and branches and leaves based on color features and texture features to achieve the goal of fruit counting, but they are all limited by their own algorithm limitations and cannot find a universal feature extraction model. Lv Qiang et al. used GB color difference components and adaptive threshold algorithm to segment citrus images, and used the least squares circle of Tukey weight function to fit the characteristic circle, but the overall recognition accuracy was low and fruit yield estimation could not be performed. Dorj et al. proposed to use color features to predict citrus yield and use watershed segmentation method to count citrus, but the detection accuracy of this method is greatly affected by distance and background changes. With the improvement of computer computing power and the continuous expansion of data scale, deep learning technology has shown outstanding advantages in image detection. The fast and accurate detection capabilities of target detection networks can provide more efficient technical means for citrus identification and information-based yield estimation.

[0003] However, at present, the target detection network is only accurate in specific scenarios, and shows lower accuracy in complex scenarios or small target situations. In addition, most current yield estimation studies only use network recognition counts as the final yield estimation results, which have low estimation accuracy and large errors, ignoring the problem of missed detection and false detection of network models in complex scenarios. Chinese patent application CN202210787701.9 discloses a YOLO-based citrus green fruit recognition method. Due to the close color of green leaves and green fruits, the accuracy is significantly affected by the environment; Chinese patent application CN202310392025.X discloses a citrus fruit recognition method and system based on improved YOLOv7, but the detection accuracy still has room for improvement, and the network parameters and computational load are too large to meet the needs of edge devices with insufficient GPU computing power, and are not suitable for real-time monitoring tasks. Summary of the invention

[0004] In view of the shortcomings of the prior art, this application proposes a citrus fruit yield estimation method based on improved YOLOv7-tiny, which meets the current lightweight and high-precision detection needs, and combines network recognition and regression analysis methods to effectively reduce counting errors and improve the accuracy of fruit yield estimation. The technical solution of the present invention is:

[0005] A citrus fruit yield estimation method based on improved YOLOv7-tiny, the method comprising the following steps:

[0006] Step 1: Use mobile phones, cameras and other devices to collect multi-angle citrus image data in complex scenes;

[0007] Step 2: Filter out clear sub-images in different scenes from the images obtained in step 1, manually annotate the filtered images to obtain required sample data, and then perform data enhancement operations on the sample data;

[0008] Step 3: Divide the sample data generated in step 2 into training set, validation set and test set according to a certain ratio;

[0009] Step 4: Build an improved YOLOv7-tiny model, and by adding the Biformer two-layer routing attention mechanism, capture the bidirectional dependencies in the input sequence to improve the ability to capture citrus spatial information and background semantic information. At the same time, replace the ordinary convolution with GSConv in the neck network, and introduce the VoVGSCSP module to improve detection accuracy and reduce model inference time. In the backbone network, replace the simplified ELAN efficient layer aggregation network with PConv to more effectively extract features and reduce network calculations. Use the training set produced in step 3 to train the improved YOLOv7-tiny model, and use the validation set to verify the YOLOv7-tiny model;

[0010] Step 5: Get the optimal weights of the YOLOv7-tiny model after training in step 4, load the weights into the model, and then implement citrus fruit detection on the test set data in step 3;

[0011] Step 6: Obtain the network recognition counts in step 5, establish a regression model by combining the network recognition counts with manual counts, and analyze the differences in fruit counting accuracy;

[0012] Step 7: Randomly select citrus trees in the orchard and obtain their complete side views. Use the regression model in step 6 to predict the citrus yield of the entire tree through network recognition and counting;

[0013] Furthermore, according to the citrus fruit yield estimation method based on improved YOLOv7-tiny, Labelimg software is used to manually annotate the citrus images to produce label data, and the label category is citrus.

[0014] Further, according to the citrus fruit yield estimation method based on improved YOLOv7-tiny, the official YOLOv7-tiny model was obtained from the GitHub website.

[0015] Furthermore, according to the citrus fruit yield estimation method based on improved YOLOv7-tiny, the BiFormer double-layer routing attention mechanism module, VoVGSCSP module, and PConv module model were obtained from the GitHub website and embedded into the YOLOv7-tiny model.

[0016] Furthermore, a regression model was established by combining network recognition counting with manual counting, and the regression model was used to randomly select fruit trees for yield prediction.

[0017] Compared with the prior art, the technical solution proposed by the present invention has the following beneficial effects:

[0018] The present invention combines the advantages of Biformer's double-layer routing attention mechanism in detecting small targets, the advantages of the VoVGSCSP module in improving detection accuracy and reducing model inference time, and the advantages of the PConv module in performing efficient feature extraction and reducing network computational complexity; the goal of lightweight and high-precision YOLOv7-tiny network is achieved; and on this basis, a regression model is established by combining network recognition counting and manual recognition counting to further reduce the estimation error and improve the accuracy of citrus yield prediction, providing more efficient and beneficial technical means for citrus yield estimation and information counting. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the specific methods in the embodiments of the present invention, the relevant drawings involved in the embodiments will be briefly described below. The following drawings are only preferred embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative changes.

[0020] Figure 1 A schematic diagram of a citrus fruit yield estimation method based on improved YOLOv7-tiny in the implementation of the present invention;

[0021] Figure 2 It is a schematic diagram of the improvement of the network model in the implementation of the present invention;

[0022] Figure 3 This is a schematic diagram of the improved YOLOv7-tiny model structure in the implementation of the present invention;

[0023] Figure 4 This is a diagram showing the effect of identifying citrus fruits in the implementation of the present invention;

[0024] Figure 5 This is a citrus yield prediction diagram for the implementation of the present invention. DETAILED DESCRIPTION

[0025] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and understandable, the specific implementation methods of the present invention are clearly and completely described below in conjunction with the accompanying drawings. The present invention can be implemented in many ways that are not limited to the embodiments of the present invention. Those skilled in the art can make similar improvements to the present invention under the premise of making creative work, and the present invention is not limited to the specific implementation disclosed below.

[0026] like Figure 1 As shown, in an embodiment of the present invention, a citrus fruit yield estimation method based on improved YOLOv7-tiny is provided, the network model is improved by model reconstruction and module replacement, and regression analysis is performed on the improved network recognition count and manual count to construct a yield estimation model, which specifically includes the following steps:

[0027] Step 1: Figure 1 In the citrus image acquisition and preprocessing stage, mobile phones, cameras and other devices were used to collect real images of citrus in the natural environment. In order to obtain citrus images at different distances, we took pictures of the citrus trees from 0.5 to 2.0 meters away from the trees, looking up, looking down, with the light shining, and with the light shining. We also took pictures of the citrus trees in various real growth conditions, such as sparse, dense, blocked, and overlapping fruits, to ensure the representativeness of the sample data. In the end, a total of 525 high-definition citrus images were collected in .JPG format, with a resolution of 4096×3072 for each image.

[0028] Step 1.1: Using the citrus images collected in step 1, 200 representative images were selected for data augmentation. The original images were manually annotated using the image annotation software Labelimg, and the annotated data was converted from xml format to txt format. Then, the Mixup method, Mosaic method, image equalization, grayscale, and gamma transformation were used for mixed data augmentation to obtain a dataset of 3,200 citrus images, which were divided into training set, validation set, and test set according to a ratio of 8:1:1.

[0029] Step 2: Improve the network model Figure 2 As shown, this implementation aims to reduce network parameter redundancy and improve detection accuracy, and specifically includes the following steps:

[0030] Step 2.1: Figure 2As shown in (a), a Biformer two-layer routing attention mechanism is added after the backbone network. It consists of an encoder and a decoder. The attention score of each position is calculated by the query vector (Q), key vector (K), and value vector (V) in the input sequence, thereby establishing a global association within the sequence. The query vector Q is used to indicate the content that needs to be paid attention to in the current position in the attention mechanism. It determines the weight in the attention allocation process by calculating the similarity with the key vector K; the value vector V contains the actual feature representation. It will be assigned different weights according to the similarity between Q and K to determine the importance of different positions in the output. The relationship between them is shown in formulas (1), (2), and (3):

[0031] K g =gather(K,I r ) (1)

[0032] V g =gather(V,I r ) (2)

[0033] O = Attention(Q, K g , V g )+LCE(V) (3)

[0034] Among them, I in formula (1) and (2) r represents the index tensor, which is used to specify the position of collecting elements from the input tensor; the gather operation is to collect the elements at the corresponding position from the input tensor according to the index; Kg and Vg are the new key and value vectors obtained after the gather operation; in formula (3), Attention represents the calculation of the attention mechanism, LCE represents the cross entropy loss function; O is the final output result, which means that the attention output is calculated through the attention mechanism, and the final output is obtained by adding the attention output to the result of the cross entropy loss, which helps the model better understand the context information in the detection task and make accurate predictions.

[0035] Step 2.2: If Figure 2As shown in (b), the ELAN module is replaced with the VoVGSCSP module in the neck network. The VoVGSCSP module is composed of GSConv through a one-time aggregation method. It first performs a normal convolution on the input feature map to achieve a downsampling effect. Then, one of the branches is subjected to a DWConv deep convolution, and the other branch is concatenated with the result of the deep convolution. Finally, the number of channels of the feature map is changed through the shuffle operation, so that the number of channels of the two convolutions is stacked front and back. GSConv infiltrates the semantic information generated by ordinary convolution into every part of the information generated by DWConv, making full use of the characteristics of ordinary convolution and DWConv, so that the model has both the high speed of DWConv and the high accuracy of ordinary convolution.

[0036] Step 2.3: If Figure 2 As shown in (c), the standard convolution in the backbone network is replaced by the PConv module, where h and w are the height and width of the feature map, respectively, c is the total number of channels, cp is the number of channels used, and the convolution kernel size is k×k. Compared with conventional convolution, PConv only needs to extract spatial features on a part of the input channel and keep the number of other channels unchanged. For continuous or regular memory access, the first or last continuous channel is regarded as the representative of the entire feature map for calculation, and the input and input feature maps are assumed to have the same number of channels without loss of generality. The floating-point operation number and content access calculation formula of PConv are as follows:

[0037]

[0038]

[0039] In formula (4) and (5), From the formula, we can see that the number of floating-point operations of PConv is only Memory access is the same as that of ordinary Conv

[0040] Step 3: Get the YOLOv7-tiny model, reconstruct the network model using the modules in step 2, and train and verify the improved YOLOv7-tiny model using the training set and validation set data prepared in step 1. The training parameters are set as follows: the input image size is 640 pixels × 640 pixels, the batch size is 32, and the stochastic gradient descent (SGD) method is used for model optimization. The initial learning rate is 0.001, the momentum factor is 0.937, and the weight decay factor is 0.0005. The model is trained for 300 epochs, and the weights are saved every 10 epochs.

[0041] Step 4: Get the model weights trained in step 3 and fix them in the YOLOv7-tiny network. Get the side view of the citrus tree in the test set data in step 1 and input it into the improved YOLOv7-tiny network. The recognition process is as follows: Figure 3 As shown in the figure, the input citrus image is first divided into three different scales for feature extraction in the backbone network and then output; then it passes through the spatial pooling pyramid module in the neck network to solve the image distortion problem and improve the speed of generating candidate frames. Then, the three scale feature maps output from the backbone network are upsampled, spliced ​​and feature fused to obtain three output feature maps of different scales. Finally, the citrus image detection result is output through the IDetect module. The citrus fruit image detection result is shown in Figure 4 shown.

[0042] Step 5: Obtain the network recognition and counting results in step 4, obtain the side view image of the citrus tree in the test set data in step 1, obtain the actual number of fruits in the image through human eyes, and perform regression analysis on the above two counting results to build a fruit yield estimation model. The yield estimation model is as follows: Figure 5 As shown, finally, the network recognition count is input into the yield estimation model as the independent variable to obtain the final yield prediction result of the fruit tree.

[0043] In the description of the present invention, the term "comprise" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus that includes a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or apparatus.

[0044] The present invention has been described in an illustrative but not restrictive manner, and the scope of protection of the present invention is not limited thereto. Without departing from the relevant scope of protection defined by the claims, those skilled in the art may make changes and / or modifications, and any modifications, equivalent substitutions, etc. based on this shall be included in the scope of protection of the present invention.

Claims

1. A citrus fruit yield estimation method based on improved YOLOv7-tiny, characterized in that: The method comprises the following steps: Step 1: Use mobile phones, cameras and other devices to collect multi-angle citrus image data in complex scenes; Step 2: Filter out clear sub-images in different scenes from the images obtained in step 1, manually annotate the filtered images to obtain required sample data, and then perform data enhancement operations on the sample data; Step 3: Divide the sample data generated in step 2 into training set, validation set and test set according to a certain ratio; Step 4: Build an improved YOLOv7-tiny model, and by adding the Biformer two-layer routing attention mechanism, capture the bidirectional dependencies in the input sequence to improve the ability to capture citrus spatial information and background semantic information. At the same time, replace the ordinary convolution with GSConv in the neck network, and introduce the VoVGSCSP module to improve detection accuracy and reduce model inference time. In the backbone network, replace the simplified ELAN efficient layer aggregation network with PConv to more effectively extract features and reduce network calculations. Use the training set produced in step 3 to train the improved YOLOv7-tiny model, and use the validation set to verify the YOLOv7-tiny model; Step 5: Get the optimal weights of the YOLOv7-tiny model after training in step 4, load the weights into the model, and then implement citrus fruit detection on the test set data in step 3; Step 6: Obtain the network recognition counts in step 5, establish a regression model by combining the network recognition counts with manual counts, and analyze the differences in fruit counting accuracy; Step 7: Randomly select citrus trees in the orchard and obtain their complete side views. Use the regression model in step 6 to predict the citrus yield of the entire tree through network recognition and counting.

2. The citrus fruit yield estimation method based on improved YOLOv7-tiny according to claim 1, characterized in that: Manual annotation was performed by calibrating the location of the fruits in the dataset using Labelimg software.

3. The citrus fruit yield estimation method based on improved YOLOv7-tiny according to claim 1, characterized in that: In step 3, the training set, validation set, and test set are randomly divided into the data set in a ratio of 8:1:

1.

4. The citrus fruit yield estimation method based on improved YOLOv7-tiny according to claim 1, characterized in that: The YOLOv7-tiny model was obtained from GitHub, and the network was improved by model reconstruction and module replacement. Then, training was performed based on the improved model and the optimal weights were fixed.

5. The citrus fruit yield estimation method based on improved YOLOv7-tiny according to claim 1, characterized in that: A citrus yield estimation model was constructed by combining the improved network recognition counting and manual visual counting, and the yield estimation model was used to predict the fruit yield of fruit trees.

Citation Information

Patent Citations

  • Real-time identification method for green citrus fruits based on YOLO

    CN115205676A

  • Citrus fruit identification method and system based on improved YOLO v7

    CN116416613A

Cited By

  • Citrus detection method and system under complex background based on improved deep learning

    CN119942530A

  • Track state management and multi-source verification fused citrus yield statistical method

    CN122289935A