Unmanned aerial vehicle litchi image detection method based on improved YOLOv8n

By improving the YOLOv8n model, the RCS-OSA module and BiFPN network structure were introduced, and combined with the DynamicHead detection head, the problems of small and medium-sized targets for lychee fruit detection, high-density occlusion and low-resolution images were solved, and high-precision lychee fruit detection was achieved.

CN120472335APending Publication Date: 2025-08-12SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510361365.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

The existing lychee fruit detection methods are limited in the detection accuracy of small targets, high-density fruits, occlusion conditions and low-resolution images. Especially when the number of lychee fruit trees is large, the fruit distribution is dense and the occlusion is severe, it is difficult to achieve accurate fruit quantity estimation and yield prediction.

Method used

Using the improved YOLOv8n model, lightweight feature extraction is performed by introducing the RCS-OSA module, combining BiFPN network structure and DynamicHead detection head to enhance feature fusion capabilities, and using CIOU Loss and DFL Loss for model training to achieve accurate detection of lychee fruits.

Benefits of technology

It improves the detection accuracy and generalization ability of the model, can realize accurate detection of lychee fruits in natural environments, and improves detection accuracy and robust performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120472335A_ABST
    Figure CN120472335A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer vision, in particular to an improved YOLOv8n-based unmanned aerial vehicle litchi image detection method, which comprises the following steps of: acquiring a litchi image data set of a litchi orchard; a YOLOv8-litchi model based on the YOLOv8n model is constructed; training set data are input into the model for training, and detection and classification of the litchi fruits are completed; and inputting test set data into the model to realize accurate detection of the litchi fruits. According to the invention, an RCS-OSA module is introduced to improve a YOLOv8 network model, the feature extraction capability of a feature acquisition module is enhanced, the calculation complexity is reduced, effective information of the module is successfully fused by introducing a BiFPN network structure, the detection capability of a detection model is enhanced by using a DynamicHead detection head, and the detection efficiency is improved. And finally, the detection precision, the generalization ability and the robustness of the model are enhanced, so that relatively high accuracy is obtained in a natural environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a method for detecting lychee images from drones based on an improved YOLOv8n. Background Art

[0002] Lychee is a fruit widely grown in tropical regions of China and Southeast Asia, beloved for its delicious flavor and high economic value. However, the lychee production cycle is short, and fruit picking time is crucial. Traditional fruit detection and yield prediction methods have many shortcomings, especially when there are large numbers of lychee trees, densely distributed fruits, and severe obscuration. Accurately estimating the number of fruits per tree and predicting the yield of the entire orchard are enormous challenges.

[0003] In recent years, the field of object detection has made significant progress in small object detection. Through deep learning models, especially convolutional neural networks (CNNs) and improved object detection algorithms (such as the YOLO series, Faster R-CNN, RetinaNet, etc.), these complex visual detection tasks can be effectively handled.

[0004] However, when existing technologies are used in practice, although the target detection method based on deep learning has high accuracy and robustness, its detection performance is still limited when dealing with small targets, high-density fruits, occlusion and low-resolution images. Summary of the Invention

[0005] The purpose of the present invention is to provide a drone litchi image detection method based on improved YOLOv8n to solve the problem that the detection accuracy is still limited when dealing with small targets, high-density fruits, occlusion situations and low-resolution images.

[0006] To achieve the above objectives, the present invention provides the following technical solution: a drone litchi image detection method based on improved YOLOv8n, comprising the following steps:

[0007] S1. Data Collection: Collect litchi images from litchi orchards under different lighting conditions, background factors, leaf occlusion, and branch occlusion, and annotate the litchi fruits in the images to construct a litchi image dataset.

[0008] S2. Build a YOLOv8-litchi model: Build a YOLOv8-litchi model based on the YOLOv8n model. The YOLOv8-litchi model includes:

[0009] The RCS-OSA module is used to replace the C2f module in the original YOLOv8n model. The RCS-OSA module implements lightweight feature extraction through channel segmentation, Shuffle operation and RepVGG structure. The RCS-OSA module includes the RCS module and the OSA module.

