Tea tree fresh leaf identification method and system based on YOLOv8
Through the YOLOv8-based tea tree fresh leaf recognition method, the Inner-SIoU loss function and improved network structure are used to solve the problem of low accuracy in tea tree fresh leaf recognition, and higher recognition accuracy and efficiency are achieved.
Patent Information
- Application Number
- CN202411888338.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-03-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
There are complexity and challenges in identifying fresh leaves of tea trees. The existing methods perform poorly in accuracy, especially because the characteristics of fresh leaves of tea trees in different varieties are not obvious, and the bud tips and spreading leaves are highly similar, making it difficult to accurately distinguish them.
The tea tree fresh leaf recognition method based on YOLOv8 is adopted, and a large number of historical images are obtained for data annotation and data expansion, a data set is constructed, and an identification model is created based on the YOLOv8 network, the loss function is set as the Inner-SIoU function, training and verification are performed, and the recognition model is finally deployed for tea tree fresh leaf recognition.
The recognition accuracy of tea tree fresh leaves is significantly improved. Through the improved YOLOv8 network structure and loss function, the model's ability and recognition efficiency of multi-scale spatial information processing are improved, and the probability of false detection and missed detection is reduced.
Smart Images

Figure CN119723291A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of tea detection, and in particular to a method and system for identifying fresh tea leaves based on YOLOv8. Background Art
[0002] With the continuous development of modern smart agriculture, machines are gradually replacing manual work. At present, tea picking mainly relies on manual picking. Accurate identification of fresh tea leaves (tea varieties) can provide important guarantees for subsequent intelligent picking decisions. At present, the identification of fresh tea leaves mainly relies on the experience and judgment of tea farmers, which requires high professional ability and practical experience, and has disadvantages such as strong subjectivity and time-consuming.
[0003] With the continuous development of science and technology, spectroscopy, molecular biology and other methods are widely used in research. Sun et al. used hyperspectral imaging technology to establish a variety identification model through spectral data to non-destructively identify green tea varieties. Although this method can quickly, non-destructively and accurately identify green tea varieties, it requires a special hyperspectral imaging system and takes a long time. Molecular biology methods use STS and CAPS markers of cytoplasmic genomes and expressed sequence tags (ESTs) combined with genetic diversity analysis to identify tea germplasm varieties. This method has the characteristics of high precision, stability, rapidity and reliability, but it has disadvantages such as high cost, complex technology and difficult sample processing.
[0004] With the rapid development of computer vision and deep learning technology, key technical support is provided for plant variety identification. These technologies can automatically extract, process and analyze plant features in images to achieve accurate identification of different plant varieties. Benassi A et al. proposed a method combining wavelet transform (WT) with deep learning model to identify the variety of Almond tree based on the classification of bark photos. The method obtained an accuracy of 96.46% using the original pictures. Miho H et al. used the OliVaR deep learning architecture to identify varieties through olive endocarp images. The experimental results showed that in the image data of 131 varieties, OliVaR achieved an accuracy of more than 86% to correctly predict the olive variety. Dong Z et al. used deep learning technology to identify the varieties of oil tea leaves based on the similarity of leaf morphology and other influencing factors. They proposed a new oil tea leaf feature extraction model focusing on the texture features of leaf images, and the variety recognition accuracy reached 93.7% and F1 was 0.945. To address the shortcomings of traditional methods of identifying tea varieties, which are time-consuming and inaccurate, Ding used five models (EfficientNet-B0, MobileNetV2, MobileNetV3, MobileViT-S and ShuffleNetV2) for transfer learning and proposed a method for identifying three tea varieties with similar leaves, with a test accuracy of over 95%.
[0005] Although the above method has achieved remarkable results in identifying and authenticating plant varieties, the identification of fresh tea leaves is more complex and challenging than that of other plants, because the characteristics (such as shape, color and size) of fresh leaves of different varieties of tea trees are not obviously different, and the buds and unfolded leaves are highly similar and difficult to distinguish. Even experienced tea farmers find it difficult to accurately distinguish and identify them. If the above method is directly applied to the identification of fresh tea leaves, the recognition accuracy will be unsatisfactory.
[0006] Therefore, how to provide a method and system for identifying fresh tea leaves based on YOLOv8 to improve the recognition accuracy of fresh tea leaves has become a technical problem that needs to be solved urgently. Summary of the invention
[0007] The technical problem to be solved by the present invention is to provide a method and system for identifying fresh tea leaves based on YOLOv8, so as to improve the recognition accuracy of fresh tea leaves.
[0008] In a first aspect, the present invention provides a method for identifying fresh tea leaves based on YOLOv8, comprising the following steps:
[0009] Step S1, obtaining a large number of historical images of fresh tea leaves, and constructing a data set after preprocessing each of the historical images including data annotation and data expansion;
[0010] Step S2, creating a tea tree fresh leaf recognition model based on the YOLOv8 network, and setting the loss function of the tea tree fresh leaf recognition model to the Inner-SIoU function;
[0011] Step S3, dividing the data set into a training set, a validation set and a test set based on a preset ratio, and respectively training, validating and testing the fresh tea leaf recognition model through the training set, the validation set and the test set;
[0012] Step S4: deploy the tea tree fresh leaf recognition model that has passed the test, and use the deployed tea tree fresh leaf recognition model to perform tea tree fresh leaf recognition.
[0013] Furthermore, the step S1 is specifically as follows:
[0014] Acquire a large number of historical images of fresh leaves of tea trees of different varieties, and annotate each of the historical images with at least the tea variety and tea category; the tea categories include single bud, one bud and one leaf, and one bud and two leaves;
[0015] The annotated historical images are subjected to data expansion including at least brightness adjustment, chromaticity adjustment, contrast adjustment, sharpness adjustment and image scaling to complete preprocessing of the historical images, and a data set is constructed based on the preprocessed historical images.
[0016] Further, in step S2, the YOLOv8 network consists of an input layer, a backbone network layer, a neck network layer and a detection head, and the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence;
[0017] The input layer is used to input tea leaves images;
[0018] The backbone network layer is based on an efficient pyramid backlog attention unit, and is used to extract spatial information from tea images through a multi-branch structure, process the spatial information at multiple scales in parallel, obtain a feature map containing a single type of kernel, use multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each of the spatial resolutions and depths, and output multi-scale features to the neck network layer through group convolution;
[0019] The neck network layer is composed of a dynamic upsampling unit and a space and channel reconstruction convolution unit; the dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; the space and channel reconstruction convolution unit is composed of a space reconstruction subunit and a channel reconstruction subunit; the space reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; the channel reconstruction subunit is used to segment, compress, convert and merge the channels of the spatial refinement features according to the strategies of splitting, converting and fusion to obtain channel refinement features;
[0020] The detection head is used to output the predicted probability of the tea variety and tea category of the fresh tea leaves according to the channel refinement characteristics.
[0021] Furthermore, in step S2, the formula of the Inner-SIoU function is:
[0022]
[0023] Among them, L Inner-SIoU Represents the loss value of the Inner-SIoU function; L SIoU represents the loss value of the SIoU loss function; IoU represents the matching degree between the predicted box and the real box of the fresh tea leaves; inter represents the intersection of the predicted box and the real box of the fresh tea leaves; union represents the union of the predicted box and the real box of the fresh tea leaves.
[0024] Furthermore, the step S3 is specifically as follows:
[0025] Dividing the data set into a training set, a validation set, and a test set based on a ratio of 8:1:1, and training the tea tree fresh leaf recognition model through the training set until the loss value of the loss function is less than a preset loss threshold;
[0026] The trained tea tree fresh leaf recognition model is verified by the verification set to determine whether the recognition accuracy of the tea tree fresh leaf recognition model is greater than a preset accuracy threshold. If not, the verification fails and the training set is expanded to continue training; if yes, the verification passes, and:
[0027] The accuracy, recall rate, average precision and mean average precision of the tea tree fresh leaf recognition model are calculated through the test set to test the tea tree fresh leaf recognition model. If the test fails, the training set is expanded to continue training; if the test passes, the training is terminated.
[0028] In a second aspect, the present invention provides a tea leaf recognition system based on YOLOv8, comprising the following modules:
[0029] A data set construction module is used to obtain a large number of historical images of fresh tea leaves, and to construct a data set after preprocessing each of the historical images including data annotation and data expansion;
[0030] A tea tree fresh leaf recognition model creation module is used to create a tea tree fresh leaf recognition model based on the YOLOv8 network, and set the loss function of the tea tree fresh leaf recognition model to be an Inner-SIoU function;
[0031] A tea tree fresh leaf recognition model training module, used to divide the data set into a training set, a validation set and a test set based on a preset ratio, and to train, validate and test the tea tree fresh leaf recognition model through the training set, the validation set and the test set respectively;
[0032] The tea tree fresh leaf recognition module is used to deploy the tea tree fresh leaf recognition model that has passed the test, and use the deployed tea tree fresh leaf recognition model to perform tea tree fresh leaf recognition.
[0033] Furthermore, the data set construction module is specifically used for:
[0034] Acquire a large number of historical images of fresh leaves of tea trees of different varieties, and annotate each of the historical images with at least the tea variety and tea category; the tea categories include single bud, one bud and one leaf, and one bud and two leaves;
[0035] The annotated historical images are subjected to data expansion including at least brightness adjustment, chromaticity adjustment, contrast adjustment, sharpness adjustment and image scaling to complete preprocessing of the historical images, and a data set is constructed based on the preprocessed historical images.
[0036] Furthermore, in the tea tree fresh leaf recognition model creation module, the YOLOv8 network is composed of an input layer, a backbone network layer, a neck network layer and a detection head, and the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence;
[0037] The input layer is used to input tea leaves images;
[0038] The backbone network layer is based on an efficient pyramid backlog attention unit, and is used to extract spatial information from tea images through a multi-branch structure, process the spatial information at multiple scales in parallel, obtain a feature map containing a single type of kernel, use multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each of the spatial resolutions and depths, and output multi-scale features to the neck network layer through group convolution;
[0039] The neck network layer is composed of a dynamic upsampling unit and a space and channel reconstruction convolution unit; the dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; the space and channel reconstruction convolution unit is composed of a space reconstruction subunit and a channel reconstruction subunit; the space reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; the channel reconstruction subunit is used to segment, compress, convert and merge the channels of the spatial refinement features according to the strategies of splitting, converting and fusion to obtain channel refinement features;
[0040] The detection head is used to output the predicted probability of the tea variety and tea category of the fresh tea leaves according to the channel refinement characteristics.
[0041] Furthermore, in the tea tree fresh leaf recognition model creation module, the formula of the Inner-SIoU function is:
[0042]
[0043] Among them, L Inner-SIoU Represents the loss value of the Inner-SIoU function; L SIoU represents the loss value of the SIoU loss function; IoU represents the matching degree between the predicted box and the real box of the fresh tea leaves; inter represents the intersection of the predicted box and the real box of the fresh tea leaves; union represents the union of the predicted box and the real box of the fresh tea leaves.
[0044] Furthermore, the tea tree fresh leaf recognition model training module is specifically used for:
[0045] Dividing the data set into a training set, a validation set, and a test set based on a ratio of 8:1:1, and training the tea tree fresh leaf recognition model through the training set until the loss value of the loss function is less than a preset loss threshold;
[0046] The trained tea tree fresh leaf recognition model is verified by the verification set to determine whether the recognition accuracy of the tea tree fresh leaf recognition model is greater than a preset accuracy threshold. If not, the verification fails and the training set is expanded to continue training; if yes, the verification passes, and:
[0047] The accuracy, recall rate, average precision and mean average precision of the tea tree fresh leaf recognition model are calculated through the test set to test the tea tree fresh leaf recognition model. If the test fails, the training set is expanded to continue training; if the test passes, the training is terminated.
[0048] The advantages of the present invention are:
[0049] By obtaining a large number of historical images of fresh tea leaves, each historical image is preprocessed including data annotation and data expansion to construct a data set; then a tea leaf recognition model is created based on the YOLOv8 network, and the loss function of the tea leaf recognition model is set to the Inner-SIoU function. The data set is divided into a training set, a validation set, and a test set based on a preset ratio. The tea leaf recognition model is trained, validated, and tested using the training set, validation set, and test set, respectively. Finally, the tea leaf recognition model that passes the test is deployed, and the tea leaf recognition model is used to recognize tea leaves; the YOLOv8 network consists of an input layer, a backbone network layer, a neck network layer, and a and a detection head, wherein the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence; the input layer is used to input tea images; the backbone network layer is based on an efficient pyramid backlog attention unit, which is used to extract spatial information from tea images through a multi-branch structure, and processes the spatial information at multiple scales in parallel to obtain a feature map containing a single type of kernel, and uses multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compresses the channel dimension of the feature map based on each spatial resolution and depth, and outputs multi-scale features to the neck network layer through group convolution; the neck network layer is based on a dynamic upsampling unit and spatial and channel reconstruction The invention is composed of a convolution unit; a dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; a spatial and channel reconstruction convolution unit is composed of a spatial reconstruction subunit and a channel reconstruction subunit; a spatial reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; a channel reconstruction subunit is used to segment, compress, convert and merge the channels of spatial refinement features according to the strategies of splitting, converting and fusion to obtain channel refinement features; a detection head is used to output the predicted probability of tea varieties and tea categories of fresh tea leaves according to the channel refinement features; that is, the traditional YOLOv8 network is improved. The backbone network layer of the YOLOv8 network incorporates an efficient pyramid backlog attention unit to improve the ability to process multi-scale spatial information; in the neck network layer of the YOLOv8 network, a dynamic upsampling unit is used to replace the traditional UpSample module, which effectively reduces the amount of data in the training process and reduces the complexity of model calculation, thereby improving the upsampling speed and efficiency; the spatial and channel reconstruction convolution unit is introduced in the neck network layer of the YOLOv8 network to further improve the model performance and reduce the redundant features of the model; and the loss function is optimized to the Inner-SIoU function to reduce network loss and accelerate regression convergence, which ultimately greatly improves the recognition accuracy of fresh tea leaves. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.
[0051] Figure 1 It is a flow chart of a method for identifying fresh tea leaves based on YOLOv8 of the present invention.
[0052] Figure 2 It is a structural schematic diagram of a tea tree fresh leaf recognition system based on YOLOv8 of the present invention.
[0053] Figure 3 It is a structural schematic diagram of the tea tree fresh leaf recognition model of the present invention.
[0054] Figure 4 It is a structural schematic diagram of the efficient pyramid backlog attention unit of the present invention.
[0055] Figure 5 It is a schematic diagram of the squeezed pyramid splicing of the efficient pyramid backlog attention unit of the present invention.
[0056] Figure 6 It is a structural schematic diagram of the dynamic upsampling unit of the present invention.
[0057] Figure 7 It is a structural schematic diagram of the space and channel reconstruction convolution unit of the present invention.
[0058] Figure 8 It is a schematic diagram of the Inner-SIoU function of the present invention. DETAILED DESCRIPTION
[0059] The technical solution in the embodiment of the present application has the following overall idea: improving the traditional YOLOv8 network, and performing fresh tea leaf recognition based on the tea leaf recognition model constructed based on the improved YOLOv8 network, integrating the efficient pyramid backlog attention unit into the backbone network layer of the YOLOv8 network to improve the ability to process multi-scale spatial information; in the neck network layer of the YOLOv8 network, using a dynamic upsampling unit to replace the traditional UpSample module, effectively reducing the amount of data in the training process, reducing the complexity of the model calculation, thereby improving the upsampling speed and efficiency; introducing a spatial and channel reconstruction convolution unit in the neck network layer of the YOLOv8 network to further improve the model performance and reduce the redundant features of the model; and optimizing the loss function to the Inner-SIoU function to reduce network loss and accelerate regression convergence to improve the recognition accuracy of fresh tea leaves.
[0060] Please refer to Figures 1 to 8 As shown, a preferred embodiment of a method for identifying fresh tea leaves based on YOLOv8 of the present invention comprises the following steps:
[0061] Step S1, obtaining a large number of historical images of fresh tea leaves, and constructing a data set after preprocessing each of the historical images including data annotation and data expansion;
[0062] Step S2, creating a tea tree fresh leaf recognition model based on the YOLOv8 network, and setting the loss function of the tea tree fresh leaf recognition model to the Inner-SIoU function;
[0063] Step S3, dividing the data set into a training set, a validation set and a test set based on a preset ratio, and respectively training, validating and testing the fresh tea leaf recognition model through the training set, the validation set and the test set;
[0064] Step S4: deploy the tea tree fresh leaf recognition model that has passed the test, and use the deployed tea tree fresh leaf recognition model to perform tea tree fresh leaf recognition.
[0065] The step S1 is specifically as follows:
[0066] A large number of historical images of fresh leaves of tea trees of different varieties are obtained, and each of the historical images is labeled with at least tea varieties and tea categories; the tea categories include single bud, one bud and one leaf, and one bud and two leaves; in specific implementation, a data set can be constructed based on the varieties of Changning large-leaf tea, Foxiang No. 3, Xianggui Yinhao, Yunkang No. 10, and Yunshan No. 1;
[0067] The annotated historical images are subjected to data expansion including at least brightness adjustment, chromaticity adjustment, contrast adjustment, sharpness adjustment and image scaling to complete preprocessing of the historical images, and a data set is constructed based on the preprocessed historical images.
[0068] In step S2, the YOLOv8 network consists of an input layer (Input), a backbone network layer (Backbone), a neck network layer (Neck) and a detection head (Head), and the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence;
[0069] YOLO (You Only Look Once) is an efficient single-stage target detection network. It is widely used because of its fast detection and significant effect. Its core idea is to transform the target detection problem into a regression problem, divide the image into grid areas, and predict the position and category of the grid bounding box. The backbone network layer of the YOLOv8 network draws on the ELAN design idea of the YOLOv7 network, and uses the C2f structure module to replace the C3 structure module in YOLOv5, which enhances the gradient flow and network receptive field, reduces the amount of calculation, and improves the performance of the network model; at the same time, the SPPF module is used to improve the model's detection ability for targets of different sizes. The neck network layer combines feature maps of different scales through feature fusion and upsampling to enhance the model's semantic expression and target positioning capabilities; the detection head uses a decoupled head structure to separate the target classification and detection tasks, improve the model's focus and detection efficiency, and at the same time, the design of the detection head is changed from anchor-based to anchor-free, simplifying the model complexity, reducing the network's dependence on the anchor size, and improving the model's generalization ability.
[0070] The input layer is used to input tea leaves images;
[0071] The backbone network layer is based on an Efficient Pyramid Squeeze Attention Network (EPSANet), which is used to extract spatial information from tea images through a multi-branch structure, process the spatial information at multiple scales in parallel, obtain a feature map containing a single type of kernel, use multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each of the spatial resolutions and depths, and output multi-scale features to the neck network layer through group convolution;
[0072] The neck network layer is based on a dynamic upsampling unit (DySample, Dynamic Upsampling) and a spatial and channel reconstruction convolution unit (SCConv, Spatial and Channel reconstruction Convolution); the dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; the spatial and channel reconstruction convolution unit is based on a spatial reconstruction subunit (SRU, spatial reconstruction unit) and a channel reconstruction subunit (CRU, channel reconstruction unit); the spatial reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; the channel reconstruction subunit is used to segment, compress, convert and merge the channels of the spatial refinement features according to the strategies of splitting, converting and merging to obtain channel refinement features;
[0073] The detection head is used to output the predicted probability of the tea variety and tea category of the fresh tea leaves according to the channel refinement characteristics.
[0074] The tea tree fresh leaf recognition model can effectively extract the features of tea leaves images during the training process, reduce the probability of false detection and missed detection, and thus improve the accuracy of recognizing fresh leaves of different varieties of tea trees under complex backgrounds.
[0075] With the continuous development of deep learning technology, convolutional neural networks (CNNs) have shown excellent results in the field of computer vision. However, traditional CNN models have problems in capturing global information and key areas of images, such as insufficient global information integration and low attention to important areas of images. In order to improve the performance and efficiency of the YOLOv8 network, this paper introduces an efficient pyramid backlog attention unit based on convolutional neural networks in the backbone network layer to learn richer multi-scale feature representations and improve the network's ability to process multi-scale spatial information.
[0076] The efficient pyramid backlog attention unit obtains multi-scale feature maps in the channel direction through the squeeze pyramid concat (SPC) method, extracts the attention of feature maps of different scales using the SEWeight module, generates channel attention vectors, and recalibrates the attention vectors of each channel using the Softmax function to obtain the recalibrated weights of the multi-scale channels. Finally, the recalibrated weights are element-wise multiplied with the corresponding feature maps to generate a refined feature map (multi-scale feature) with richer multi-scale feature information as output.
[0077] The key process to achieve multi-scale feature extraction is SPC, which extracts the spatial information of the input tea image through a multi-branch structure to obtain richer position information of the input tensor, and processes it in parallel at multiple scales to obtain a feature map containing a single type of kernel. At the same time, multi-scale convolution kernels are used in a pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each spatial resolution and depth, and output multi-scale features to the neck network layer through group convolution.
[0078] During the compression process, each feature map F of different scales i All have a common channel dimension C' = C / S and i = 0, 1, ..., S-1. However, as the size of the convolution kernel increases, the number of parameters will be significantly improved. In order to process input tensors of different kernel scales without increasing the computational cost, the group convolution method is introduced. The relationship between the multi-scale kernel size and the group size is shown in formula (1):
[0079]
[0080] Among them, K represents the convolution kernel size; Y represents the group convolution size.
[0081] The multi-scale feature map generation function is shown in formula (2):
[0082] F i =Conv(k i ×k i ,Y i )(X)i=0,1,2…S-1; (2)
[0083] Among them, k i represents the size of the i-th kernel, k i =2×(i+1)+1; Y i represents the size of the i-th group convolution; F i Represents feature maps of different scales, F i ∈R C'×H×W , R represents a real number, C' represents the number of channels; H represents the height of the image; W represents the width of the image; X represents the tea image.
[0084] Finally, the entire multi-scale preprocessed feature map (multi-scale feature) is obtained by cascading, as shown in formula (3):
[0085] F=Cat([F0,F1,…,F S-1 ]); (3)
[0086] Among them, F∈R C×H×W .
[0087] As an ultra-lightweight and efficient dynamic upsampler, the design concept of the dynamic upsampling unit breaks through the limitations of traditional dynamic convolution and returns to the essence of upsampling, that is, reconstructing the upsampling process from the perspective of point sampling. Compared with other dynamic upsamplers, such as CARAFE, FADE, and SAPA, the dynamic upsampling unit does not require high-resolution guided features as input, and significantly reduces memory usage, parameter volume, FLOPs, etc., that is, it retains the effectiveness of dynamic upsampling under simple, fast, and low-cost conditions. The dynamic upsampling process of the dynamic upsampling unit is exemplified as follows:
[0088] It is known that the size of the feature map X is C×H1×W1, and the size of the sampling set S is 2×H2×W2, where the first number 2 represents the coordinates of x and y. The network sample function (grid_sample) uses the positions in S to resample the assumed bilinear interpolation X to X' of size C×H2×W2, as shown in formula (4):
[0089] X'=grid_sample(X,S); (4)
[0090] At the same time, set an upsampling scale factor s and a feature map X of size C×H×W. Use an input and output channel number C and 2s respectively 2 A linear layer is used to generate 2s 2 The offset O of ×H×W is reshaped into 2×sH×sW by pixel shuffling. At this time, the sampling set S is the sum of the offset O and the original sampling grid G, as shown in equations (5) and (6):
[0091] O=linear(X); (5)
[0092] S=G+O; (6)
[0093] Due to the existence of the normalization layer, the value of the output feature is usually in the range of [-1, 1] centered on 0, resulting in local s 2 The walking scope of the sampling position may overlap, affecting the prediction accuracy near the boundary. In order to reduce the output artifacts during the step-by-step propagation of the error to the sampling, the offset O is reduced to 0.25 times of the original value to meet the theoretical marginal condition between overlap and non-overlap.
[0094] In order to reduce the redundant features of tea images extracted in large quantities by the convolution layer during training, alleviate the inherent redundancy of parameters in the model, and improve the efficiency of model training, the present invention introduces a lightweight and efficient convolution module, namely a spatial and channel reconstruction convolution unit; the spatial and channel reconstruction convolution unit is based on a spatial reconstruction subunit and a channel reconstruction subunit, and the spatial reconstruction subunit and the channel reconstruction subunit are sequentially connected.
[0095] The spatial reconstruction subunit separates the feature maps with rich information from those with less information in the space through separation and reconstruction operations, and evaluates the information content of different feature maps through the scaling factor in the group normalization (GN) layer. As shown in equations (7) to (10):
[0096]
[0097] W=Gate(Sigmoid(W γ (GN(X)))); (9)
[0098]
[0099] Input an intermediate feature map X∈R N×C×H×W , where N is the batch axis, C is the channel axis, H and W are the spatial height and width axes. First, X is normalized, where μ and σ are the mean and standard deviation in X, respectively, ε is a small positive constant added for stability, and γ and β are trainable affine transformation parameters. To indicate the importance of different feature maps, the normalized correlation weights W are calculated γ ∈R C , and then the weight value of the feature map is passed through W γ Re-weighted, mapped to the range of (0, 1) by the sigmoid function and gated by the threshold, the weights above the threshold are set to 1 to obtain the information weight W1, and set to 0 to obtain the information weight W2. Multiply the input feature with the obtained information weight to obtain the information-rich and small amount of information Two weighted features, the latter of which has little or no information, are considered redundant information. Finally, cross reconstruction is used to combine the weighted features of two different information amounts to enhance the communication of information flow.
[0100] In order to effectively utilize the channel redundancy of features, the channel reconstruction subunit adopts the Split-Transform-and-Fuse strategy to transform the spatial-refined features X w ∈R c×h×wThe channel of X is divided into two parts, αC and (1-α)C, where α is the segmentation ratio and the range is [0, 1]. Then, a 1×1 convolution is used to compress the channel of the feature map. w Divided into upper part X up and the lower part X low , as shown in equations (11) to (15):
[0101]
[0102]
[0103] Y=β1Y1+β2Y2; (15)
[0104] X up In the conversion stage from the input to the upper layer, efficient convolution operations group-wise convolution (GWC) and point-wise convolution (PWC) are used to extract high-level representative information and reduce computational costs to form an upper output feature map Y1. low The input to the lower layer conversion stage uses 1×1 PWC to generate a feature map with shallow hidden details and reuses X low The features are connected to form the lower output feature map Y2 of the low-level stage. After the conversion, the output features of the upper and lower stage conversions are adaptively merged through the simplified SKNet method, and global average pooling is applied to collect the channel statistics S m Finally, the upper feature Y1 and the lower feature Y2 are combined to obtain the channel refinement feature Y. G is the learnable weight matrix of GWC, is the learnable weight matrix of PWC, and β1 and β2 are the feature importance vectors generated using the channel-level soft attention mechanism.
[0105] In step S2, the formula of the Inner-SIoU function is:
[0106]
[0107] Among them, L Inner-SIoU Represents the loss value of the Inner-SIoU function; L SIoU represents the loss value of the SIoU loss function; IoU represents the matching degree between the predicted box and the real box of the fresh tea leaves; inter represents the intersection of the predicted box and the real box of the fresh tea leaves; union represents the union of the predicted box and the real box of the fresh tea leaves.
[0108] The traditional YOLOv8 network uses the CIoU function as the loss function in the prediction box regression. Although it can describe the regression state of the prediction box, it still lacks adaptive adjustment capabilities when facing different detection tasks, and its generalization ability is weak. Therefore, in order to accelerate the prediction box regression and improve the generalization ability, the Inner-SIoU function is introduced to replace the CIoU function.
[0109] In the prediction box regression (BBR), the IoU loss accurately describes the matching degree between the prediction box and the real box, ensuring that the model can effectively learn the location information of the target. As shown in formula (16):
[0110]
[0111] Among them, B and B gt Represent the predicted box and the true box respectively.
[0112] The SIoU loss function takes into account the angle between the predicted box and the true box in the prediction box regression, and the impact on the prediction box regression, so the angle loss Λ is introduced into the regression loss function. The angle loss Λ represents the minimum angle between the center point connection of the true box and the predicted box. When the angle is 45°, Λ=1, and when the center point is aligned on the X-axis or Y-axis, Λ=0. After considering the angle loss, the SIoU loss function and its distance loss Δ and shape loss Ω are shown in equations (17) to (19):
[0113]
[0114] The present invention combines the SIoU loss function with the prediction box to accelerate the loss calculation and prediction box regression process, thereby compensating for the shortcomings of weak generalization and low computational efficiency of the IoU loss. At the same time, the scale factor ratio is introduced into the Inner-IoU loss to control the scale of the prediction box. The process is shown in equations (20) to (25):
[0115]
[0116] union=(w gt *h gt )*(ration) 2 +(w*h)*(ration) 2 -inter; (25)
[0117] in, Indicates the center point of the Target Box and the Inner Target Box, (x c ,y c ) represents the center point of Anchor Box and Inner Anchor Box, w gt 、h gtRepresents the width and height of the Target Box, w and h represent the width and height of the Anchor Box, and ratio represents the scale factor, which ranges from [0.5, 1.5]. When ratio is less than 1 and the predicted box is smaller than the true box, although the effective range of regression is smaller than IoU, the absolute value of the gradient is greater than IoU, which accelerates the convergence of high IoU samples. When ratio is greater than 1, the predicted box expands the effective range of regression and enhances the regression effect of IoU samples.
[0118] The step S3 is specifically as follows:
[0119] Dividing the data set into a training set, a validation set, and a test set based on a ratio of 8:1:1, and training the tea tree fresh leaf recognition model through the training set until the loss value of the loss function is less than a preset loss threshold;
[0120] The trained tea tree fresh leaf recognition model is verified by the verification set to determine whether the recognition accuracy of the tea tree fresh leaf recognition model is greater than a preset accuracy threshold. If not, the verification fails and the training set is expanded to continue training. If yes, the verification passes, and:
[0121] The precision (Precision, P), recall (Recall, R), average precision (Average Precision, AP) and mean average precision (mean Average Precision, mAP) of the tea tree fresh leaf recognition model are calculated through the test set to test the tea tree fresh leaf recognition model. If the test fails, the training set is expanded to continue training; if the test passes, the training is terminated.
[0122]
[0123] Among them, T P Indicates the number of samples identified correctly; F P Indicates the number of samples that actually exist but are misidentified; F N Indicates the number of samples that were not detected.
[0124] A preferred embodiment of a tea tree fresh leaf recognition system based on YOLOv8 of the present invention includes the following modules:
[0125] A data set construction module is used to obtain a large number of historical images of fresh tea leaves, and to construct a data set after preprocessing each of the historical images including data annotation and data expansion;
[0126] A tea tree fresh leaf recognition model creation module is used to create a tea tree fresh leaf recognition model based on the YOLOv8 network, and set the loss function of the tea tree fresh leaf recognition model to be an Inner-SIoU function;
[0127] A tea tree fresh leaf recognition model training module, used to divide the data set into a training set, a validation set and a test set based on a preset ratio, and to train, validate and test the tea tree fresh leaf recognition model through the training set, the validation set and the test set respectively;
[0128] The tea tree fresh leaf recognition module is used to deploy the tea tree fresh leaf recognition model that has passed the test, and use the deployed tea tree fresh leaf recognition model to perform tea tree fresh leaf recognition.
[0129] The data set construction module is specifically used for:
[0130] A large number of historical images of fresh leaves of tea trees of different varieties are obtained, and each of the historical images is labeled with at least tea varieties and tea categories; the tea categories include single bud, one bud and one leaf, and one bud and two leaves; in specific implementation, a data set can be constructed based on the varieties of Changning large-leaf tea, Foxiang No. 3, Xianggui Yinhao, Yunkang No. 10, and Yunshan No. 1;
[0131] The annotated historical images are subjected to data expansion including at least brightness adjustment, chromaticity adjustment, contrast adjustment, sharpness adjustment and image scaling to complete preprocessing of the historical images, and a data set is constructed based on the preprocessed historical images.
[0132] In the tea tree fresh leaf recognition model creation module, the YOLOv8 network consists of an input layer (Input), a backbone network layer (Backbone), a neck network layer (Neck) and a detection head (Head), and the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence;
[0133] YOLO (You Only Look Once) is an efficient single-stage target detection network. It is widely used because of its fast detection and significant effect. Its core idea is to transform the target detection problem into a regression problem, divide the image into grid areas, and predict the position and category of the grid bounding box. The backbone network layer of the YOLOv8 network draws on the ELAN design idea of the YOLOv7 network, and uses the C2f structure module to replace the C3 structure module in YOLOv5, which enhances the gradient flow and network receptive field, reduces the amount of calculation, and improves the performance of the network model; at the same time, the SPPF module is used to improve the model's detection ability for targets of different sizes. The neck network layer combines feature maps of different scales through feature fusion and upsampling to enhance the model's semantic expression and target positioning capabilities; the detection head uses a decoupled head structure to separate the target classification and detection tasks, improve the model's focus and detection efficiency, and at the same time, the design of the detection head is changed from anchor-based to anchor-free, simplifying the model complexity, reducing the network's dependence on the anchor size, and improving the model's generalization ability.
[0134] The input layer is used to input tea leaves images;
[0135] The backbone network layer is based on an Efficient Pyramid Squeeze Attention Network (EPSANet), which is used to extract spatial information from tea images through a multi-branch structure, process the spatial information at multiple scales in parallel, obtain a feature map containing a single type of kernel, use multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each of the spatial resolutions and depths, and output multi-scale features to the neck network layer through group convolution;
[0136] The neck network layer is based on a dynamic upsampling unit (DySample, Dynamic Upsampling) and a spatial and channel reconstruction convolution unit (SCConv, Spatial and Channel reconstruction Convolution); the dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; the spatial and channel reconstruction convolution unit is based on a spatial reconstruction subunit (SRU, spatial reconstruction unit) and a channel reconstruction subunit (CRU, channel reconstruction unit); the spatial reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; the channel reconstruction subunit is used to segment, compress, convert and merge the channels of the spatial refinement features according to the strategies of splitting, converting and merging to obtain channel refinement features;
[0137] The detection head is used to output the predicted probability of the tea variety and tea category of the fresh tea leaves according to the channel refinement characteristics.
[0138] The tea tree fresh leaf recognition model can effectively extract the features of tea leaves images during the training process, reduce the probability of false detection and missed detection, and thus improve the accuracy of recognizing fresh leaves of different varieties of tea trees under complex backgrounds.
[0139] With the continuous development of deep learning technology, convolutional neural networks (CNNs) have shown excellent results in the field of computer vision. However, traditional CNN models have problems in capturing global information and key areas of images, such as insufficient global information integration and low attention to important areas of images. In order to improve the performance and efficiency of the YOLOv8 network, this paper introduces an efficient pyramid backlog attention unit based on convolutional neural networks in the backbone network layer to learn richer multi-scale feature representations and improve the network's ability to process multi-scale spatial information.
[0140] The efficient pyramid backlog attention unit obtains multi-scale feature maps in the channel direction through the squeeze pyramid concat (SPC) method, extracts the attention of feature maps of different scales using the SEWeight module, generates channel attention vectors, and recalibrates the attention vectors of each channel using the Softmax function to obtain the recalibrated weights of the multi-scale channels. Finally, the recalibrated weights are element-wise multiplied with the corresponding feature maps to generate a refined feature map (multi-scale feature) with richer multi-scale feature information as output.
[0141] The key process to achieve multi-scale feature extraction is SPC, which extracts the spatial information of the input tea image through a multi-branch structure to obtain richer position information of the input tensor, and processes it in parallel at multiple scales to obtain a feature map containing a single type of kernel. At the same time, multi-scale convolution kernels are used in a pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each spatial resolution and depth, and output multi-scale features to the neck network layer through group convolution.
[0142] During the compression process, each feature map F of different scales i All have a common channel dimension C' = C / S and i = 0, 1, ..., S-1. However, as the size of the convolution kernel increases, the number of parameters will be significantly improved. In order to process input tensors of different kernel scales without increasing the computational cost, the group convolution method is introduced. The relationship between the multi-scale kernel size and the group size is shown in formula (1):
[0143]
[0144] Among them, K represents the convolution kernel size; Y represents the group convolution size.
[0145] The multi-scale feature map generation function is shown in formula (2):
[0146] F i =Conv(k i ×k i ,Yi )(X)i=0,1,2…S-1; (2)
[0147] Among them, k i represents the size of the i-th kernel, k i =2×(i+1)+1; Y i represents the size of the i-th group convolution; F i Represents feature maps of different scales, F i ∈R C'×H×W , R represents a real number, C' represents the number of channels; H represents the height of the image; W represents the width of the image; X represents the tea image.
[0148] Finally, the entire multi-scale preprocessed feature map (multi-scale feature) is obtained by cascading, as shown in formula (3):
[0149] F=Cat([F0,F1,…,F S-1 ]); (3)
[0150] Among them, F∈R C×H×W .
[0151] As an ultra-lightweight and efficient dynamic upsampler, the design concept of the dynamic upsampling unit breaks through the limitations of traditional dynamic convolution and returns to the essence of upsampling, that is, reconstructing the upsampling process from the perspective of point sampling. Compared with other dynamic upsamplers, such as CARAFE, FADE, and SAPA, the dynamic upsampling unit does not require high-resolution guided features as input, and significantly reduces memory usage, parameter volume, FLOPs, etc., that is, it retains the effectiveness of dynamic upsampling under simple, fast, and low-cost conditions. The dynamic upsampling process of the dynamic upsampling unit is exemplified as follows:
[0152] It is known that the size of the feature map X is C×H1×W1, and the size of the sampling set S is 2×H2×W2, where the first number 2 represents the coordinates of x and y. The network sample function (grid_sample) uses the positions in S to resample the assumed bilinear interpolation X to X' of size C×H2×W2, as shown in formula (4):
[0153] X'=grid_sample(X,S); (4)
[0154] At the same time, set an upsampling scale factor s and a feature map X of size C×H×W. Use an input and output channel number C and 2s respectively 2 A linear layer is used to generate 2s 2The offset O of ×H×W is reshaped into 2×sH×sW by pixel shuffling. At this time, the sampling set S is the sum of the offset O and the original sampling grid G, as shown in equations (5) and (6):
[0155] O=linear(X); (5)
[0156] S=G+O; (6)
[0157] Due to the existence of the normalization layer, the value of the output feature is usually in the range of [-1, 1] centered on 0, resulting in local s 2 The walking scope of the sampling position may overlap, affecting the prediction accuracy near the boundary. In order to reduce the output artifacts during the step-by-step propagation of the error to the sampling, the offset O is reduced to 0.25 times of the original value to meet the theoretical marginal condition between overlap and non-overlap.
[0158] In order to reduce the redundant features of tea images extracted in large quantities by the convolution layer during training, alleviate the inherent redundancy of parameters in the model, and improve the efficiency of model training, the present invention introduces a lightweight and efficient convolution module, namely a spatial and channel reconstruction convolution unit; the spatial and channel reconstruction convolution unit is based on a spatial reconstruction subunit and a channel reconstruction subunit, and the spatial reconstruction subunit and the channel reconstruction subunit are sequentially connected.
[0159] The spatial reconstruction subunit separates the feature maps with rich information from those with less information in the space through separation and reconstruction operations, and evaluates the information content of different feature maps through the scaling factor in the group normalization (GN) layer. As shown in equations (7) to (10):
[0160]
[0161] W=Gate(Sigmoid(W γ (GN(X)))); (9)
[0162]
[0163] Input an intermediate feature map X∈R N×C×H×W , where N is the batch axis, C is the channel axis, H and W are the spatial height and width axes. First, X is normalized, where μ and σ are the mean and standard deviation in X, respectively, ε is a small positive constant added for stability, and γ and β are trainable affine transformation parameters. To indicate the importance of different feature maps, the normalized correlation weights W are calculated γ ∈R C , and then the weight value of the feature map is passed through W γRe-weighted, mapped to the range of (0, 1) by the sigmoid function and gated by the threshold, the weights above the threshold are set to 1 to obtain the information weight W1, and set to 0 to obtain the information weight W2. Multiply the input feature with the obtained information weight to obtain the information-rich and small amount of information Two weighted features, the latter of which has little or no information, are considered redundant information. Finally, cross reconstruction is used to combine the weighted features of two different information amounts to enhance the communication of information flow.
[0164] In order to effectively utilize the channel redundancy of features, the channel reconstruction subunit adopts the Split-Transform-and-Fuse strategy to transform the spatial-refined features X w ∈R c×h×w The channel of X is divided into two parts, αC and (1-α)C, where α is the segmentation ratio and the range is [0, 1]. Then, a 1×1 convolution is used to compress the channel of the feature map. w Divided into upper part X up and the lower part X low , as shown in equations (11) to (15):
[0165]
[0166] Y=β1Y1+β2Y2; (15)
[0167] X up In the conversion stage from the input to the upper layer, efficient convolution operations group-wise convolution (GWC) and point-wise convolution (PWC) are used to extract high-level representative information and reduce computational costs to form an upper output feature map Y1. low The input to the lower layer conversion stage uses 1×1 PWC to generate a feature map with shallow hidden details and reuses X low The features are connected to form the lower output feature map Y2 of the low-level stage. After the conversion, the output features of the upper and lower stage conversions are adaptively merged through the simplified SKNet method, and global average pooling is applied to collect the channel statistics S m Finally, the upper feature Y1 and the lower feature Y2 are combined to obtain the channel refinement feature Y. G is the learnable weight matrix of GWC, is the learnable weight matrix of PWC, and β1 and β2 are the feature importance vectors generated using the channel-level soft attention mechanism.
[0168] In the tea tree fresh leaf recognition model creation module, the formula of the Inner-SIoU function is:
[0169]
[0170] Among them, L Inner-SIoU Represents the loss value of the Inner-SIoU function; L SIoU represents the loss value of the SIoU loss function; IoU represents the matching degree between the predicted box and the real box of the fresh tea leaves; inter represents the intersection of the predicted box and the real box of the fresh tea leaves; union represents the union of the predicted box and the real box of the fresh tea leaves.
[0171] The traditional YOLOv8 network uses the CIoU function as the loss function in the prediction box regression. Although it can describe the regression state of the prediction box, it still lacks adaptive adjustment capabilities when facing different detection tasks, and its generalization ability is weak. Therefore, in order to accelerate the prediction box regression and improve the generalization ability, the Inner-SIoU function is introduced to replace the CIoU function.
[0172] In the prediction box regression (BBR), the IoU loss accurately describes the matching degree between the prediction box and the real box, ensuring that the model can effectively learn the location information of the target. As shown in formula (16):
[0173]
[0174] Among them, B and B gt Represent the predicted box and the true box respectively.
[0175] The SIoU loss function takes into account the angle between the predicted box and the true box in the prediction box regression, and the impact on the prediction box regression, so the angle loss Λ is introduced into the regression loss function. The angle loss Λ represents the minimum angle between the center point connection of the true box and the predicted box. When the angle is 45°, Λ=1, and when the center point is aligned on the X-axis or Y-axis, Λ=0. After considering the angle loss, the SIoU loss function and its distance loss Δ and shape loss Ω are shown in equations (17) to (19):
[0176]
[0177] The present invention combines the SIoU loss function with the prediction box to accelerate the loss calculation and prediction box regression process, thereby compensating for the shortcomings of weak generalization and low computational efficiency of the IoU loss. At the same time, the scale factor ratio is introduced into the Inner-IoU loss to control the scale of the prediction box. The process is shown in equations (20) to (25):
[0178]
[0179] union=(wgt *h gt )*(ration) 2 +(w*h)*(ration) 2 -inter; (25)
[0180] in, Indicates the center point of the Target Box and the Inner Target Box, (x c ,y c ) represents the center point of Anchor Box and Inner Anchor Box, w gt 、h gt Represents the width and height of the Target Box, w and h represent the width and height of the Anchor Box, and ratio represents the scale factor, which ranges from [0.5, 1.5]. When ratio is less than 1 and the predicted box is smaller than the true box, although the effective range of regression is smaller than IoU, the absolute value of the gradient is greater than IoU, which accelerates the convergence of high IoU samples. When ratio is greater than 1, the predicted box expands the effective range of regression and enhances the regression effect of IoU samples.
[0181] The tea tree fresh leaf recognition model training module is specifically used for:
[0182] Dividing the data set into a training set, a validation set, and a test set based on a ratio of 8:1:1, and training the tea tree fresh leaf recognition model through the training set until the loss value of the loss function is less than a preset loss threshold;
[0183] The trained tea tree fresh leaf recognition model is verified by the verification set to determine whether the recognition accuracy of the tea tree fresh leaf recognition model is greater than a preset accuracy threshold. If not, the verification fails and the training set is expanded to continue training. If yes, the verification passes, and:
[0184] The precision (Precision, P), recall (Recall, R), average precision (Average Precision, AP) and mean average precision (mean Average Precision, mAP) of the tea tree fresh leaf recognition model are calculated through the test set to test the tea tree fresh leaf recognition model. If the test fails, the training set is expanded to continue training; if the test passes, the training is terminated.
[0185]
[0186] Among them, T P Indicates the number of samples identified correctly; F P Indicates the number of samples that actually exist but are misidentified; FN Indicates the number of samples that were not detected.
[0187] In summary, the advantages of the present invention are:
[0188] By obtaining a large number of historical images of fresh tea leaves, each historical image is preprocessed including data annotation and data expansion to construct a data set; then a tea leaf recognition model is created based on the YOLOv8 network, and the loss function of the tea leaf recognition model is set to the Inner-SIoU function. The data set is divided into a training set, a validation set, and a test set based on a preset ratio. The tea leaf recognition model is trained, validated, and tested using the training set, validation set, and test set, respectively. Finally, the tea leaf recognition model that passes the test is deployed, and the tea leaf recognition model is used to recognize tea leaves; the YOLOv8 network consists of an input layer, a backbone network layer, a neck network layer, and a and a detection head, wherein the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence; the input layer is used to input tea images; the backbone network layer is based on an efficient pyramid backlog attention unit, which is used to extract spatial information from tea images through a multi-branch structure, and processes the spatial information at multiple scales in parallel to obtain a feature map containing a single type of kernel, and uses multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compresses the channel dimension of the feature map based on each spatial resolution and depth, and outputs multi-scale features to the neck network layer through group convolution; the neck network layer is based on a dynamic upsampling unit and spatial and channel reconstruction The invention is composed of a convolution unit; a dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; a spatial and channel reconstruction convolution unit is composed of a spatial reconstruction subunit and a channel reconstruction subunit; a spatial reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; a channel reconstruction subunit is used to segment, compress, convert and merge the channels of spatial refinement features according to the strategies of splitting, converting and fusion to obtain channel refinement features; a detection head is used to output the predicted probability of tea varieties and tea categories of fresh tea leaves according to the channel refinement features; that is, the traditional YOLOv8 network is improved. The backbone network layer of the YOLOv8 network incorporates an efficient pyramid backlog attention unit to improve the ability to process multi-scale spatial information; in the neck network layer of the YOLOv8 network, a dynamic upsampling unit is used to replace the traditional UpSample module, which effectively reduces the amount of data in the training process and reduces the complexity of model calculation, thereby improving the upsampling speed and efficiency; the spatial and channel reconstruction convolution unit is introduced in the neck network layer of the YOLOv8 network to further improve the model performance and reduce the redundant features of the model; and the loss function is optimized to the Inner-SIoU function to reduce network loss and accelerate regression convergence, which ultimately greatly improves the recognition accuracy of fresh tea leaves.
[0189] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.
Claims
1. A method for identifying fresh tea leaves based on YOLOv8, characterized in that: The steps include: Step S1, obtaining a large number of historical images of fresh tea leaves, and constructing a data set after preprocessing each of the historical images including data annotation and data expansion; Step S2, creating a tea tree fresh leaf recognition model based on the YOLOv8 network, and setting the loss function of the tea tree fresh leaf recognition model to the Inner-SIoU function; Step S3, dividing the data set into a training set, a validation set and a test set based on a preset ratio, and respectively training, validating and testing the tea tree fresh leaf recognition model through the training set, the validation set and the test set; Step S4: deploy the tea tree fresh leaf recognition model that has passed the test, and use the deployed tea tree fresh leaf recognition model to perform tea tree fresh leaf recognition.
2. A method for identifying fresh tea leaves based on YOLOv8 as claimed in claim 1, characterized in that: The step S1 is specifically as follows: Acquire a large number of historical images of fresh leaves of tea trees of different varieties, and annotate each of the historical images with at least the tea variety and tea category; the tea categories include single bud, one bud and one leaf, and one bud and two leaves; The annotated historical images are subjected to data expansion including at least brightness adjustment, chromaticity adjustment, contrast adjustment, sharpness adjustment and image scaling to complete preprocessing of the historical images, and a data set is constructed based on the preprocessed historical images.
3. The method for identifying fresh tea leaves based on YOLOv8 as claimed in claim 1, characterized in that: In step S2, the YOLOv8 network consists of an input layer, a backbone network layer, a neck network layer and a detection head, and the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence; The input layer is used to input tea leaves images; The backbone network layer is based on an efficient pyramid backlog attention unit, and is used to extract spatial information from tea images through a multi-branch structure, process the spatial information at multiple scales in parallel, obtain a feature map containing a single type of kernel, use multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each of the spatial resolutions and depths, and output multi-scale features to the neck network layer through group convolution; The neck network layer is composed of a dynamic upsampling unit and a space and channel reconstruction convolution unit; the dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; the space and channel reconstruction convolution unit is composed of a space reconstruction subunit and a channel reconstruction subunit; the space reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; the channel reconstruction subunit is used to segment, compress, convert and merge the channels of the spatial refinement features according to the strategies of splitting, converting and fusion to obtain channel refinement features; The detection head is used to output the predicted probability of the tea variety and tea category of the fresh tea leaves according to the channel refinement characteristics.
4. The method for identifying fresh tea leaves based on YOLOv8 as claimed in claim 1, characterized in that: In step S2, the formula of the Inner-SIoU function is: Among them, L Inner-SIoU Represents the loss value of the Inner-SIoU function; L SIoU represents the loss value of the SIoU loss function; IoU represents the matching degree between the predicted box and the real box of the fresh tea leaves; inter represents the intersection of the predicted box and the real box of the fresh tea leaves; union represents the union of the predicted box and the real box of the fresh tea leaves.
5. The method for identifying fresh tea leaves based on YOLOv8 as claimed in claim 1, characterized in that: The step S3 is specifically as follows: Dividing the data set into a training set, a validation set, and a test set based on a ratio of 8:1:1, and training the tea tree fresh leaf recognition model through the training set until the loss value of the loss function is less than a preset loss threshold; The trained tea tree fresh leaf recognition model is verified by the verification set to determine whether the recognition accuracy of the tea tree fresh leaf recognition model is greater than a preset accuracy threshold. If not, the verification fails and the training set is expanded to continue training. If yes, the verification passes, and: The accuracy, recall rate, average precision and mean average precision of the tea tree fresh leaf recognition model are calculated through the test set to test the tea tree fresh leaf recognition model. If the test fails, the training set is expanded to continue training; if the test passes, the training is terminated.
6. A tea leaf recognition system based on YOLOv8, characterized in that: Includes the following modules: A data set construction module is used to obtain a large number of historical images of fresh tea leaves, and to construct a data set after preprocessing each of the historical images including data annotation and data expansion; A tea tree fresh leaf recognition model creation module is used to create a tea tree fresh leaf recognition model based on the YOLOv8 network, and set the loss function of the tea tree fresh leaf recognition model to be an Inner-SIoU function; A tea tree fresh leaf recognition model training module, used to divide the data set into a training set, a validation set and a test set based on a preset ratio, and to train, validate and test the tea tree fresh leaf recognition model through the training set, the validation set and the test set respectively; The tea tree fresh leaf recognition module is used to deploy the tea tree fresh leaf recognition model that has passed the test, and use the deployed tea tree fresh leaf recognition model to perform tea tree fresh leaf recognition.
7. A tea leaf recognition system based on YOLOv8 as claimed in claim 6, characterized in that: The data set construction module is specifically used for: Acquire a large number of historical images of fresh leaves of tea trees of different varieties, and annotate each of the historical images with at least the tea variety and tea category; the tea categories include single bud, one bud and one leaf, and one bud and two leaves; The annotated historical images are subjected to data expansion including at least brightness adjustment, chromaticity adjustment, contrast adjustment, sharpness adjustment and image scaling to complete preprocessing of the historical images, and a data set is constructed based on the preprocessed historical images.
8. The tea leaf recognition system based on YOLOv8 as claimed in claim 6, characterized in that: In the tea tree fresh leaf recognition model creation module, the YOLOv8 network consists of an input layer, a backbone network layer, a neck network layer and a detection head, and the input layer, the backbone network layer, the neck network layer and the detection head are connected in sequence; The input layer is used to input tea leaves images; The backbone network layer is based on an efficient pyramid backlog attention unit, and is used to extract spatial information from tea images through a multi-branch structure, process the spatial information at multiple scales in parallel, obtain a feature map containing a single type of kernel, use multi-scale convolution kernels in the pyramid structure to generate different spatial resolutions and depths, compress the channel dimension of the feature map based on each of the spatial resolutions and depths, and output multi-scale features to the neck network layer through group convolution; The neck network layer is composed of a dynamic upsampling unit and a space and channel reconstruction convolution unit; the dynamic upsampling unit is used to upsample multi-scale features to obtain an upsampled feature map; the space and channel reconstruction convolution unit is composed of a space reconstruction subunit and a channel reconstruction subunit; the space reconstruction subunit is used to separate and reconstruct the upsampled feature map according to the richness of spatial information to obtain spatial refinement features; the channel reconstruction subunit is used to segment, compress, convert and merge the channels of the spatial refinement features according to the strategies of splitting, converting and fusion to obtain channel refinement features; The detection head is used to output the predicted probability of the tea variety and tea category of the fresh tea leaves according to the channel refinement characteristics.
9. The tea leaf recognition system based on YOLOv8 as claimed in claim 6, characterized in that: In the tea tree fresh leaf recognition model creation module, the formula of the Inner-SIoU function is: Among them, L Inner-SIoU Represents the loss value of the Inner-SIoU function; L SIoU represents the loss value of the SIoU loss function; IoU represents the matching degree between the predicted box and the real box of the fresh tea leaves; inter represents the intersection of the predicted box and the real box of the fresh tea leaves; union represents the union of the predicted box and the real box of the fresh tea leaves.
10. The tea leaf recognition system based on YOLOv8 as claimed in claim 6, characterized in that: The tea tree fresh leaf recognition model training module is specifically used for: Dividing the data set into a training set, a validation set, and a test set based on a ratio of 8:1:1, and training the tea tree fresh leaf recognition model through the training set until the loss value of the loss function is less than a preset loss threshold; The trained tea tree fresh leaf recognition model is verified by the verification set to determine whether the recognition accuracy of the tea tree fresh leaf recognition model is greater than a preset accuracy threshold. If not, the verification fails and the training set is expanded to continue training. If yes, the verification passes, and: The accuracy, recall rate, average precision and mean average precision of the tea tree fresh leaf recognition model are calculated through the test set to test the tea tree fresh leaf recognition model. If the test fails, the training set is expanded to continue training; if the test passes, the training is terminated.
Citation Information
Patent Citations
Tea disease identification method based on improved YOLOv7
CN118537642A
Tea leaf picking time prediction method based on improved YOLOv8n network
CN118658042A
Cited By
Method for identifying warning line crossing behavior of miner
CN120564270A
Method for identifying miners crossing the warning line
CN120564270B
Plant growth vigor identification method and system
CN121190990A
Multi-source data fusion-based tea leaf fine manipulation degree identification method and system
CN121582666A
A tea leaf making green degree recognition method and system based on multi-source data fusion
CN121582666B