A dragon fruit counting method based on YOLOv8
By improving the backbone and neck networks of the YOLOv8 model and combining the ByteTracker tracker and counter, the problems of slow inference speed and large number of parameters in dragon fruit counting of the YOLOv8 model were solved, and efficient and accurate dragon fruit counting was achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2026-03-13
Smart Images

Figure CN119274054B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of fruit counting, specifically relating to a dragon fruit counting method based on YOLOv8. Background Technology
[0002] In agricultural production, fruit counting has always been a laborious and time-consuming task, especially for fruits like dragon fruit grown in orchards with large sprawling areas. By constructing a lightweight, efficient, and accurate fruit counting model and mounting it on mobile devices, fruit farmers can reduce their workload, improve counting efficiency, and save labor costs (Rahnemoonfar M, Sheppard C. Deep count: Fruit counting based on deep simulated learning[J]. Sensors, 2017, 17(4).). The literature (Li P, Zheng J, Li P, et al. Tomato maturity detection and counting model based on MHSA-YOLOv8[J]. Sensors, 2023, 23(15).) proposes a fruit counting model based on YOLOv8, which adopts a YOLOv8 detection model with added MHSA attention mechanism. The addition of MHSA attention mechanism can improve the detection accuracy, but at the same time, it will reduce the inference speed of the model. Therefore, when using a YOLOv8-based model for fruit counting, an efficient attention mechanism is needed, namely, an attention mechanism that increases the model's focus on effective information without reducing the model's inference speed (Hou Q, Zhou D, Feng J. Coordinate attention for efficient mobile network design[C] / / Proceedings of the 2021 IEEE / CVF Conference on Computer Vision and Pattern Recognition.2021:13708-13717.). Furthermore, the backbone network of the fruit counting model in the literature (Li P, Zheng J, Li P, et al. Tomato maturity detection and counting model based on MHSA-YOLOv8[J]. Sensors,2023,23(15.)) consists of convolutional modules with a large number of parameters, making it difficult to mount on mobile devices. Therefore, researching how to improve the YOLOv8 model to enhance its inference speed, reduce its parameter count, and achieve efficient dragon fruit counting has significant theoretical and practical value. Summary of the Invention
[0003] The main objective of this invention is to overcome the shortcomings and deficiencies of the prior art and provide a dragon fruit counting method based on YOLOv8, which reduces the workload of fruit farmers, improves the efficiency of dragon fruit counting, and saves labor costs.
[0004] To achieve the above objectives, the present invention adopts the following technical solution:
[0005] The dragon fruit counting method based on YOLOv8 provided by this invention includes the following steps:
[0006] S1. Dragon fruit detection image dataset is created by acquiring dragon fruit images, scaling dragon fruit images, annotating dragon fruit images, and dividing dragon fruit images and annotation files.
[0007] S2. Use video recording equipment to capture videos of dragon fruit;
[0008] S3. Construct a dragon fruit counting model, including an improved detector, a tracker, and a counter; the improved detector is constructed based on the existing YOLOv8 model and is used to detect dragon fruit; the tracker is the existing ByteTracker tracker and is used to track dragon fruit; the counter is a renamed existing counter and is used to output a dictionary of dragon fruit counting results.
[0009] S4. Train and test the improved detector in the dragon fruit counting model using the dragon fruit detection image dataset;
[0010] S5. Use the dragon fruit counting model to count the dragon fruit in the collected dragon fruit videos.
[0011] As a preferred technical solution, the steps for creating the dragon fruit detection image dataset are as follows:
[0012] S101. Dragon Fruit Image Acquisition: Determine the number of dragon fruit categories and their names according to requirements; use image acquisition equipment to acquire images of dragon fruit in the natural environment of the orchard and save them to a folder;
[0013] S102, Dragon Fruit Image Scaling: Scaling the dragon fruit images in the folder to 3*W*H pixels, where W is the width of the scaled image and H is the height of the scaled image.
[0014] S103. Dragon fruit image annotation: Select the scaled dragon fruit images in the folder, annotate them with the actual fruit category name, and save the annotation file;
[0015] S104. Dragon fruit image and annotation file division: The processed dragon fruit images and their corresponding annotation files are randomly divided into training set, test set and validation set according to the proportion to obtain dragon fruit detection image dataset.
[0016] As a preferred technical solution, the construction of the dragon fruit counting model specifically includes:
[0017] S301. Constructing an improved detector: Based on the existing YOLOv8 model, an original detector is constructed, which includes a backbone network, a neck network, and a head network. The original detector is improved by lightweighting the backbone network and adding an attention mechanism to the neck network, resulting in an improved detector for the dragon fruit counting model.
[0018] S302, Call and initialize the ByteTracker tracker: Call the existing ByteTracker tracker and initialize it, then use the tracker to calculate the output of the improved detector;
[0019] S303, Rename the existing counter to Counter and call it.
[0020] As a preferred technical solution, the lightweighting of the backbone network refers to replacing the original detector backbone network by combining the CBRM block and Shuffle_Block block in the existing ShuffleNetv2 network.
[0021] As a preferred technical solution, the addition of the attention mechanism to the neck network involves adding a CA attention mechanism after the Bottleneck block within each C2f block of the neck network pointing to the original detector.
[0022] As a preferred technical solution, the improved detector in the dragon fruit counting model is specifically trained and tested as follows:
[0023] S401, Improved detector in training the dragon fruit counting model:
[0024] The training set images and validation set images are converted into training set image tensors and validation set image tensors, respectively. The training set annotation files and validation set annotation files are converted into training set true label tensor lists and validation set true label tensor lists, respectively. The training set image tensors and validation set image tensors are then normalized to obtain normalized training set image tensors and normalized validation set image tensors.
[0025] Set the training batch size, momentum, learning rate, and number of training iterations. Use the obtained normalized training set image tensor, normalized validation set image tensor, training set ground truth label tensor list, and validation set ground truth label tensor list for training. After training, automatically save the optimal model parameter tensor to the parameter file.
[0026] S402, Testing an improved detector in a dragon fruit counting model:
[0027] The test set images are converted into test set image tensors, the test set annotation files are converted into a list of test set true label tensors, and the test set image tensors are normalized to obtain normalized test set image tensors.
[0028] Load the current optimal model parameter tensor from the saved parameter file into the improved detector in the constructed dragon fruit counting model;
[0029] The normalized test set image tensor is used as input to the improved detector in the dragon fruit counting model loaded with the current optimal model parameter tensor to obtain a list of predicted label tensors for the test set images.
[0030] Accuracy, mean precision, recall, inference speed, and number of model parameters were used as evaluation metrics. The performance of the improved detector in the dragon fruit counting model was evaluated using a list of real label tensors and a list of predicted label tensors for the obtained dragon fruit images.
[0031] As a preferred technical solution, the counting of dragon fruit fruits in the collected dragon fruit video specifically involves:
[0032] S501. Convert the video to be counted into a tensor, and load the tensor and the current optimal model parameter tensor in the saved parameter file into the constructed dragon fruit counting model.
[0033] S502. Obtain the final counting result dictionary through the dragon fruit counting model.
[0034] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0035] The dragon fruit counting model constructed in this invention includes an improved detector, a tracker, and a counter, enabling the detection and counting of dragon fruits. On one hand, because the improved detector uses a backbone network combining CBRM blocks and Shuffle_Block blocks, it has fewer model parameters and faster detection speed compared to the original detector. On the other hand, because a CA attention mechanism is added after the Bottleneck block within each C2f block in the neck network of the improved detector, it can not only acquire information between channels but also consider orientation-related positional information, which helps to better locate and identify dragon fruit fruits. Attached Figure Description
[0036] Figure 1 This is an overall flowchart of a dragon fruit counting method based on YOLOv8.
[0037] Figure 2 This is a schematic diagram of the CountMD counting model.
[0038] Figure 3 For Detector Impr A schematic diagram of the improved detector.
[0039] Figure 4 This is a schematic diagram of the structure of C2f-CA.
[0040] Figure 5 This is a diagram showing the effect of counting dragon fruit. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below.
[0042] Example 1
[0043] like Figure 1 As shown, a dragon fruit counting method based on YOLOv8 includes the following steps:
[0044] S1. Create a dataset of dragon fruit detection images.
[0045] S2. Use video recording equipment to capture videos of dragon fruit.
[0046] S3. Construct the CountMD counting model.
[0047] S4. Train and test the Detector in the CountMD counting model. Impr Improve the detector.
[0048] S5. Apply the CountMD counting model.
[0049] Furthermore, in step S1, a dragon fruit detection image dataset is created, and the steps are as follows:
[0050] S101. Dragon Fruit Image Acquisition: In this embodiment, the number of fruit categories is determined to be nmCPt = 3, and the fruit category name is neCPt = {unripe fruit, pigmented fruit, ripe fruit}, i.e., immature fruit, colored fruit, and ripe fruit; 1694 JPG images of dragon fruit with a resolution of 3904*2928 are taken in the natural environment of the orchard using a smartphone. Next, rename the filename of the image in OIm to [filename]. NOIm j For image OIm jThe filenames are excluding the extension; then, a pitaya folder is created, and a pitaya-ori folder is created inside it. The 1694 dragon fruit images OIm are stored in the pitaya-ori folder.
[0051] S102. Dragon Fruit Image Scaling: In this embodiment, a pitaya-zoom folder is created within the pitaya folder. The Torchvision library in Python is used to scale the 1694 images (OIm) in the pitaya-ori folder, reducing their size to 3*640*640 pixels. Then, the scaled 1694 images are... Save it to the pitaya-zoom folder, where the filename of the image SIm has the non-extension part as NOIm.
[0052] S103, Dragon Fruit Image Annotation: In this embodiment, the specific steps for dragon fruit image annotation are as follows: (1) Create a labelstxt folder in the pitaya folder. (2) Open the labelImg tool and use it to open the pitaya-zoom folder, and label each of the 1694 scaled images SIm in the folder. ①k∈{1,…,nTBSI j}: Drag the mouse to outline the dragon fruit k with a rectangle, and enter the fruit category name of dragon fruit k in labelImg, where nTBSI j For image SIm j The number of dragon fruit fruits in the array is given. Then, labelImg will automatically calculate the category index (tix) of dragon fruit fruit k. j [k], the center coordinates of the rectangle ((tx0)). j [k],(ty0) j [k]), rectangle width (tw) j [k] and the height of the rectangle (th) j [k], where (tix) j [k]∈{0,…,2}. ②The image SIm j After performing the operation ① above, a file named NOIm will be automatically created by labelImg. j And the annotation file with the extension .txt (LTx) j Save it to the labelstxt folder. (3) Close the labelImg tool. Annotation files for all 1694 images (SIm).
[0053] S104. Dragon Fruit Image and Label File Division: In this embodiment, the specific steps for dividing the dragon fruit image and label file are as follows: First, create a folder named pitaya1, and within pitaya1, create three folders: train, test, and validation. These folders are used to store the training set images and label files, the test set images and label files, and the validation set images and label files, respectively. Second, within the train, test, and validation folders, create an images folder to store JPG format files and a labels folder to store TXT format files. Let the division ratio of image SIm and label file LTx both be P. tr :P te :P va = 7:2:1. Next, using the random library in Python, the 1694 images SIm in the pitaya-zoom folder in step S102 are divided into training set images TrI = {TrI1,…,TrI...} 1185 The test set images TeI = {TeI1, ...,TeI} 340} and the validation set images VaI={VaI1,…,VaI 169}, where 1185=|TrI|, 340=|TeI| and 169=|VaI| are the number of images in the training set, test set, and validation set, respectively. Then, Sim=TrI∪TeI∪VaI, 1694=1185+340+169, where [1185,340,169]=[7,2,1]*(1694 / (7+2+1)). Move the training set images TrI to the images folder under the train folder, move the test set images TeI to the images folder under the test folder, and move the validation set images VaI to the images folder under the val folder. Divide the labeling file LTx in the labelstxt folder into training set labeling files LrT={LrT1,…,LrT 1185 The test set annotation file is LeT = {LeT1, ..., LeT}. 340} and the validation set annotation file LaT = {LaT1, ..., LaT 169Let 1185 = |LrT|, 340 = |LeT|, and 169 = |LaT| be the number of labeled files in the training, test, and validation sets, respectively. Then, LTx = LrT∪LeT∪LaT. Move the training set labeled files LrT to the labels folder under the train folder, the test set labeled files LeT to the labels folder under the test folder, and the validation set labeled files LaT to the labels folder under the val folder. Let TrD = {(TrI1,LrT1),…,(TrI... 1185 ,LrT 1185 Let TeD = {(TeI1,LeT1),…,(TeI}} be the training set. 340 LeT 340 )} is the test set, VaD={(VaI1,LaT1),…,(VaI 169 ,LaT 169 Let )} be the validation set. Therefore, the dragon fruit detection image dataset is: PtD=TrD∪TeD∪VaD.
[0054] In step S2 of this application, the video shooting device is not limited to traditional camcorders, cameras, and other shooting devices; any device with video shooting and recording functions is included. The format of the captured video is not limited to mp4, 3gp, and mov formats. In this embodiment, a smartphone is used to capture videos of dragon fruit in a natural environment in the orchard, obtaining a total of nmPV = 1 segment of mp4 format dragon fruit video PV = {PV 1},in This is the first video segment. t is the t-th frame in the first video segment, and 256 is the frame number of the first video segment.
[0055] Furthermore, the specific steps for S3 to construct the CountMD counting model are as follows: Construct Detector Impr The detector is improved by calling and initializing the ByteTracker tracker, and renaming the existing counter to Counter and calling it. The constructed CountMD counting model can be represented as CountR = CountMD(TInput,ω CtM ), where CountMD is the model name, TInput is the input tensor of the CountMD model, and ω CtM Here is the tensor of model parameters to be trained, and CountR is the dictionary of the model's counting results.
[0056] S301, Construct Detector ImprImproved Detector: In this embodiment, the original detector (Detector) is constructed based on the YOLOv8 model developed by the Ultralytics team (https: / / github.com / ultralytics / ultralytics). yolov8 , among which Detector yolov8 Includes the backbone network. yolov8 Neck network yolov8 and Head Network yolov8 Then by improving the Detector yolov8 To construct an improved detector LsTLP = Detector in the CountMD counting model Impr (TInput,ω DI ), where Detector Impr To improve the detector name, TInput is the input tensor of the improved detector, ω DI For the parameter tensor of the improved detector to be trained, LsTLP is a list of predicted label tensors of the improved detector, such as... Figure 3 As shown, specifically:
[0057] (1) For the original detector yolov8 Backbone network yolov8 Lightweighting results in Backbone Impr :
[0058] The Backbone is obtained by combining the CBRM block and Shuffle_Block block from the existing ShuffleNetv2 network. Impr In this embodiment, the ShuffleNetv2 network from the literature (Ma N, Zhang X, Zheng HT, et al. ShuffleNet V2: Practical guidelines for efficient CNN architecture design[C] / / Proceedings of the 15th European Conference on Computer Vision.2018:122-138.) is adopted.
[0059] (2) For the original detector yolov8 Neck network yolov8 Improvements were made to obtain the Neck Impr :
[0060] First, the neck network yolov8The C2f block in the code is improved to a C2f-CA block, such as... Figure 4 As shown, by adding a CA attention mechanism to the Bottleneck blocks within the C2f block, the n Bottleneck blocks in the C2f block are improved into Bottleneck-CA blocks, while the convolutional blocks, split blocks, and connection function blocks in the C2f block remain unchanged. Then, the Neck... yolov8 Each C2f block in the Neck is replaced with a C2f-CA block, and the Neck is... yolov8 The connection function block, upsampling function block, and convolutional block remain unchanged. In this embodiment, the CA attention mechanism from the literature (Hou Q, Zhou D, Feng J. Coordinate attention for efficient mobile network design[C] / / Proceedings of the 2021 IEEE / CVF Conference on Computer Vision and Pattern Recognition.2021:13708-13717.) is adopted.
[0061] Therefore, the improved detector in the CountMD counting model of this application Impr It can be represented as: Detector Impr (TInput,ω DI ) = Head yolov8 (Neck Impr (BackBone Impr (TInput,ω BI ),ω NI ),ω H ), where ω BI It's BackBone Impr The parameter tensor, ω NI It is Neck Impr The parameter tensor, ω H It is Head yolov8 The parameter tensor. Then, Detector Impr The model parameter tensor that needs to be trained is ω DI =[ω BI ,ω NI ,ω H ].
[0062] S302. Call and initialize the ByteTracker tracker: In this embodiment: First, a ByteTracker tracker is created according to the method in the literature (Zhang Y, Sun P, Jiang Y, et al. ByteTrack: Multi-object tracking by associating every detection box [C] / / Proceedings of the 17th European Conference on ComputerVision. 2022: 1-21.), and initialized in the same way. The initialization control parameters include image size img_size = 640, confidence level conf = 0.25, and intersection-over-union ratio iou = 0.7. The corresponding values are set according to the literature. Then, the improved detector is... Impr The output LsTLP is used as the input of the ByteTracker tracker, and the ByteTracker tracker calculates the output TTOut, which is represented as TTOut = ByteTracker(LsTLP).
[0063] S303. Rename the existing counter to Counter and call it: In this embodiment: First, download the code from https: / / github.com / Umar-Saeed-97 / Vehicle-Count and rename the existing counter in the code to Counter. Second, use the output TTOut of the ByteTracker tracker as the input of Counter. Next, use the trajectory drawing module built into Counter to draw the motion trajectory of each tracked dragon fruit in TTOut. Then, use the video counting processing module built into Counter to process TTOut and obtain the model's counting result dictionary CountR, represented as: Among them nneCPt k For the predicted neCPt k The number of dragon fruits of each category.
[0064] Finally, the CountMD counting model is obtained, such as Figure 2 As shown, it is represented as: CountMD(TInput,ω CtM )=Counter(ByteTracker(Detector Impr (TInput,ω DI ))), ω CtMThese are the parameters that need to be trained for the CountMD counting model.
[0065] Furthermore, the Detector in the CountMD counting model is trained and tested. Impr The detector has been improved, specifically:
[0066] S401, Detector in training the CountMD counting model Impr Improved detector:
[0067] (1) In this embodiment: First, the 1185 training set images TrI and 169 validation set images VaI in step S104 are converted into training set image tensors TTrI and validation set image tensors TVaI, respectively. Then, the 1185 training set annotation files LrT and 169 validation set annotation files LaT in step S104 are converted into training set ground truth label tensor lists LsTLTr and validation set ground truth label tensor lists LsTLTa, respectively. Then, the tensors TTrI and TVaI are normalized to obtain normalized training set image tensors TNTrI and normalized validation set image tensors TNVaI.
[0068] (2) In this embodiment, the training batch size is set to 16, momentum to 0.973, learning rate to 0.01, and training iterations to 150 epochs. The TNTrI, TNVaI, LsTLTr, and LsTLTa obtained in step S401 (1) are input into the training module of the improved detector in the CountMD counting model for training. After training, the training module automatically assigns the optimal model parameter tensor ω. DI Save it to the best.pt parameter file.
[0069] S402, Testing the Detector in the CountMD counting model Impr Improved detector:
[0070] (1) In this embodiment: First, the 340 test set images TeI in step S104 are converted into test set image tensors TTeI, and the 340 test set annotation files LeT in step S104 are converted into a list of test set real label tensors LsTLTe. Then, the tensor TTeI is normalized to obtain the normalized test set image tensor TNTeI.
[0071] (2) Transfer the current optimal model parameter tensor ω from the saved best.pt parameter file. DI Load the Detector constructed in step S301 Impr Improved detector.
[0072] (3) The normalized test set image tensor TNTeI is used as the tensor ω loaded with the current optimal model parameters. DI Detector Impr Improve the detector's input. This is achieved through LsTLP=Detector Impr (TInput,ω DI This yields a list of predicted label tensors for the test set image TeI.
[0073] (4) Accuracy, average precision, recall, inference speed, and model parameter count were used as evaluation metrics. The real label tensor list LsTLTe and the predicted label tensor list LsTLP of the dragon fruit image were used to evaluate the Detector. Impr Improve the detector and evaluate its performance. As shown in Table 1, the detector... Impr The parameters are 5.9M, the inference speed is 2.0ms, the accuracy is 86.5%, the recall is 84.6%, and the average precision is 90.1%.
[0074] Table 1 is based on Detector Impr Evaluation of the performance of dragon fruit testing
[0075] Evaluation indicators Evaluation index values Accuracy / % 86.5 Recall rate / % 84.6 Average accuracy / % 90.1 Model parameter count / M 5.9 Inference speed / ms 2.0
[0076] Furthermore, the specific steps for applying the CountMD counting model in S5 are as follows:
[0077] S501. Convert the video PV to be counted into a tensor, and combine this tensor with the current optimal model parameter tensor ω from the saved best.pt parameter file. DI Load it into the CountMD counting model constructed in step S3.
[0078] S502, using CountR = CountMD(TInput,ω CtM The final counting result dictionary is obtained. The effect of using the CountMD counting model to count dragon fruits in the video PV is as follows: Figure 5 As shown in the figure, the counting results are: 3 ripe fruits, 4 unripe fruits, and 1 pigmented fruit.
Claims
1. A dragon fruit counting method based on YOLOv8, characterized in that, Includes the following steps: S1. Dragon fruit detection image dataset is created by acquiring dragon fruit images, scaling dragon fruit images, annotating dragon fruit images, and dividing dragon fruit images and annotation files. S2. Use video recording equipment to capture videos of dragon fruit; S3. Construct a dragon fruit counting model, including improvements to the detector, tracker, and counter; The improved detector is constructed based on the existing YOLOv8 model and is used to detect dragon fruit; the tracker is an existing one. ByteTracker A tracker is used to track dragon fruit fruits; the counter is a renamed existing counter used to output a dictionary of dragon fruit counting results. S4. Train and test the improved detector in the dragon fruit counting model using the dragon fruit detection image dataset; S5. Use the dragon fruit counting model to count the dragon fruit in the collected dragon fruit videos. The construction of the dragon fruit counting model is specifically as follows: S301. Constructing an Improved Detector: Based on the existing YOLOv8 model, an original detector is constructed, comprising a backbone network, a neck network, and a head network. The original detector is improved by lightweighting the backbone network and adding an attention mechanism to the neck network, resulting in an improved detector for the dragon fruit counting model. Lightweighting the backbone network involves replacing the original detector's backbone network with a combination of the CBRM and Shuffle_Block blocks from the existing ShuffleNetv2 network. Adding an attention mechanism to the neck network involves adding a CA attention mechanism after the Bottleneck block within each C2f block in the neck network of the original detector. S302, Call and initialize ByteTracker Tracker: Calling existing ones ByteTracker The tracker is initialized and then used to compute the output of the improved detector; S303, Rename the existing counter. Counter The counter is then invoked.
2. The dragon fruit counting method based on YOLOv8 according to claim 1, characterized in that, The steps for creating the dragon fruit detection image dataset are as follows: S101. Dragon Fruit Image Acquisition: Determine the number of dragon fruit categories and their names according to requirements; use image acquisition equipment to acquire images of dragon fruit in the natural environment of the orchard and save them to a folder; S102, Dragon Fruit Image Resizing: Resize the dragon fruit images in the folder to 3* inch. W * H Pixel size, of which W The width of the scaled image. H The height of the scaled image; S103. Dragon fruit image annotation: Select the scaled dragon fruit images in the folder, annotate them with the actual fruit category name, and save the annotation file; S104. Dragon fruit image and annotation file division: The processed dragon fruit images and their corresponding annotation files are randomly divided into training set, test set and validation set according to the proportion to obtain dragon fruit detection image dataset.
3. The dragon fruit counting method based on YOLOv8 according to claim 1, characterized in that, The improved detector in the training and testing of the dragon fruit counting model is specifically as follows: S401, Improved detector in training the dragon fruit counting model: The training set images and validation set images are converted into training set image tensors and validation set image tensors, respectively. The training set annotation files and validation set annotation files are converted into training set true label tensor lists and validation set true label tensor lists, respectively. The training set image tensors and validation set image tensors are then normalized to obtain normalized training set image tensors and normalized validation set image tensors. Set the training batch size, momentum, learning rate, and number of training iterations. Use the obtained normalized training set image tensor, normalized validation set image tensor, training set ground truth label tensor list, and validation set ground truth label tensor list for training. After training is complete, the optimal model parameter tensor will be automatically saved to the parameter file; S402, Testing an improved detector in a dragon fruit counting model: The test set images are converted into test set image tensors, the test set annotation files are converted into a list of test set true label tensors, and the test set image tensors are normalized to obtain normalized test set image tensors. Load the current optimal model parameter tensor from the saved parameter file into the improved detector in the constructed dragon fruit counting model; The normalized test set image tensor is used as input to the improved detector in the dragon fruit counting model loaded with the current optimal model parameter tensor to obtain a list of predicted label tensors for the test set images. Accuracy, mean precision, recall, inference speed, and number of model parameters were used as evaluation metrics. The performance of the improved detector in the dragon fruit counting model was evaluated using a list of real label tensors and a list of predicted label tensors for the obtained dragon fruit images.
4. The dragon fruit counting method based on YOLOv8 according to claim 3, characterized in that, The counting of dragon fruit fruits in the collected dragon fruit videos specifically involves: S501. Convert the video to be counted into a tensor, and load the tensor and the current optimal model parameter tensor in the saved parameter file into the constructed dragon fruit counting model. S502. Obtain the final counting result dictionary through the dragon fruit counting model.
Citation Information
Patent Citations
Improved YOLOv5n-based winter jujube detection and counting method deployed in Android system
CN116309414A
Field fruit counting method and system based on video target tracking
CN117036238A