[0010] The BiFPN network structure is introduced into the original YOLOv8n model to weightedly fuse multi-scale features to improve feature fusion capabilities and enable the model to more effectively utilize information at different scales.

[0011] Use DynamicHead dynamic detection head to improve the model's detection accuracy for small targets;

[0012] S3, model training: Divide the orchard litchi image dataset in step S1 into a training set, a validation set, and a test set, input the training set data into the YOLOv8-litchi model in step S2 for training, and use CIOU Loss and DFLLoss as loss functions to train the YOLOv8-litchi model to complete the detection and classification of litchi fruits;

[0013] S4. Complete detection: Input the test set data in step S3 into the trained YOLOv8-litchi model to achieve accurate detection of litchi fruits and output the detection results.

[0014] Preferably, the process of constructing the orchard litchi image dataset in step S1 includes:

[0015] Use drones to conduct aerial photography in multiple litchi orchards and collect multiple high-resolution images;

[0016] Use image annotation tools to accurately label the litchi fruits in each image;

[0017] Sliding window technique is used to segment the image to expand the dataset;

[0018] Apply online data augmentation techniques to enrich training data and improve the robustness and generalization ability of the model.

[0019] Preferably, in step S2:

[0020] The RCS module divides the channels of the input feature map into multiple groups through channel splitting and performs convolution operations on each group independently to reduce computational complexity. It then reorganizes the connections between channels through channel shuffle operations to ensure sufficient information exchange.

[0021] The OSA module enhances the model's feature expression capability at different spatial locations by introducing a spatial attention mechanism.

[0022] Preferably, the BiFPN network structure in step S2 includes a bidirectional feature fusion module and a dynamic weighted feature fusion module, which can capture and fuse feature information of different scales to improve the detection performance of the model.

[0023] Preferably, the DynamicHead in step S2 includes a position module, a shape module and a classification module, which are respectively used to learn the position information, shape characteristics and category distribution of the target, thereby generating high-quality detection results.

[0024] Compared with the prior art, the present invention has the following beneficial effects:

[0025] The present invention introduces the RCS-OSA module to improve the YOLOv8 network model, enhances the feature extraction capability of the feature acquisition module and reduces the computational complexity. By introducing the BiFPN network structure, the effective information of the module is successfully integrated. The DynamicHead detection head is used to enhance the detection capability of the inspection model, ultimately enhancing the detection accuracy, generalization ability and robust performance of the model. Finally, the trained litchi recognition model is used to detect litchi, which can achieve accurate detection of litchi under drones and obtain a high accuracy rate in natural environments. It can provide an effective detection method for litchi fruit detection under low-altitude drones. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 Schematic diagram of data acquisition equipment in an embodiment of the drone litchi image detection method based on improved YOLOv8n of the present invention;

[0027] Figure 2 Schematic diagram of a dataset of orchard litchi images in an embodiment of the drone litchi image detection method based on improved YOLOv8n of the present invention;

[0028] Figure 3 This is a schematic diagram of annotating an image using Labelimg and the annotation results in an embodiment of the drone litchi image detection method based on improved YOLOv8n of the present invention;

[0029] Figure 4 This is a schematic block diagram of the YOLOv8-litchi model for the drone litchi image detection method based on the improved YOLOv8n of the present invention;

[0030] Figure 5 This is a schematic block diagram of the RCS-OSA module structure of the drone litchi image detection method based on the improved YOLOv8n of the present invention;

[0031] Figure 6 This is a schematic block diagram of the structure of the DynamicHead detection head of the drone litchi image detection method based on the improved YOLOv8n of the present invention;

[0032] Figure 7 This is a schematic diagram of the BiFPN network structure of the drone litchi image detection method based on the improved YOLOv8n of the present invention;

[0033] Figure 8 This is a schematic diagram of the lychee image detection results of the drone lychee image detection method based on the improved YOLOv8n of the present invention. DETAILED DESCRIPTION

[0034] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0035] Many studies have used traditional image processing techniques to identify litchi fruit. For example, Xiong Juntao et al. proposed a litchi fruit detection method based on RGB to YCbCr image conversion. This method uses threshold segmentation to remove background and combines it with a fuzzy C-means clustering algorithm to identify the fruit and stem. While this method is somewhat effective for litchi detection, its accuracy decreases significantly in strong lighting or complex backgrounds, and it is also sensitive to occlusion of the fruit.

