Pineapple fruit detection method, device and equipment in complex environment and medium
Through the improved YOLOv5s model and non-maximum suppression algorithm, the problem of false detection and missed detection of pineapple fruit detection in complex environments is solved, the detection accuracy and adaptability are improved, and it is suitable for smart agricultural systems.
Patent Information
- Application Number
- CN202410884895.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-10-29
AI Technical Summary
Existing pineapple fruit detection methods are prone to problems such as false detection, missed detection, and low detection accuracy in complex environments. In particular, illumination and viewing angle factors have a greater impact and have low adaptability.
The improved YOLOv5s model is adopted, the original convolution is replaced by Ghost convolution, and the CABM attention mechanism module is added to the backbone network and neck network, a lightweight upsampling operator is introduced, and combined with the non-maximum suppression algorithm, the detection accuracy is improved. and robustness.
It significantly improves the accuracy and adaptability of pineapple fruit detection, reduces the number of parameters and calculations of the model, reduces the hardware cost, avoids the problem of mistaken picking and missing picking, and provides a solid theoretical foundation for smart agriculture.
Smart Images

Figure CN118865367A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision, and in particular to a method for detecting pineapple fruit in a complex environment, a corresponding device, an electronic device, and a computer-readable storage medium. Background Art
[0002] The world's pineapple production and trade are showing a steady growth trend, but the current pineapple harvesting method is still mainly manual. However, the sharp thorns on the leaves of pineapples, the short harvest period, and the heavy workload make robot harvesting an inevitable trend in the future. Therefore, in order to achieve efficient automatic picking of pineapples, ensure the timely harvest of ripe fruits, and improve the competitiveness of the pineapple market, it is essential to conduct in-depth research on the key technologies of pineapple picking robots.
[0003] Pineapple target detection is one of the most critical technologies for pineapple picking robots, which will directly affect the success rate and efficiency of picking. Therefore, in order to improve the efficiency of robot picking pineapples and avoid excessive damage to the fruits, it is necessary to quickly and accurately identify the location of pineapples in the pineapple field.
[0004] At present, the design of robot vision systems in agricultural production mainly covers traditional image processing methods and deep learning-based technologies. Traditional image processing methods focus on using the color, shape, and texture characteristics of pineapple fruits for identification. However, these methods are prone to false detection, missed detection, and low detection accuracy due to factors such as lighting and viewing angle in natural environments. In addition, the pineapple fruit detection method based on deep learning mainly relies on the data set of a single fruit, and its adaptability to complex orchard environments is relatively low.
[0005] To sum up, the image processing methods in the prior art focus on using the color, shape, texture and other features of pineapple fruits for identification. However, these methods are prone to problems such as false detection, missed detection and low detection accuracy due to factors such as lighting and viewing angle in the natural environment. The applicant has made corresponding explorations to solve this problem. Summary of the invention
[0006] The purpose of this application is to solve the above-mentioned problems and provide a pineapple fruit detection method in a complex environment, a corresponding device, an electronic device and a computer-readable storage medium.
[0007] In order to meet the various objectives of this application, this application adopts the following technical solutions:
[0008] A pineapple fruit detection method in a complex environment proposed to meet one of the purposes of this application comprises:
[0009] Responding to a pineapple fruit detection instruction, obtaining an image of a pineapple orchard to be detected;
[0010] Based on the pineapple fruit detection model that has been trained to a convergent state, target detection is performed on the pineapple orchard image to be detected to determine a candidate frame corresponding to the pineapple to be picked, and the candidate frame is processed by a non-maximum suppression algorithm to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected, wherein the basic network architecture of the pineapple fruit detection model is an improved YOLOv5s model, the improved YOLOv5s model uses Ghost convolution to replace the convolution of the original network, adds a CABM attention mechanism module at the connection between the backbone network and the neck network, and introduces a lightweight upsampling operator in the neck network;
[0011] The picking operation robot determines the picking action position of its manipulator according to the target position of the pineapple to be picked, and drives the manipulator to pick the pineapple to be picked into a fruit collection frame to complete the pineapple fruit detection in a complex environment.
[0012] Optionally, the steps for training a pineapple fruit detection model include:
[0013] Determine a pineapple orchard image, and use the pineapple orchard image to construct a data set of a pineapple fruit detection model;
[0014] Using an image annotation tool to manually annotate the pineapple fruits in the dataset;
[0015] Adjust and train the parameters of the improved YOLOv5s model, and obtain and save the model weights that have been trained to a converged state;
[0016] The improved YOLOv5s model that has been trained to a convergent state is used to infer the pineapple orchard image to be detected, and the specific position of the pineapple fruit in the pineapple orchard image to be detected is obtained after being processed by a non-maximum suppression algorithm.
[0017] Optionally, the Ghost convolution module includes a conventional convolution module, a Ghost feature generation module and a feature image stitching module;
[0018] In the conventional convolution module, the input feature is convolved using conventional convolution to determine the first feature map, so as to determine the first feature map;
[0019] In the Ghost feature generation module, a simpler linear transformation is applied to each intrinsic feature in the first feature map to determine a second feature map to determine a second feature map;
[0020] In the feature image stitching module, the first feature map and the second feature map are identity-connected to determine a final output feature.
[0021] Optionally, the basic network architecture of the backbone network is an improved CSP-Darknet53 network, and the improved CSP-Darknet53 network adds a CABM attention mechanism module after the C3 module to improve the ability to extract pineapple feature information, and outputs three feature maps of different scales as input of the neck network, wherein the CABM attention mechanism module is an attention module that combines a channel attention mechanism and a spatial attention mechanism;
[0022] The CABM attention mechanism module is added at the three connections between the backbone network and the neck network. The channel attention mechanism in the CABM attention mechanism module sequentially infers a one-dimensional channel attention map F along two independent dimensions of channel and space. C and a two-dimensional spatial attention map F S , multiply it by the feature map for adaptive feature refinement, and obtain the refined map F2 as the input of the next layer.
[0023] Optionally, the neck network is composed of a spatial pyramid pooling network that introduces a lightweight upsampling operator and a feature pyramid-path aggregation network, wherein the lightweight upsampling operator is a CARAFE upsampling operator.
[0024] Optionally, the spatial pyramid pooling network includes three pooling layers, the convolution kernel size of the pooling layer is 5x5, the step size is 1, and the padding is 2;
[0025] The feature pyramid-path aggregation network splices the three feature maps of different scales extracted by the backbone network from two path directions, top-down and bottom-up;
[0026] The feature pyramid-path aggregation network performs a convolution and upsampling operation on the feature map output by the spatial pyramid pooling network, and the obtained feature map is concatenated with the 40×40 feature layer of the improved CSP-Darknet53 network, and then three Ghost convolutions are performed;
[0027] The feature pyramid-path aggregation network performs a convolution and upsampling operation on the feature map after three Ghost convolutions, and the obtained feature map is spliced with the 40×40 feature layer of the improved CSP-Darknet53 network. After three Ghost convolution operations, a part of it is used as the input of the 80×80 feature layer of the detection head part to detect the small target pineapple fruit;
[0028] The other part undergoes a convolution operation, which is then concatenated with the feature map of the last single convolution operation and then convolution operations are performed three times. On the one hand, it is used as the input of the 40×40 feature layer of the detection head. On the other hand, it undergoes another convolution operation, which is then concatenated with the feature map of the first convolution operation and then convolution operations are performed three times as the input of the 20×20 feature layer of the detection head.
[0029] Optionally, the CARAFE upsampling operator is an efficient and lightweight upsampling operator, which consists of two parts: a kernel prediction module and a content-aware reorganization module;
[0030] In the kernel prediction module, the size of the feature map of the kernel prediction module input is H×W×C, and the number of channels of the input feature is compressed to H×W×C by using a 1×1 convolution through Channel Compressor. m ;
[0031] The content encoder uses a convolutional layer with a convolution kernel size of k to generate a K-th up ×K up The predicted recombinant nucleus, where each K up ×K up The predicted reorganized kernel is subjected to Kernel Normalizer operation before being applied to the input feature map;
[0032] The Softmax function is used to normalize the space so that the sum of the convolution kernel weights is 1, resulting in a size of K up ×K up ×H×W reorganized kernel w′.
[0033] In the content-aware reorganization module, a k×k subregion centered at l(i,j) in the input feature map X is selected as input, and a position-based kernel w is predicted for each position l′ in w′. l′ Perform the recombination operation to obtain the feature graph X′ l′ .
[0034] A pineapple fruit detection device in a complex environment provided to meet another purpose of the present application includes:
[0035] An image acquisition module is configured to respond to a pineapple fruit detection instruction and acquire an image of a pineapple orchard to be detected;
[0036] A pineapple position determination module is configured to perform target detection on the pineapple orchard image to be detected based on a pineapple fruit detection model that has been trained to a convergence state to determine a candidate frame corresponding to the pineapple to be picked, and process the candidate frame using a non-maximum suppression algorithm to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected, wherein the basic network architecture of the pineapple fruit detection model is an improved YOLOv5s model, the improved YOLOv5s model uses Ghost convolution to replace the convolution of the original network, adds a CABM attention mechanism module at the connection between the backbone network and the neck network, and introduces a lightweight upsampling operator in the neck network;
[0037] The pineapple picking module is configured as a picking operation robot that determines the picking action position of its manipulator according to the target position of the pineapple to be picked, and drives the manipulator to pick the pineapple to be picked into a fruit collection frame to complete the pineapple fruit detection in a complex environment.
[0038] An electronic device provided to meet another purpose of the present application includes a central processing unit and a memory, wherein the central processing unit is used to call and run a computer program stored in the memory to execute the steps of the pineapple fruit detection method in a complex environment described in the present application.
[0039] A computer-readable storage medium is provided to meet another purpose of the present application, which stores a computer program implemented according to the pineapple fruit detection method in a complex environment in the form of computer-readable instructions. When the computer program is called and executed by a computer, the steps included in the corresponding method are executed.
[0040] Compared with the prior art, the present application focuses on the image processing methods in the prior art that use the color, shape, texture and other features of pineapple fruits for identification. However, these methods are prone to false detection, missed detection and low detection accuracy due to factors such as lighting and viewing angle in the natural environment. The present application includes but is not limited to the following beneficial effects:
[0041] First, the pineapple fruit detection method in a complex environment of the present application fully considers pineapple fruits in different situations in a complex environment, and completes the preparation of a data set based on this, thereby improving the generalization performance and robustness performance of the detection model;
[0042] Secondly, the pineapple fruit detection method in a complex environment of the present application makes a lightweight improvement on the YOLOv5s detection network, replaces the original ordinary convolution with Ghost convolution, adds channels and spatial attention mechanisms to the backbone network, and introduces a lightweight upsampling operator to the neck network, which greatly reduces the number of parameters and calculations of the model while ensuring the accuracy of detection, improves the accurate detection of pineapple fruits in the complex environment of the pineapple orchard, and significantly reduces the hardware cost of model deployment;
[0043] Thirdly, the pineapple fruit detection method in a complex environment of the present application is based on a deep learning network. Compared with the traditional method, it has the ability of autonomous feature learning, does not require manual extraction and design of the features of pineapple fruits, can better reduce labor costs, and also has higher accuracy;
[0044] Furthermore, the pineapple fruit detection method in complex environments of the present application can adapt to various complex pineapple picking environments, avoid problems such as mispicking, missed picking, and low detection accuracy of the picking robot during the picking process, and lay a solid theoretical foundation for the construction of a smart agricultural system. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0046] Figure 1 This is a flow chart of the pineapple fruit detection method in a complex environment of this application;
[0047] Figure 2 A schematic diagram of the network structure of the improved YOLOv5s model in the embodiment of the present application;
[0048] Figure 3 Schematic diagram of the principle diagram of Ghost convolution in an embodiment of the present application;
[0049] Figure 4 This is a schematic diagram of the channel space attention mechanism structure in an embodiment of the present application;
[0050] Figure 5 This is a schematic diagram of a lightweight upsampling structure in an embodiment of the present application;
[0051] Figure 6 This is a schematic diagram of a pineapple orchard image to be detected in an embodiment of the present application;
[0052] Figure 7 This is a schematic diagram of the detection effect of the pineapple fruit to be picked in the embodiment of the present application;
[0053] Figure 8This is a principle block diagram of a pineapple fruit detection device in a complex environment in an embodiment of the present application;
[0054] Fig. 9 It is a schematic diagram of the structure of the computer device in the embodiment of the present application. DETAILED DESCRIPTION
[0055] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.
[0056] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0057] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0058] It will be understood by those skilled in the art that the terms "client", "terminal" and "terminal device" as used herein include both devices with wireless signal receivers, which are devices with only wireless signal receivers without transmission capability, and devices with receiving and transmitting hardware, which are devices with receiving and transmitting hardware capable of two-way communication over a two-way communication link. Such devices may include: cellular or other communication devices such as personal computers, tablet computers, which have single-line displays or multi-line displays or cellular or other communication devices without multi-line displays; PCS (Personal Communications Services) which may combine voice, data processing, fax and / or data communication capabilities; PDA (Personal Digital Assistant) which may include a radio frequency receiver, pager, Internet / intranet access, web browser, notepad, calendar and / or GPS (Global Positioning System) receiver; conventional laptop and / or palmtop computers or other devices which have and / or include a radio frequency receiver. The "client", "terminal" and "terminal device" used herein may be portable, transportable, installed in a vehicle (air, sea and / or land), or adapted and / or configured to run locally, and / or in a distributed form, at any other location on the earth and / or in space. The "client", "terminal" and "terminal device" used herein may also be a communication terminal, an Internet terminal, a music / video playing terminal, such as a PDA, a MID (Mobile Internet Device) and / or a mobile phone with a music / video playing function, or may be a smart TV, a set-top box and other devices.
[0059] The hardware referred to by the names such as "server", "client", and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann principle, such as a central processing unit (including an arithmetic unit and a controller), a memory, an input device, and an output device. The computer program is stored in its memory, and the central processing unit calls the program stored in the external memory into the internal memory for execution, executes the instructions in the program, and interacts with the input and output devices to complete specific functions.
[0060] It should be pointed out that the concept of "server" referred to in this application can also be extended to the case of server clusters. According to the network deployment principle understood by those skilled in the art, the servers should be logically divided. In physical space, these servers can be independent of each other but can be called through interfaces, or integrated into a physical computer or a set of computer clusters. Those skilled in the art should understand this flexibility, and should not use it to restrict the implementation of the network deployment method of this application.
[0061] Unless expressly specified, one or more technical features of the present application can be deployed on a server for implementation and accessed by a client through a remote call to obtain an online service interface provided by the server, or can be directly deployed and run on a client for access.
[0062] The neural network models referenced or may be referenced in this application, unless expressly specified, can be deployed on a remote server and remotely called on the client, or can be deployed and directly called on a client with sufficient device capabilities. In some embodiments, when it runs on the client, its corresponding intelligence can be obtained through transfer learning to reduce the requirements for the client's hardware operating resources and avoid excessive occupation of the client's hardware operating resources.
[0063] Unless explicitly specified, the various data involved in this application can be stored remotely on a server or on a local terminal device, as long as it is suitable for being called by the technical solution of this application.
[0064] Those skilled in the art should be aware that, although the various methods of the present application are described based on the same concept and thus present commonality to each other, unless otherwise specified, these methods can be independently executed. Similarly, for each embodiment disclosed in the present application, they are all proposed based on the same inventive concept, therefore, concepts with the same expression, and concepts that are appropriately changed for convenience despite different expressions, should be understood as equivalent.
[0065] Unless the mutually exclusive relationship between the embodiments to be disclosed in this application is explicitly stated, the relevant technical features involved in each embodiment can be cross-combined to flexibly construct a new embodiment, as long as such combination does not deviate from the creative spirit of this application and can meet the needs of the prior art or solve certain deficiencies in the prior art. Those skilled in the art should be aware of this flexibility.
[0066] See also Figure 1 In one embodiment, the pineapple fruit detection method under a complex environment of the present application comprises:
[0067] Step S10, responding to the pineapple fruit detection instruction, obtaining the image of the pineapple orchard to be detected;
[0068] The picking robot can respond to the pineapple fruit detection instruction and obtain the image of the pineapple orchard to be detected. The image of the pineapple orchard to be detected can be obtained based on the binocular camera or other camera equipment in the picking robot, wherein the image of the pineapple orchard to be detected is an image containing pineapple fruits to be picked. After obtaining the image of the pineapple orchard to be detected, the image of the pineapple orchard to be detected is pushed to the pineapple fruit detection module in the picking robot for target detection.
[0069] In some embodiments, the picking robot can collect pineapple orchard images with a resolution of 1920*1080 from different angles of view from 45° to 90° to establish a pineapple fruit detection model data set; the data takes into account the time and weather factors of the actual picking robot, such as the shooting situations in sunny mornings and noons, cloudy days, evenings, etc., and at the same time collects pineapple orchard images when pineapples are blocked by large areas of branches and leaves and when pineapples are remotely detected; after collecting the above-mentioned pineapple orchard images, use an image annotation tool to manually annotate the pineapple fruits in the data set; specifically, use an open source image annotation tool l abe l img to annotate the pineapple fruits in the pineapple orchard images.
[0070] Step S20, based on the pineapple fruit detection model that has been trained to a convergent state, target detection is performed on the pineapple orchard image to be detected to determine a candidate frame corresponding to the pineapple to be picked, and the candidate frame is processed by a non-maximum suppression algorithm to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected, wherein the basic network architecture of the pineapple fruit detection model is an improved YOLOv5s model, the improved YOLOv5s model uses Ghost convolution to replace the convolution of the original network, a CABM attention mechanism module is added at the connection between the backbone network and the neck network, and a lightweight upsampling operator is introduced in the neck network;
[0071] After obtaining the pineapple orchard image to be detected, target detection is performed on the pineapple orchard image to be detected based on the pineapple fruit detection model that has been trained to a convergent state to determine the candidate frame corresponding to the pineapple to be picked, and the candidate frame is processed by a non-maximum suppression algorithm to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected, wherein the basic network architecture of the pineapple fruit detection model is an improved YOLOv5s model, please refer to Figure 2 The improved YOLOv5s model adopts Ghost convolution to replace the convolution of the original network, adds a CABM attention mechanism module at the connection between the backbone network (Backbone) and the neck network (Neck), and introduces a lightweight upsampling operator in the neck network (Neck) and the detection head (Head);
[0072] In some embodiments, the non-maximum suppression algorithm sorts the candidate box list of the pineapple fruit to be picked according to the confidence of the box, and selects the candidate box with the highest score as the initial output; calculates the IoU of the remaining boxes and the currently selected box, removes all boxes with IoU greater than a preset threshold, and only retains those with lower IoU to ensure that too many overlapping boxes are not retained, and repeats the above steps until all boxes are processed to determine the target position of the pineapple fruit to be picked.
[0073] In some embodiments, the step of training a pineapple fruit detection model comprises:
[0074] Step S101, determining a pineapple orchard image, and using the pineapple orchard image to construct a data set of a pineapple fruit detection model;
[0075] Step S103, manually labeling the pineapple fruits in the data set using an image labeling tool;
[0076] Step S105: adjusting and training the parameters of the improved YOLOv5s model, and obtaining and saving the model weights that have been trained to a convergence state;
[0077] Step S107, using the improved YOLOv5s model that has been trained to a convergence state to infer the pineapple orchard image to be detected, and obtaining the specific position of the pineapple fruit in the pineapple orchard image to be detected after processing by a non-maximum suppression algorithm.
[0078] Specifically, the training batch size is set to 8, the experimental optimizer is Adan, the total number of iterations is 300 epochs, the learning rate adopts the cosine annealing algorithm, the maximum learning rate is 0.05, and the decay weight value is 0.01;
[0079] The specific steps for training the pineapple fruit detection model are:
[0080] Adjust hyperparameters, select dataset folder and network model structure, and conduct training;
[0081] After training reaches a preset number of iterations, the training ends, and the pineapple fruit detection model with the best evaluation index is selected, and its weight file is saved;
[0082] The optimal pineapple fruit detection model is used to infer the pineapple orchard image to be detected, and the specific position of the pineapple fruit to be picked in the pineapple orchard image to be detected is obtained after maximum suppression processing;
[0083] More specifically, the pineapple fruit detection model that has been trained to a convergent state is used to infer the pineapple orchard image to be detected, and n preliminary screening results are obtained. Non-maximum suppression with a threshold of 0.5 and confidence screening and filtering with a threshold of 0.25 are performed to obtain the detection results of the pineapple fruit. The pineapple orchard image to be detected is a complex pineapple orchard image, which contains target pineapple fruits to be picked.
[0084] In some embodiments, a data enhancement algorithm is used to expand the pineapple orchard image dataset. Based on the improved YOLOv5s backbone network extraction part and the neck network responsible for feature fusion and processing, an attention mechanism is added and a lightweight upsampling operator is introduced to make it more suitable for the pineapple fruit dataset in the complex environment of the pineapple orchard. The hyperparameters and training parameters are set and adjusted to iteratively train the network, thereby realizing real-time detection of pineapple fruits in the complex environment of the orchard.
[0085] In some embodiments, see Figure 3 The Ghost convolution module includes a conventional convolution module, a Ghost feature generation module and a feature image splicing module; in the conventional convolution module, the input feature X is convolved by conventional convolution to determine the first feature map Y to determine the first feature map; in the Ghost feature generation module, a simpler linear transformation is applied to each inherent feature in the first feature map to determine the second feature map Y' to determine the second feature map; in the feature image splicing module, the first feature map is identity-connected with the second feature map to determine the final output feature.
[0086] In some embodiments, the basic network architecture of the backbone network is an improved CSP-Darknet53 network, and the improved CSP-Darknet53 network adds a CABM attention mechanism module after the C3 module to improve the ability to extract pineapple feature information, and outputs three feature maps of different scales as inputs of the neck network, wherein the CABM attention mechanism module is an attention module that combines a channel attention mechanism and a spatial attention mechanism;
[0087] See also Figure 4 The CABM attention mechanism module is added at the three connections between the backbone network and the neck network. The channel attention mechanism in the CABM attention mechanism module sequentially infers a one-dimensional channel attention map F along two independent dimensions of channel and space. C and a two-dimensional spatial attention map F S , multiply it by the feature map for adaptive feature refinement, and obtain the refined map F2 as the input of the next layer.
[0088] In some embodiments, the neck network is composed of a spatial pyramid pooling network (SPP) and a feature pyramid-path aggregation network (FPN-PAN) that introduce a lightweight upsampling operator, wherein the lightweight upsampling operator is a CARAFE upsampling operator, and the CARAFE (Content-Aware ReAssembly of FEatures) upsampling operator is a neural network upsampling method, and its main advantage is that it can improve the quality of upsampling while maintaining computational efficiency. Traditional upsampling methods (such as bilinear interpolation) usually lead to smoothing of images or features, while the CARAFE upsampling operator can better retain and reconstruct detail information through adaptive feature reorganization, thereby improving the performance of the model.
[0089] In some embodiments, the spatial pyramid pooling network includes three pooling layers, the convolution kernel size of the pooling layer is 5x5, the step size is 1, and the padding is 2; the feature pyramid-path aggregation network splices the three feature maps of different scales extracted by the backbone network from the top-down and bottom-up paths; the feature pyramid-path aggregation network performs a convolution and upsampling operation on the feature map output by the spatial pyramid pooling network, and the obtained feature map is spliced with the 40×40 feature layer of the improved CSP-Darknet53 network, and then three Ghost convolutions are performed; the feature pyramid-path aggregation network performs a convolution and upsampling operation on the feature map after three Ghost convolutions, and the obtained feature map is spliced with the improved CSP-Darknet53 network. The 40×40 feature layer of the SP-Darknet53 network is spliced and subjected to three Ghost convolution operations. One part is used as the input of the 80×80 feature layer of the detection head to detect the small target pineapple fruit; the other part undergoes a convolution operation, spliced with the feature map of the last single convolution operation, and then subjected to three convolution operations. On the one hand, it is used as the input of the 40×40 feature layer of the detection head, and on the other hand, it undergoes another convolution operation, spliced with the feature map of the first convolution operation, and then subjected to three convolution operations as the input of the 20×20 feature layer of the detection head.
[0090] In some embodiments, see Figure 5The CARAFE upsampling operator is an efficient and lightweight upsampling operator, which consists of two parts: a kernel prediction module and a content-aware reorganization module; in the kernel prediction module, the size of the input feature map of the kernel prediction module is H×W×C, and the number of channels of the input feature is compressed to H×W×C by using a 1×1 convolution through ChannelCompressor m ; Use the convolution layer with a convolution kernel size of k to generate a K-th image up ×K up The predicted recombinant nucleus, where each K up ×K up The predicted reorganized kernel is subjected to Kernel Normalizer operation before being applied to the input feature map; the Softmax function is used to normalize the space so that the sum of the convolution kernel weights is 1, resulting in a convolution kernel of size K. up ×K up ×H×W reorganized kernel w′;
[0091] In the content-aware reorganization module, a k×k subregion centered at l(i,j) in the input feature map X is selected as input, and a position-based kernel w is predicted for each position l′ in w′. l′ Perform the recombination operation to obtain the feature graph X′ l′ .
[0092] In some embodiments, see Figure 6 and Figure 7 ,in, Figure 6 is a schematic diagram of the pineapple orchard image to be detected. Figure 7 Schematic diagram of the detection effect of pineapple fruits to be picked.
[0093] Step S30: The picking operation robot determines the picking action position of its manipulator according to the target position of the pineapple to be picked, and drives the manipulator to pick the pineapple to be picked into a fruit collection frame to complete the pineapple fruit detection in a complex environment.
[0094] The candidate frame is processed by a non-maximum suppression algorithm to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected. Then, a picking operation robot determines the picking action position of its manipulator according to the target position of the pineapple to be picked, and drives the manipulator to pick the pineapple to be picked into a fruit collection frame to complete the pineapple fruit detection in a complex environment.
[0095] It can be seen from the above embodiments that, compared with the prior art, the present application focuses on the image processing methods in the prior art that use the color, shape, texture and other features of pineapple fruits for identification. However, these methods are prone to problems such as false detection, missed detection and low detection accuracy due to factors such as lighting and viewing angle in the natural environment. The present application includes but is not limited to the following beneficial effects:
[0096] First, the pineapple fruit detection method in a complex environment of the present application fully considers pineapple fruits in different situations in a complex environment, and completes the preparation of a data set based on this, thereby improving the generalization performance and robustness performance of the detection model;
[0097] Secondly, the pineapple fruit detection method in a complex environment of the present application makes a lightweight improvement on the YOLOv5s detection network, replaces the original ordinary convolution with Ghost convolution, adds channels and spatial attention mechanisms to the backbone network, and introduces a lightweight upsampling operator to the neck network, which greatly reduces the number of parameters and calculations of the model while ensuring the accuracy of detection, improves the accurate detection of pineapple fruits in the complex environment of the pineapple orchard, and significantly reduces the hardware cost of model deployment;
[0098] Thirdly, the pineapple fruit detection method in a complex environment of the present application is based on a deep learning network. Compared with the traditional method, it has the ability of autonomous feature learning, does not require manual extraction and design of the features of pineapple fruits, can better reduce labor costs, and also has higher accuracy;
[0099] Furthermore, the pineapple fruit detection method in complex environments of the present application can adapt to various complex pineapple picking environments, avoid problems such as mispicking, missed picking, and low detection accuracy of the picking robot during the picking process, and lay a solid theoretical foundation for the construction of a smart agricultural system.
[0100] See also Figure 8A pineapple fruit detection device in a complex environment is provided to meet one of the purposes of the present application, including an image acquisition module 1100, a pineapple position determination module 1200 and a pineapple picking module 1300. Among them, the image acquisition module 1100 is configured to respond to the pineapple fruit detection instruction and obtain the pineapple orchard image to be detected; the pineapple position determination module 1200 is configured to perform target detection on the pineapple orchard image to be detected based on the pineapple fruit detection model that has been trained to a convergence state to determine the candidate frame corresponding to the pineapple to be picked, and use a non-maximum suppression algorithm to process the candidate frame to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected, wherein the basic network architecture of the pineapple fruit detection model is an improved YOLOv5s model, the improved YOLOv5s model uses Ghost convolution to replace the convolution of the original network, adds a CABM attention mechanism module at the connection between the backbone network and the neck network, and introduces a lightweight upsampling operator in the neck network; the pineapple picking module 1300 is configured for the picking operation robot to determine the picking action position of its manipulator according to the target position of the pineapple to be picked, and drives the manipulator to pick the pineapple to be picked into the fruit collection frame to complete the pineapple fruit detection in a complex environment.
[0101] Based on any embodiment of this application, please refer to Fig. 9 Another embodiment of the present application further provides an electronic device, which can be implemented by a computer device, such as Fig. 9 As shown, a schematic diagram of the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. Among them, the computer-readable storage medium of the computer device stores an operating system, a database, and computer-readable instructions. The database may store a control information sequence. When the computer-readable instructions are executed by the processor, the processor can implement a pineapple fruit detection method in a complex environment. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute the pineapple fruit detection method in a complex environment of the present application. The network interface of the computer device is used to connect and communicate with a terminal. Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0102] In this embodiment, the processor is used to execute Figure 8The memory stores the program code and various data required to execute the above modules or submodules. The network interface is used to transmit data between user terminals or servers. The memory in this embodiment stores the program code and data required to execute all modules / submodules in the pineapple fruit detection device under complex environment of this application, and the server can call the program code and data of the server to execute the functions of all submodules.
[0103] The present application also provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the pineapple fruit detection method in a complex environment described in any embodiment of the present application.
[0104] The present application also provides a computer program product, including a computer program / instruction, which, when executed by one or more processors, implements the steps of the pineapple fruit detection method in a complex environment described in any embodiment of the present application.
[0105] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments of the present application can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a computer-readable storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0106] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
[0107] To sum up, the pineapple fruit detection method in complex environments of the present application can adapt to various complex pineapple picking environments, avoid problems such as mispicking, missed picking, and low detection accuracy of the picking robot during the picking process, and lay a solid theoretical foundation for the construction of a smart agricultural system.
Claims
1. A pineapple fruit detection method under a complex environment, characterized in that, include: Responding to a pineapple fruit detection instruction, obtaining an image of a pineapple orchard to be detected; Based on the pineapple fruit detection model that has been trained to a convergent state, target detection is performed on the pineapple orchard image to be detected to determine a candidate frame corresponding to the pineapple to be picked, and the candidate frame is processed by a non-maximum suppression algorithm to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected, wherein the basic network architecture of the pineapple fruit detection model is an improved YOLOv5s model, the improved YOLOv5s model uses Ghost convolution to replace the convolution of the original network, adds a CABM attention mechanism module at the connection between the backbone network and the neck network, and introduces a lightweight upsampling operator in the neck network; The picking operation robot determines the picking action position of its manipulator according to the target position of the pineapple to be picked, and drives the manipulator to pick the pineapple to be picked into a fruit collection frame to complete the pineapple fruit detection in a complex environment.
2. The pineapple fruit detection method under complex environment according to claim 1, characterized in that, The steps to train the pineapple fruit detection model include: Determine a pineapple orchard image, and use the pineapple orchard image to construct a data set of a pineapple fruit detection model; Using an image annotation tool to manually annotate the pineapple fruits in the dataset; Adjust and train the parameters of the improved YOLOv5s model, and obtain and save the model weights that have been trained to a converged state; The improved YOLOv5s model that has been trained to a convergent state is used to infer the pineapple orchard image to be detected, and the specific position of the pineapple fruit in the pineapple orchard image to be detected is obtained after being processed by a non-maximum suppression algorithm.
3. The pineapple fruit detection method under complex environment according to claim 1, characterized in that, The Ghost convolution module includes a conventional convolution module, a Ghost feature generation module and a feature image splicing module; In the conventional convolution module, the input feature is convolved using conventional convolution to determine the first feature map, so as to determine the first feature map; In the Ghost feature generation module, a simpler linear transformation is applied to each intrinsic feature in the first feature map to determine a second feature map to determine a second feature map; In the feature image stitching module, the first feature map and the second feature map are identity-connected to determine a final output feature.
4. The pineapple fruit detection method under complex environment according to claim 1, characterized in that, The basic network architecture of the backbone network is an improved CSP-Darknet53 network. The improved CSP-Darknet53 network adds a CABM attention mechanism module after the C3 module to improve the ability to extract pineapple feature information and outputs three feature maps of different scales as inputs of the neck network. The CABM attention mechanism module is an attention module that combines the channel attention mechanism and the spatial attention mechanism. The CABM attention mechanism module is added at the three connections between the backbone network and the neck network. The channel attention mechanism in the CABM attention mechanism module sequentially infers a one-dimensional channel attention map F along two independent dimensions of channel and space. C and a two-dimensional spatial attention map F S , multiply it by the feature map for adaptive feature refinement, and obtain the refined map F2 as the input of the next layer.
5. The pineapple fruit detection method under complex environment according to claim 1, characterized in that, The neck network is composed of a spatial pyramid pooling network that introduces a lightweight upsampling operator and a feature pyramid-path aggregation network, wherein the lightweight upsampling operator is a CARAFE upsampling operator.
6. The pineapple fruit detection method under complex environment according to any one of claims 3 to 5, characterized in that: The spatial pyramid pooling network includes three pooling layers, the convolution kernel size of the pooling layer is 5x5, the step size is 1, and the padding is 2; The feature pyramid-path aggregation network splices the three feature maps of different scales extracted by the backbone network from two path directions, top-down and bottom-up; The feature pyramid-path aggregation network performs a convolution and upsampling operation on the feature map output by the spatial pyramid pooling network, and the obtained feature map is concatenated with the 40×40 feature layer of the improved CSP-Darknet53 network, and then three Ghost convolutions are performed; The feature pyramid-path aggregation network performs a convolution and upsampling operation on the feature map after three Ghost convolutions, and the obtained feature map is spliced with the 40×40 feature layer of the improved CSP-Darknet53 network. After three Ghost convolution operations, a part of it is used as the input of the 80×80 feature layer of the detection head part to detect the small target pineapple fruit; The other part undergoes a convolution operation, which is then concatenated with the feature map of the last single convolution operation and then convolution operations are performed three times. On the one hand, it is used as the input of the 40×40 feature layer of the detection head. On the other hand, it undergoes another convolution operation, which is then concatenated with the feature map of the first convolution operation and then convolution operations are performed three times as the input of the 20×20 feature layer of the detection head.
7. The pineapple fruit detection method under complex environment according to any one of claims 3 to 5, characterized in that: The CARAFE upsampling operator is an efficient and lightweight upsampling operator, which consists of two parts: a kernel prediction module and a content-aware reorganization module; In the kernel prediction module, the size of the feature map of the kernel prediction module input is H×W×C, and the number of channels of the input feature is compressed to H×W×C by using a 1×1 convolution through Channel Compressor. m ; The content encoder uses a convolutional layer with a convolution kernel size of k to generate a K-th image. up ×K up The predicted recombinant nucleus, where each K up ×K up The predicted reorganized kernel is subjected to Kernel Normalizer operation before being applied to the input feature map; The Softmax function is used to normalize the space so that the sum of the convolution kernel weights is 1, resulting in a size of K up ×K up ×H×W reorganized kernel w′; In the content-aware reorganization module, a k×k subregion centered at l(i,j) in the input feature map X is selected as input, and a position-based kernel w is predicted for each position l′ in w′. l′ Perform the recombination operation to obtain the feature graph X′ l′ .
8. A pineapple fruit detection device in a complex environment, characterized in that: include: An image acquisition module is configured to respond to a pineapple fruit detection instruction and acquire an image of a pineapple orchard to be detected; A pineapple position determination module is configured to perform target detection on the pineapple orchard image to be detected based on a pineapple fruit detection model that has been trained to a convergence state to determine a candidate frame corresponding to the pineapple to be picked, and process the candidate frame using a non-maximum suppression algorithm to obtain the target position of the pineapple to be picked in the pineapple orchard image to be detected, wherein the basic network architecture of the pineapple fruit detection model is an improved YOLOv5s model, the improved YOLOv5s model uses Ghost convolution to replace the convolution of the original network, adds a CABM attention mechanism module at the connection between the backbone network and the neck network, and introduces a lightweight upsampling operator in the neck network; The pineapple picking module is configured as a picking operation robot that determines the picking action position of its manipulator according to the target position of the pineapple to be picked, and drives the manipulator to pick the pineapple to be picked into a fruit collection frame to complete the pineapple fruit detection in a complex environment.
9. An electronic device, comprising a central processing unit and a memory, characterized in that: The central processing unit is used to call and run the computer program stored in the memory to execute the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: It stores a computer program implemented according to the method described in any one of claims 1 to 7 in the form of computer-readable instructions, and when the computer program is called and executed by a computer, the steps included in the corresponding method are executed.
Citation Information
Patent Citations
Fruit picking robot target detection method based on deep learning in unstructured environment
CN112270268A
Industrial process performance evaluation method based on mixed attention convolutional neural network
CN114326639A
Tea tender shoot lightweight detection method in complex environment based on target detection
CN115439744A
Apple detection positioning method and system based on deep convolutional neural network
CN115880477A
Digital measurement system for potato root system length and measurement method thereof
CN116129096A