[0036] Another method is the double Otsu segmentation algorithm proposed by Peng Hongxing et al., which improves detection stability and efficiency by optimizing image segmentation quality. However, this method still fails to accurately identify lychee fruit when the fruit and background color are similar.

[0037] For nighttime lychee detection, Xiong Juntao et al. proposed a lychee recognition method based on the YIQ color space. This method uses Otsu segmentation to eliminate background, employs the FCM algorithm to segment the fruit and stem, and incorporates Hough circle fitting for fruit detection. While this method is capable of detecting fruit at night, it places high demands on image quality and is susceptible to image noise.

[0038] With the rapid development of deep learning technology, small object detection methods based on convolutional neural networks (CNNs) have gradually become the mainstream technology for litchi fruit detection. Liang et al. proposed a nighttime litchi fruit and stem detection model based on YOLOv3. This method first determines the region of interest based on detection results and then performs stem segmentation based on a U-Net. This method achieves high detection accuracy for litchi fruit under different brightness conditions, reaching up to 96.78%. However, this method is still affected by the density of fruit and the complexity of the background. Although it has good robustness, detection performance may decline in scenes with occlusion or uneven distribution of fruit.

[0039] Wang et al., addressing the dense distribution of fruit in large scenes, proposed a detection method based on YOLOv3. Through strategies such as multi-scale training and anchor box re-clustering, they significantly improved detection accuracy. Experimental results show that the model achieved an average accuracy of 87.43% in large scenes, with a single image detection time of 136.17ms. While this speed is significantly improved compared to traditional methods, it still falls short of real-time detection requirements.

[0040] Compared to traditional image processing methods, deep learning-based object detection methods have higher accuracy and robustness, and can effectively identify objects in complex environments. However, these methods still have some problems, especially when dealing with small objects, dense fruit, occlusion, and low-resolution images, where detection performance is still limited.

[0041] Challenges

[0042] Although deep learning technology has made some progress in litchi fruit detection, due to the particularity of litchi fruit, existing detection methods still face the following major challenges:

[0043] The fruit is densely packed and small in size, making it difficult to detect: Lychee fruits are small in size and densely distributed, which makes it difficult for the detection model to extract effective features and is easily interfered by neighboring fruits.

[0044] Fruit images are small in scale and low in resolution: Due to shooting angle and equipment limitations, fruit images are small in scale and low in resolution, which increases the difficulty of feature extraction and affects detection accuracy.

[0045] Fruit occlusion and overlap: Lychee fruits often occlude or overlap each other, especially when the fruits are densely packed. Traditional detection methods find it difficult to accurately distinguish the boundaries between fruits, resulting in false detection or missed detection.

[0046] Environmental factors: Lighting, weather, background clutter, and other environmental factors can affect detection results. This is especially true in outdoor environments with large lighting variations, where the robustness of the model is still under scrutiny.

[0047] See also Figure 1-8 The present invention provides a technical solution to solve the above shortcomings of the prior art: a drone litchi image detection method based on improved YOLOv8n, comprising the following steps:

[0048] S1. Data Collection: Collect lychee images from lychee orchards under different lighting conditions, background factors, leaf occlusion, and branch occlusion. Label the lychee fruits in the images to construct an orchard lychee image dataset. The construction process of the orchard lychee image dataset includes the following steps:

[0049] Use drones to conduct aerial photography in multiple litchi orchards and collect multiple high-resolution images;

[0050] Use image annotation tools to accurately label the litchi fruits in each image;

[0051] Sliding window technique is used to segment the image to expand the dataset;

[0052] Apply online data augmentation techniques to enrich training data and improve the robustness and generalization ability of the model;

[0053] S2. Build the YOLOv8-litchi model: Build a YOLOv8-litchi model based on the YOLOv8n model. The YOLOv8-litchi model includes:

[0054] The RCS-OSA module replaces the C2f module in the original YOLOv8n model. The full name of the RCS-OSA module is "Reparameterized Convolution with Channel Shuffle and One-Shot Aggregation". The RCS-OSA module implements lightweight feature extraction through channel segmentation, shuffle operation, and RepVGG structure. The RCS-OSA module includes the RCS module and the OSA module.

[0055] RCS combines channel shuffling and reparameterized convolution to enhance the network's feature extraction capabilities. During the training phase, the RCS module uses a multi-branch structure to learn rich feature representations. During the inference phase, it simplifies the model into a single branch through structured reparameterization to reduce memory consumption. The main purpose of the RCS module is to optimize convolution operations through channel segmentation and channel shuffle, reduce computational complexity, and improve feature representation capabilities.

[0056] Channel Split: In the RCS module, the channels of the input feature map are split into multiple smaller channel groups. Each group performs convolution operations independently, thereby reducing the amount of computation required for each convolution operation.

[0057] Channel Shuffle: After each convolution operation, the connections between channels are reorganized through shuffle. The shuffle operation ensures that information between each channel group can be fully exchanged, thus avoiding the problem of information loss between channels.

[0058] In addition, the RCS module adopts a heavily parameterized structure, using a multi-branch structure to learn deep feature information during the training phase, and reduces memory consumption and improves inference speed by simplifying it to a single-branch structure during the inference phase.

[0059] The OSA module enhances the model's ability to express features at different spatial locations by introducing a spatial attention mechanism;

[0060] The RCS-OSA module ensures feature reuse and strengthens information flow between different layers by stacking RCS.

[0061] The BiFPN network structure is introduced into the original YOLOv8n model, in which the BiFPN network structure introduces a bidirectional feature fusion module and a dynamic weighted feature fusion module;

[0062] The bidirectional feature fusion module fuses information both from high-level to low-level layers and from low-level to high-level layers, helping the model better capture information at different scales. The original YOLOv8n model used the traditional Feature Pyramid Network (FPN). The basic principle of FPN is to generate feature maps at multiple scales through top-to-bottom convolutional layers, then fuse these feature maps layer by layer to form a pyramid-shaped feature map. The introduction of the bidirectional feature fusion module allows for a more comprehensive integration of feature information at different scales, avoiding information loss associated with unidirectional fusion.

[0063] The dynamic weighted feature fusion module learns the weight coefficients for each level. These weight coefficients are learned dynamically during the training process, rather than simply concatenating or weighted averaging. This approach allows the model to more flexibly process features from different levels. In traditional feature pyramid networks, all input features are typically treated equally without distinction, meaning that features of different resolutions are simply added together without considering their different contributions to the output features. The dynamic weighted feature fusion module adds an additional weight to each input and allows the network to learn the importance of each input feature.

[0064]

[0065] Among them, ωi is a learnable weight, I i are different inputs. By introducing the BiFPN module, the network can better capture information of different scales;

[0066] The DynamicHead dynamic detection head is used. It consists of three modules: the position module πL, the shape module πS, and the classification module πC. Through a structural design with clear division of labor, it learns the target's position information, shape characteristics, and category distribution respectively to improve the model's detection accuracy for small targets.

[0067] S3, model training: Divide the orchard litchi image dataset in step S1 into a training set, a validation set, and a test set, input the training set data into the YOLOv8-litchi model in step S2 for training, and use CIOU Loss and DFLLoss as loss functions to train the YOLOv8-litchi model to complete the detection and classification of litchi fruits;

[0068] S4. Complete detection: Input the test set data in step S3 into the trained YOLOv8-litchi model to achieve accurate detection of litchi fruits and output the detection results.

[0069] The present invention also provides a specific embodiment of a drone litchi image detection method based on improved YOLOv8n, comprising the following steps:

[0070] S1. Data collection:

[0071] The image data used in this embodiment comes from the DJI Phantom 4 drone. Figure 1 As shown, the images were taken in a litchi orchard at the College of Horticulture, South China Agricultural University, and in a litchi orchard in Conghua District. The drone was kept between 5 and 10 meters from the trees, capturing raw images with a resolution of 3840 × 2160 pixels. The images contain litchi images under various lighting conditions, background factors, and occlusions from leaves and branches. Due to the large number of litchi objects in each image and their small size, a sliding window technique with a step size of 640 was used to resize each image to 1280 × 1280 pixels to reduce the data annotation workload and expand the dataset. The augmented dataset generated using this method was manually screened to remove low-quality data, resulting in 2068 high-quality litchi images.

[0072] This dataset uses the PASCAL VOC format and is randomly divided into training, validation, and test sets in a 7:2:1 ratio. All images were labeled with fruit objects using the LabelImg tool, with the number of lychee objects in each image ranging from 5 to 150. To avoid model overfitting, small portions of lychees that were heavily occluded and difficult to identify with the naked eye, or fruits with morphological differences significantly from normal lychees, were not labeled during the labeling process.

[0073] In addition to data augmentation through sliding windows, this dataset also uses a variety of online data augmentation techniques, including Random, Mosaic, and HSV transformations. Random augmentation is used to randomly rotate and stretch images, Mosaic augmentation generates new samples by randomly splicing four images, and HSV transformation increases image diversity by randomly adjusting the hue (H), saturation (S), and brightness (V) of the images, thereby further enriching the training data and enhancing the robustness of the model.

[0074] S2. Build the YOLOv8-litchi model:

[0075] In this example, model training was performed on the Ubuntu operating system using the PyTorch framework. The hardware configuration used was 10 vCPUs and a GeForce RTX 3090 GPU, paired with CUDA 11.6 and Python 3.9. The training environment remained consistent across all algorithms, and the main parameters used during training were set as follows:

[0076] Batch size: 16

[0077] Maximum number of iterations: 200

[0078] Early stopping condition: If the model performance does not improve significantly within 30 consecutive epochs, it will stop automatically

[0079] Image input size: 640×640 pixels

[0080] Initial learning rate: 0.01

[0081] Cyclic learning rate: 0.2

[0082] Momentum: 0.937

[0083] Weight decay coefficient: 0.0005

[0084] In addition, after applying non-maximum suppression (NMS) processing, if the classification confidence of all prediction boxes exceeds the 0.5 threshold, the prediction box is defined as a positive sample; conversely, the prediction box with a confidence lower than 0.5 is regarded as a negative sample, and a YOLOv8-litchi model based on the YOLOv8n model is constructed in the model training;

[0085] YOLOv8 is a new version of the YOLO (You Only Look Once) object detection model family. Compared to previous versions, YOLOv8 uses a single neural network to simultaneously predict both the bounding box and the category of an object in an image. The model's network architecture consists of three main components: the backbone network, the neck network, and the detection head. The backbone network extracts features from the input image, while the neck network and detection head process these features to ultimately detect and classify objects.

[0086] Backbone

[0087] The backbone network of YOLOv8 consists of 10 layers, of which the 1st, 2nd, 4th, 6th, and 8th layers are CBS modules, the 3rd, 5th, 7th, and 9th layers are C2f modules, and the 10th layer is the SPPF module.

[0088] CBS module: This module first performs convolution operations to extract image features. Next, it performs normalization through the BatchNormalization (BN) layer to improve network stability and generalization. Finally, it uses the SiLU activation function for nonlinear transformations, enhancing the network's expressive power.

[0089] The C2f module first performs a convolution operation on the input features, then uses the Split module to split the features into two parts. One part is fed into the Bottleneck module to obtain more gradient information, while the other part is concatenated with the outputs of multiple Bottleneck modules before undergoing a convolution operation. The design of the C2f module is inspired by the C3 module and the ELAN architecture, ensuring lightweight architecture while capturing richer gradient flow information.

[0090] SPPF module: This module first performs a convolution operation on the input feature map, then performs pooling of the features extracted by convolution at different scales to extract feature information at different scales. Next, it uses the Concat operation to fuse the feature information at different scales, and finally performs another convolution operation.

[0091] Neck

[0092] The neck network of YOLOv8 contains 12 layers, of which the 11th and 14th layers are upsampling modules, the 12th, 15th, 18th and 21st layers are Concat modules, the 13th, 16th, 19th and 22nd layers are C2f modules, and the 17th and 20th layers are CBS modules.

[0093] Upsampling operation: In this stage, the output feature map of the backbone network is upsampled, and the length and width of the feature map are expanded to twice the original ones.

[0094] Feature concatenation operation: The Concat module concatenates feature maps from different layers to fuse feature information at different scales.

[0095] C2f module convolution: The concatenated feature map is convolved through the C2f module to extract richer features.

[0096] CBS module convolution: Some layers use CBS modules to further process feature maps and reduce the size of feature maps (length and width are halved) to focus on more key information.

[0097] Detection head (Head)

[0098] The YOLOv8 detection head receives the outputs from layers 16, 19, and 22 and feeds them into the decoupling head structure for processing. The decoupling head structure consists of two branches, each containing two CBS modules and a convolutional module. One branch is responsible for predicting the bounding box of the object, while the other branch performs category prediction.

[0099] Loss Function

[0100] BCE Loss: used to calculate classification loss. Its formula is as follows:

[0101] Loss=-w*[p*log(q)+(1-p)*log(1-q)]

[0102] Where p and q are the theoretical label and the actual predicted value, respectively, and w is the weight. Here, log represents the natural logarithm (ln).

[0103] CIOU Loss: loss calculation for bounding box regression. The formula is as follows:

[0104] CIOU loss=1-CIOU

[0105]

[0106]

[0107] Among them, d o is the Euclidean distance between the center points of the target box and the predicted box, d cis the diagonal distance of the target box, w gt and h gt is the width and height of the real target box, w p and h p are the width and height of the prediction box.

[0108] DFL (Distribution Focal Loss): used to optimize bounding box regression. Its formula is as follows:

[0109]

[0110]

[0111] Among them, y is the theoretical label, y i and y i+1 is a value near y, p i and p i+1 is the predicted bounding box distribution probability;

[0112] In this embodiment, the YOLOv8-litchi model uses the RCS-OSA module, the improved BiFPN network structure, and the DynamicHead detection head in YOLOv8 to quickly identify litchi. The YOLOv8-litchi model includes:

[0113] The RCS-OSA module replaces the C2f module of the YOLOv8 neck network to aggregate features at different levels and improve the model's ability to extract semantic information, thereby enhancing the model's accuracy. The RCS-OSA module implements lightweight feature extraction through channel segmentation, shuffle operations, and RepVGG structure. The RCS-OSA module includes the RCS module and the OSA module. Figure 5 The following is the structure diagram of the RCS-OSA module, where:

[0114] The main purpose of the RCS module is to optimize the convolution operation through channel segmentation and channel shuffle, reduce computational complexity and improve feature representation capabilities, where:

[0115] Channel Split: In the RCS module, the channels of the input feature map are split into multiple smaller channel groups. Each group performs convolution operations independently, thereby reducing the amount of computation required for each convolution operation.

[0116] Channel shuffle: After each convolution operation, the connections between channels are reorganized through shuffle. The shuffle operation ensures that information between each channel group can be fully exchanged, thus avoiding the problem of information loss between channels.

[0117] In addition, the RCS module adopts a heavily parameterized structure, using a multi-branch structure to learn deep feature information during the training phase, and reduces memory consumption and improves inference speed by simplifying it to a single-branch structure during the inference phase.

[0118] The purpose of the OSA module is to enhance the model's ability to express features at different spatial locations. It introduces a spatial attention mechanism to optimize the model's response to different spatial regions, thereby improving the accuracy and robustness of object detection. Specifically, the OSA module can automatically learn which areas in the image are more important and dynamically adjust the model's attention to these areas.

[0119] The RCS-OSA module has a six-layer network structure. The first layer is a RepVGG module, the second and third layers are dual RCS modules, the fourth layer is a channel shuffle, and the fifth layer is concatenated using a concat operation before being fed into the sixth layer, the RepVGG module. The module first passes through the RepVGG module in the first layer, where a lightweight convolution operation using a reparameterized convolution (RepVGG) structure is performed on the input feature map to extract basic features. The number of channels is halved at the output and then fed into the dual RCS module in the second layer. This module performs channel splitting and shuffle operations on the input features to enhance feature representation while reducing computational complexity. The number of channels is then halved and fed into the third layer. The third layer functions similarly to the second layer, but the number of output channels remains the same, matching the number of channels in the second layer. The outputs of layers 1, 2, and 3 are then fed into the channel shuffle in the fourth layer to enhance information fusion between different feature maps. The concatenated feature maps are then fed into the fifth layer for concatenation, merging the channels into Channel / 2 + 2 × Channel / 4. Finally, the sixth layer RepVGG module performs convolution on the concatenated feature maps to extract higher-level features.

[0120] The BiFPN structure is introduced into the original YOLOv8n model and the network is redesigned to enhance the network's ability to fuse features, enabling the network to more effectively utilize information at different scales, thereby improving the performance of target detection. Figure 7 This is the structural diagram of BiFPN. The main advantage of the BiFPN structure is the introduction of a bidirectional feature fusion module and a dynamic weighted feature fusion module. The bidirectional feature fusion module fuses information from high-level to low-level and from low-level to high-level, which can help the model better capture information of different scales. The dynamic weighted feature fusion module obtains the weight coefficients of each level through learning. These weight coefficients are dynamically learned during the training process, rather than simply splicing or weighted averaging. This approach allows the model to process features from different levels more flexibly. By introducing the BiFPN module, the network can better capture information of different scales;

[0121] In addition, Figure 4 In the YOLOv8-litchi model shown, additional convolution is added to reduce dimensionality, and P2 layer information is introduced. The introduction of P2 layer information helps capture more fine-grained features. The higher-resolution feature map can provide more spatial information, which helps detect small objects.

[0122] Using DynamicHead dynamic detection head, Figure 6 This is the architecture of the DynamicHead detection head. The DynamicHead consists of three modules: the location module πL, the shape module πS, and the classification module πC. Through a clearly defined structural design, these modules learn the target's location information, shape characteristics, and category distribution. Ultimately, through feature fusion, it generates high-quality detection results, demonstrating strong dynamic adaptability and efficient computational performance. The target feature map received from the input layer provides input features for the three subsequent submodules.

[0123] First, the position module performs spatial pooling on the feature map through an average pooling layer. This module then passes through a 1×1 convolutional layer to extract the position information for each channel. This module then uses a ReLU activation function to introduce nonlinear features, and finally uses a hard sigmoid activation function to normalize the output. This module generates position information to guide the offset calculation in the shape module.

[0124] The second part is the shape module. This module first passes through the index layer, which uses the output of the position module to index specific feature regions. It then passes through a 3×3 convolutional layer to extract features locally while preserving contextual information. The third layer then passes the sigmoid activation function. The second output is then fed into the fourth offset layer to generate a shape offset. This module learns the shape variations of each object in the feature map and generates high-quality bounding box regression results.

[0125] The third part is the classification module. This module first passes through the average pooling layer and then enters the fully connected layer fc, extracts classification features through a multi-layer fully connected network, then passes through the ReLU activation function and enters the fully connected layer again, and finally passes through the normalization layer for weighted operation, adjusts the results according to the weights, and finally outputs the prediction results;

[0126] S3, model training: Divide the orchard litchi image dataset in step S1 into a training set, a validation set, and a test set, input the training set data into the YOLOv8-litchi model in step S2 for training, and use CIOU Loss and DFLLoss as loss functions to train the YOLOv8-litchi model to complete the detection and classification of litchi fruits;

[0127] S4. Complete the detection: Input the test set data in step S3 into the trained YOLOv8-litchi model to accurately detect litchi fruits and output the detection results. This example also evaluates the model performance, specifically:

[0128] Precision (P), recall (R), and mean average precision (mAP50) are selected as evaluation indicators of model performance. P and R measure the accuracy of the detection algorithm in positive samples and the recall ability in correct samples, respectively. mAP50 represents the average precision (AP) value when the intersection over union (IoU) threshold between the predicted box and the true box is set to 0.5 in the detection results of all categories. The higher the mAP50, the higher the detection accuracy of the model. Its value range is [0,1], where a lower value indicates a poorer detection effect. The calculation formula of the above evaluation indicators is as follows:

[0129]

[0130]

[0131]

[0132]

[0133] Among them, TP is the number of true positive samples, FP is the number of false positive samples, FN is the number of false negative samples, C is the number of categories, N is the number of reference thresholds, k is the threshold, P(k) is the precision, and R(k) is the recall.

[0134] By using the method described in this embodiment and the original YOLOvn model to test on the litchi image test set, the test results are shown in the following table:

[0135]

[0136] As shown in the table above, this example was tested on the litchi image test set, achieving a precision of 93.8%, a recall of 90.9%, and a map50 value of 95.7%, which are improvements of 2.2%, 2.1%, and 2.1%, respectively, compared to the original YOLOvn.

[0137] As shown in the table below, by adding the BiFPN network structure introduced in this embodiment to the YOLOv8n model, the mAP is improved by 0.3%, indicating that the introduction of the BiFPN network structure improves the network's ability to capture feature information and enables the model to more effectively utilize information at different scales. Replacing the C2f of the YOLOv8n model with the RCS-OSA module improves the mAP by 0.4% compared to the original YOLOv8n model, indicating that the RCS-OSA module can effectively reduce the complexity of the model. After replacing the detection head with DynamicHead, the mAP is improved by 0.5%. The combination of the BiFPN network structure, the RCS-OSA module, and the DynamicHead increases the mAP by 2.1%, thereby improving the model's performance for litchi image detection.

[0138]

[0139] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.

[0140] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A drone litchi image detection method based on improved YOLOv8n is characterized by: The following steps are involved: S1. Data Collection: Collect litchi images from litchi orchards under different lighting conditions, background factors, leaf occlusion, and branch occlusion, and annotate the litchi fruits in the images to construct a litchi image dataset. S2. Build a YOLOv8-litchi model: Build a YOLOv8-litchi model based on the YOLOv8n model. The YOLOv8-litchi model includes: The RCS-OSA module is used to replace the C2f module in the original YOLOv8n model. The RCS-OSA module implements lightweight feature extraction through channel segmentation, Shuffle operation and RepVGG structure. The RCS-OSA module includes the RCS module and the OSA module. The BiFPN network structure is introduced into the original YOLOv8n model to weightedly fuse multi-scale features to improve feature fusion capabilities and enable the model to more effectively utilize information at different scales. Use DynamicHead dynamic detection head to improve the model's detection accuracy for small targets; S3, model training: Divide the orchard litchi image dataset in step S1 into a training set, a validation set, and a test set, input the training set data into the YOLOv8-litchi model in step S2 for training, and use CIOU Loss and DFLLoss as loss functions to train the YOLOv8-litchi model to complete the detection and classification of litchi fruits; S4. Complete detection: Input the test set data in step S3 into the trained YOLOv8-litchi model to achieve accurate detection of litchi fruits and output the detection results.

2. The drone litchi image detection method based on improved YOLOv8n according to claim 1 is characterized in that: The process of constructing the orchard litchi image dataset in step S1 includes: Use drones to conduct aerial photography in multiple litchi orchards and collect multiple high-resolution images; Use image annotation tools to accurately label the litchi fruits in each image; Sliding window technique is used to segment the image to expand the dataset; Apply online data augmentation techniques to enrich training data and improve the robustness and generalization ability of the model.

3. The drone litchi image detection method based on improved YOLOv8n according to claim 2 is characterized in that: In the step S2: The RCS module divides the channels of the input feature map into multiple groups through channel splitting and performs convolution operations on each group independently to reduce computational complexity. It then reorganizes the connections between channels through channel shuffle operations to ensure sufficient information exchange. The OSA module enhances the model's feature expression capability at different spatial locations by introducing a spatial attention mechanism.

4. The drone litchi image detection method based on improved YOLOv8n according to claim 3 is characterized in that: The BiFPN network structure in step S2 includes a bidirectional feature fusion module and a dynamic weighted feature fusion module, which can capture and fuse feature information of different scales to improve the detection performance of the model.

5. The drone litchi image detection method based on improved YOLOv8n according to claim 4 is characterized in that: The DynamicHead dynamic detection head in step S2 includes a position module, a shape module and a classification module, which are respectively used to learn the position information, shape characteristics and category distribution of the target, thereby generating high-quality detection results.

Citation Information

Cited By

  • Smoke identification method and system suitable for comprehensive pipe gallery fire

    CN121259962A

  • Litchi fruit detection method and device based on improved YOLOv8n

    CN121982706A