Apple maturity detection method, device and equipment and storage medium
By using the combination of convolutional layer, cross-stage feature fusion layer and spatial pyramid pooling layer in Apple's maturity detection technology, combined with the neural network attention mechanism, the problem of low detection accuracy in the existing technology is solved and high precision is achieved and high real-time Apple maturity detection.
Patent Information
- Application Number
- CN202411166838.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-01-03
AI Technical Summary
The existing apple maturity detection technology has low detection accuracy in complex orchard environments, especially when shading targets, and the confidence is low, making it difficult to meet the real-time operation needs.
An Apple maturity detection method is adopted. By obtaining historical Apple images and Apple images to be detected, it is divided into training sets and verification sets, and the initial detection model is trained, using convolutional layers, cross-stage feature fusion layers and spatial pyramid pooling. The layer is processed to generate the Apple maturity detection result. This method includes denoising processing, image enhancement, local features extraction of convolutional layer, cross-stage feature fusion layer enhancement features, spatial pyramid pooling layer multi-scale pooling, combined with neural network attention mechanism to improve detection accuracy.
It realizes high real-time and high-precision Apple maturity detection, which can effectively identify Apple maturity in complex environments, and improves the accuracy and reliability of the detection.
Smart Images

Figure CN119251828A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of apple maturity detection, and in particular to an apple maturity detection method, device, equipment and storage medium. Background Art
[0002] Accurate detection of apple maturity is of great significance for orchard management and automated harvesting. However, current detection technologies have some challenges in detection accuracy.
[0003] In complex orchard environments, target detection algorithms may perform poorly due to problems such as large number of parameters and poor robustness. For example, factors such as natural light, weather conditions, fruit color, collection angle, and number of samples may affect detection accuracy. Especially when detecting distant and obscured targets, existing algorithms may have problems such as missed detection and low confidence, making it difficult to meet the needs of real-time operations.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide an apple maturity detection method, device, equipment and storage medium, aiming to solve the technical problem of low detection accuracy of existing apple maturity detection technology.
[0006] To achieve the above purpose, the present application proposes a method for detecting apple maturity, which comprises:
[0007] Obtain historical apple images and apple images to be detected;
[0008] Dividing the historical apple images into a training set and a validation set, training the initial detection model, and obtaining a target detection model, wherein the target detection model includes a convolution layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer;
[0009] The apple image to be detected is processed by the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain an apple maturity detection result.
[0010] In one embodiment, the step of processing the apple image to be detected through the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain the apple maturity detection result includes:
[0011] Extracting local features of the to-be-detected apple image through the convolutional layer in the target detection model to obtain a feature map;
[0012] Processing the feature map through the cross-stage feature fusion layer to obtain an enhanced feature map;
[0013] The enhanced feature map is processed by the spatial pyramid pooling layer to obtain a target feature image, and an apple maturity detection result is generated based on the target feature image.
[0014] In one embodiment, the step of processing the enhanced feature map through the spatial pyramid pooling layer to obtain a target feature image includes:
[0015] Performing multi-scale pooling on the enhanced feature map through the spatial pyramid pooling layer to obtain global scale features, semi-local scale features, and local scale features of the apple image to be detected;
[0016] The global scale feature, the semi-local scale feature and the local scale feature are fused to obtain a target feature image.
[0017] In one embodiment, the step of processing the feature map through the cross-stage feature fusion layer to obtain an enhanced feature map includes:
[0018] The feature map is subjected to feature conversion, branch processing and feature fusion through the cross-stage feature fusion layer to obtain an enhanced feature map.
[0019] In one embodiment, after the step of extracting local features of the apple image to be detected through the convolutional layer in the object detection model to obtain a feature map, the step further includes:
[0020] Processing the feature map through a channel attention mechanism and a spatial attention mechanism of a neural network attention mechanism to obtain an attention-enhanced feature map;
[0021] The step of performing feature conversion, branch processing and feature fusion on the feature map through the cross-stage feature fusion layer to obtain an enhanced feature map also includes:
[0022] The attention enhanced feature map is subjected to feature conversion, branch processing and feature fusion through the cross-stage feature fusion layer to obtain an enhanced feature map.
[0023] In one embodiment, after the step of obtaining the image of the apple to be detected, the method further includes:
[0024] Performing denoising on the apple image to be detected to obtain a denoised apple image;
[0025] Performing image enhancement processing on the denoised apple image to obtain an enhanced apple image to be detected;
[0026] The enhanced apple image to be detected is used as the apple image to be detected.
[0027] In one embodiment, before the step of dividing the historical apple images into a training set and a validation set and training the initial detection model, the step further includes:
[0028] Marking the maturity of the historical apple images respectively to obtain the marked data of the historical apple images;
[0029] A corresponding label file is generated based on the annotated data, and based on the label file, the historical apple images are divided into a training set and a validation set to train an initial detection model.
[0030] In addition, to achieve the above purpose, the present application also proposes an apple maturity detection device, the device comprising:
[0031] An image acquisition module, used to acquire historical apple images and apple images to be detected;
[0032] A model building module, used for dividing the historical apple images into a training set and a validation set, training the initial detection model, and obtaining a target detection model, wherein the target detection model includes a convolution layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer;
[0033] The image processing module is used to process the apple image to be detected through the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain an apple maturity detection result.
[0034] A deployment module is used to determine the target individual position and the target network coverage based on the optimal network coverage updated each time, and to establish a target apple maturity detection map based on the target network coverage.
[0035] In addition, to achieve the above-mentioned purpose, the present application also proposes an apple maturity detection device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the apple maturity detection method described above.
[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the apple maturity detection method described above are implemented.
[0037] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the apple maturity detection method described above are implemented.
[0038] One or more technical solutions proposed in this application have at least the following technical effects:
[0039] Obtain historical apple images and apple images to be detected; divide the historical apple images into a training set and a validation set, train the initial detection model, and obtain a target detection model, wherein the target detection model includes a convolutional layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer; process the apple images to be detected through the convolutional layer, the cross-stage feature fusion layer, and the spatial pyramid pooling layer in the target detection model to obtain an apple maturity detection result with high real-time and high-precision detection capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 A schematic diagram of a process flow provided for Example 1 of the apple maturity detection method of the present application;
[0043] Figure 2 A schematic diagram of a process flow provided for Example 2 of the apple maturity detection method of the present application;
[0044] Figure 3 A diagram of the spatial pyramid pooling layer structure provided for the second embodiment of the apple maturity detection method of the present application;
[0045] Figure 4 A schematic diagram of the process provided for Example 3 of the apple maturity detection method of the present application;
[0046] Figure 5 A structural diagram of a neural network attention mechanism provided in Example 3 of the apple maturity detection method of this application;
[0047] Figure 6 This is a schematic diagram of the module structure of the apple maturity detection device according to the embodiment of the present application;
[0048] Figure 7Schematic diagram of the device structure of the hardware operating environment involved in the apple maturity detection method in the embodiment of the present application.
[0049] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0051] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0052] This application proposes an improved YOLOv8 algorithm detection method to address the problem of low accuracy in detecting apple maturity. The algorithm adds an attention mechanism to the neural network structure and improves the SPPF structure by adding a pooling layer. The improved algorithm can improve the recognition accuracy.
[0053] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, an apple maturity detection device, etc. The following takes the apple maturity detection device as an example to illustrate this embodiment and the following embodiments.
[0054] Based on this, the present application embodiment provides a method for detecting apple maturity, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the apple maturity detection device method of the present application.
[0055] In this embodiment, the apple maturity detection device method includes steps S10 to S30:
[0056] Step S10, obtaining historical apple images and apple images to be detected;
[0057] In the specific implementation, a high-definition camera is used to capture images of the apple to be inspected.
[0058] The camera should be fixed in a stable position to ensure a consistent shooting angle, collect images of apples at different maturity levels and in different environments, and ensure data diversity. At this time, the images of apples to be tested are collected, and historical apple images are obtained from the image library of previously tested apples.
[0059] Furthermore, after step S10, the method further includes:
[0060] Perform denoising on the apple image to be detected to obtain a denoised apple image;
[0061] Performing image enhancement processing on the denoised apple image to obtain an enhanced apple image to be detected;
[0062] The enhanced apple image to be detected is used as the apple image to be detected.
[0063] In the specific implementation, OpenCV is used to preprocess the acquired images, including:
[0064] Denoising: Use filters to remove noise from an image.
[0065] Image Enhancement: Adjust contrast and brightness to improve image clarity.
[0066] Store the preprocessed images in a specified folder for later processing.
[0067] It should be noted that the basic network structure adopted by this strategy first includes standard convolutional layers, activation functions (such as ReLU or Leaky ReLU) and pooling operations. This part is used to build the basis for feature extraction. Then replace the C3 module in YOLOv8, use the new C2F structure, adopt the idea of ELAN (Efficient Layer Aggregation Network), and improve the efficiency of gradient propagation by cross-stage partial fusion. In the implementation process, it is necessary to ensure that the C2F layer can effectively reduce information loss, and enhance the network's expression ability while maintaining the model's computational complexity, and adjust the hyperparameters of each layer in the model (such as convolution kernel size, step size, padding method, etc.) to optimize the role of the C2F layer on different feature maps; Neck adopts a structure that combines FPN (feature pyramid network) and PAN (path aggregation network). The features of adjacent layers are connected as the input of the C2F module; when the features are passed from top to bottom, they are combined with the high-level semantic features of the underlying features.
[0068] In order to reduce the impact of background on apple features during apple detection, the CBAM attention mechanism is added to make the model focus on specific regions of interest in the image, reduce the interference of background in the image, and improve the feature expression ability.
[0069] In the last part, the SPPF layer design in YOLOv8 is retained. The SPPF layer generates outputs with multi-scale features through multi-level maximum pooling operations, enabling the model to effectively detect targets at different scales. Try to increase or decrease the number of pooling layers, or adjust the size of the pooling window to find the best receptive field and feature fusion method. Then integrate the convolution layer, C2F layer, and SPPF layer into the backbone network to form a complete YOLOv8 backbone structure, and perform forward propagation tests to ensure that the data flow between modules is smooth and correct, and all feature extraction processes can be effectively executed.
[0070] Step S20, dividing the historical apple images into a training set and a validation set, training the initial detection model, and obtaining a target detection model, wherein the target detection model includes a convolutional layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer;
[0071] It should be noted that the method proposed in this strategy is implemented using the YOLOv8 model algorithm, and the backbone consists of three parts: convolutional layer, C2F layer, and SPPF layer. The cross-stage feature fusion layer, namely C2F, has a structure different from the C3 module in YOLOv8. It adopts a structure that combines FPN (feature pyramid network) and PAN (path aggregation network). The features of adjacent layers are connected as the input of the C2F module. When the features are passed from top to bottom, they are combined with the high-level semantic features of the underlying features. The spatial pyramid pooling layer, namely SPPF (spatial pyramid pooling fusion), is a spatial pyramid pooling fusion technology used for image classification and target detection tasks, which can effectively capture information of different scales in the image.
[0072] It should be understood that the convolution layer is used to extract deep features of the image and provide a basis for subsequent target recognition. The cross-stage feature fusion layer is a network structure that extracts information from feature maps of different resolutions and fuses the information. The spatial pyramid pooling layer contains spatial pyramid pooling fusion technology for image classification and target detection tasks, which can effectively capture information of different scales in the image.
[0073] In the specific implementation, the collected historical apple images are divided into training sets and validation sets; the YOLOv8 model is used for training, and the preprocessed images and label files are loaded; the YOLOv8 model parameters are configured, including learning rate, batch size, etc.; the model training is started, and the loss value and accuracy rate during the training process are monitored; the model is tested on the validation set, and the parameters are adjusted to optimize the performance.
[0074] Furthermore, before step S20, the method further includes:
[0075] The historical apple images are labeled with maturity levels to obtain the labeled data of the historical apple images;
[0076] A corresponding label file is generated based on the annotated data, and the historical apple images are divided into a training set and a validation set based on the label file to train the initial detection model.
[0077] In the specific implementation, an annotation tool is used to annotate the apples in the image, record the maturity of each apple, store the annotated data in YOLO format, and generate the corresponding label file.
[0078] Step S30, processing the apple image to be detected through the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain the apple maturity detection result.
[0079] In the specific implementation, the image of the apple to be tested is input into the trained model to detect the maturity of the apple; according to the output of the model, the apples are classified, the accuracy of the classification results is statistically analyzed, the cause of the error is analyzed, and the experimental data is recorded.
[0080] Based on the experimental results, the system is optimized, data is recollected and the experiment is repeated to ensure the stability and accuracy of the system.
[0081] The present embodiment provides an apple maturity detection method, which obtains historical apple images and apple images to be detected; divides the historical apple images into a training set and a validation set, trains an initial detection model, and obtains a target detection model, wherein the target detection model includes a convolution layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer; processes the apple images to be detected through the convolution layer, the cross-stage feature fusion layer, and the spatial pyramid pooling layer in the target detection model to obtain an apple maturity detection result, integrates the convolution layer, the C2F layer, and the SPPF layer into the backbone network to form a complete YOLOv8 backbone structure, and performs a forward propagation test to ensure that the data flow between the modules is smooth and correct, and all feature extraction processes can be effectively executed, with high real-time and high-precision detection capabilities.
[0082] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 , step S30, the apple maturity detection method further includes steps S301 to S303:
[0083] Step S301, extracting local features of the apple image to be detected through the convolutional layer in the object detection model to obtain a feature map;
[0084] It should be noted that the convolution layer slides the convolution kernel on the input image through the convolution operation, calculates the dot product between the convolution kernel and the local area of the image, obtains a pixel value of the feature map, and repeats this process at each position of the image until the entire image is covered. Useful local features are extracted from the apple image and encoded into the feature map.
[0085] In the specific implementation, the input feature map is obtained through a convolutional neural network (CNN).
[0086] Step S302, processing the feature map through a cross-stage feature fusion layer to obtain an enhanced feature map;
[0087] It should be noted that the cross-stage feature fusion layer is a network structure that can extract information from feature maps of different resolutions and fuse them together, thereby improving the efficiency of gradient propagation by partial cross-stage fusion.
[0088] Furthermore, the step S302 includes:
[0089] The feature map is transformed, branched and fused through the cross-stage feature fusion layer to obtain an enhanced feature map.
[0090] In the specific implementation, the input features are transformed through the convolution layer to extract richer feature representations; different features are processed independently through the branch structure to increase the nonlinearity of the network; the processed features are spliced in the channel dimension to integrate multi-branch information and enhance feature expressiveness.
[0091] Step S303, processing the enhanced feature map through a spatial pyramid pooling layer to obtain a target feature image, and generating an apple maturity detection result based on the target feature image.
[0092] like Figure 3 As shown, Figure 3 The figure is a diagram of the spatial pyramid pooling layer structure, where CBS includes Conv convolution, normalized BN and SiLU activation functions, MaxPool is the maximum pooling operation, concat is the feature fusion operation, and the SPPF layer generates outputs with multi-scale features through multi-level maximum pooling operations, enabling the model to effectively detect targets at different scales. Try to increase or decrease the number of pooling layers, or adjust the size of the pooling window to find the best receptive field and feature fusion method.
[0093] It should be noted that by using spatial pyramid pooling, feature extraction and pooling operations are performed on image sub-regions of different scales to generate feature representations with multi-scale information. This multi-scale representation allows the model to better adapt to targets of different scales and improve robustness to scale changes. At the same time, by performing pooling operations at different spatial levels, SPPF is also able to maintain a certain degree of variability to improve the model's ability to perceive target deformation and posture changes. It converts variable-length feature vectors into fixed-length feature representations through pooling operations on sub-regions. In this way, SPPF not only reduces the number of parameters of the model, but also reduces the computational complexity and improves the computational efficiency of the model.
[0094] In the specific implementation, the input feature maps are obtained from the convolutional neural network (CNN) of the previous layer, and these feature maps are processed at multiple scales to capture the diverse spatial information in the apple image.
[0095] Furthermore, the step S303 includes:
[0096] The enhanced feature map is subjected to multi-scale pooling through the spatial pyramid pooling layer to obtain the global scale feature, semi-local scale feature, and local scale feature of the apple image to be detected;
[0097] The global scale features, semi-local scale features and local scale features are fused to obtain the target feature image.
[0098] It should be noted that the pooling layer performs pooling operations at different scales. The pooling type is maximum pooling, and the pooling levels include 1x1, 3x3, 5x5, etc. For feature maps, pooling layers of different sizes and strides are used.
[0099] This strategy uses SPPF to effectively capture information of different scales in the image. By using spatial pyramid pooling, feature extraction and pooling operations are performed on image sub-regions of different scales to generate feature representations with multi-scale information.
[0100] In the specific implementation, the results of all pooling operations are collected. These feature maps represent the input features at different spatial resolutions, including global scale features, semi-local scale features, and local scale features; the pooled feature maps are then stacked or connected along the depth dimension to form a multi-scale representation, where multi-scale feature fusion can be connecting the pooled feature maps to form a comprehensive feature representation or applying additional convolutional layers to fuse the connected feature maps.
[0101] This embodiment provides an apple maturity detection method, which uses spatial pyramid pooling to perform feature extraction and pooling operations on image sub-regions of different scales to generate feature representations with multi-scale information; this multi-scale representation allows the model to better adapt to targets of different scales and improves robustness to scale changes; by performing pooling operations at different spatial levels, SPPF can capture features of global, semi-local and local scales, enabling the model to better understand the spatial structure and contextual relationship of targets at different scales; the pooling operation enables SPPF to perform invariant transformations on input features, and this strategy increases the SPPF structure to the maximum pooling of the 4th layer; at the same time, by performing pooling operations at different spatial levels, SPPF can also maintain a certain degree of variability to improve the model's ability to perceive target deformation and posture changes. It converts variable-length feature vectors into fixed-length feature representations through pooling operations on sub-regions; in this way, SPPF not only reduces the number of parameters of the model, but also reduces the computational complexity and improves the computational efficiency of the model.
[0102] Based on the first and second embodiments of the present application, in the third embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction, and will not be described in detail later. Figure 4 After step S301, the apple maturity detection method further includes steps S3011 to S3012:
[0103] Step S3011, processing the feature map through the channel attention mechanism and the spatial attention mechanism of the neural network attention mechanism to obtain an attention enhanced feature map;
[0104] It should be noted that in order to reduce the impact of background on apple features during apple detection, the CBAM attention mechanism, i.e., the neural network attention mechanism, is added to enable the model to focus on specific areas of interest in the image, reduce the interference of the background in the image, and improve the feature expression ability.
[0105] like Figure 5 As shown, Figure 5 This is the structure diagram of the neural network attention mechanism, which mainly includes two parts, namely CAM (Channel Attention Module) channel attention mechanism and SAM (Spatial Attention Module) spatial attention mechanism. CBAM will process the input image with the channel attention mechanism and the spatial attention mechanism respectively. The two modules are connected in series as shown in the figure above. The input image (Input Feature) is first processed by the channel attention mechanism and then by the spatial attention mechanism. Finally, the channel weight is formed and multiplied with the input image to obtain the final image feature map (Refined Feature).
[0106] In the specific implementation, an attention mechanism such as CBAM (Convolutional Block Attention Module) is integrated to enhance important features and suppress irrelevant features, where the channel attention mechanism is used to focus on significant channels and the spatial attention mechanism is used to focus on significant spatial locations.
[0107] Step S3012, performing feature conversion, branch processing and feature fusion on the feature map through a cross-stage feature fusion layer to obtain an enhanced feature map, also includes:
[0108] The attention enhanced feature map is subjected to feature transformation, branch processing and feature fusion through a cross-stage feature fusion layer to obtain an enhanced feature map.
[0109] In the specific implementation, the attention enhanced feature map is transformed through the convolution layer to extract richer feature representation; different features are processed independently through the branch structure to increase the nonlinearity of the network; the processed features are spliced in the channel dimension to integrate multi-branch information and enhance feature expression. These enhanced features will be passed to subsequent layers for further processing and ultimately used for apple image detection.
[0110] This embodiment provides an apple maturity detection method. In order to reduce the impact of the background on apple features during apple detection, a CBAM attention mechanism is added to enable the model to focus on specific regions of interest in the image, reduce the interference of the background in the image, and improve the feature expression capability.
[0111] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the apple maturity detection method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0112] This application also provides an apple maturity detection device, please refer to Figure 6 , the apple maturity detection device comprises:
[0113] An image acquisition module 10, used to acquire historical apple images and apple images to be detected;
[0114] A model building module 20 is used to divide the historical apple images into a training set and a validation set, train the initial detection model, and obtain a target detection model, wherein the target detection model includes a convolution layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer;
[0115] The image processing module 30 is used to process the apple image to be detected through the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain the apple maturity detection result.
[0116] The apple maturity detection device provided by the present application adopts the apple maturity detection method in the above embodiment, which can solve the technical problem of low detection accuracy of the existing apple maturity detection technology. Compared with the prior art, the beneficial effects of the apple maturity detection device provided by the present application are the same as the beneficial effects of the apple maturity detection method provided by the above embodiment, and the other technical features of the apple maturity detection device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0117] The present application provides an apple maturity detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the apple maturity detection method in the above-mentioned embodiment one.
[0118] Reference below Figure 7 , which shows a schematic diagram of the structure of an apple maturity detection device suitable for implementing the embodiment of the present application. The apple maturity detection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The apple maturity detection device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0119] like Figure 7As shown, the apple maturity detection device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM) 1004. In RAM 1004, various programs and data required for the operation of the apple maturity detection device are also stored. The processing device 1001, ROM 1002, and RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the apple maturity detection device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an apple maturity detection device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0120] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0121] The apple maturity detection device provided by the present application adopts the apple maturity detection method in the above embodiment, which can solve the technical problem of low detection accuracy of the existing apple maturity detection technology. Compared with the prior art, the beneficial effects of the apple maturity detection device provided by the present application are the same as the beneficial effects of the apple maturity detection device method provided by the above embodiment, and the other technical features of the apple maturity detection device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0122] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0123] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0124] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the apple maturity detection method in the above-mentioned embodiment.
[0125] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0126] The computer-readable storage medium may be included in the apple maturity detection device; or may exist independently without being assembled into the apple maturity detection device.
[0127] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the apple maturity detection device, the apple maturity detection device enables the apple maturity detection device to: obtain historical apple images and apple images to be detected; divide the historical apple images into a training set and a verification set, train the initial detection model, and obtain a target detection model, wherein the target detection model includes a convolution layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer; process the apple image to be detected through the convolution layer, the cross-stage feature fusion layer, and the spatial pyramid pooling layer in the target detection model to obtain an apple maturity detection result.
[0128] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0129] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0130] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0131] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned apple maturity detection method, and can solve the technical problem of low detection accuracy of existing apple maturity detection technology. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the apple maturity detection method provided in the above-mentioned embodiment, and will not be elaborated here.
[0132] The present application also provides a computer program product, comprising a computer program, which implements the steps of the above-mentioned apple maturity detection method when executed by a processor.
[0133] The computer program product provided by the present application can solve the technical problem of low detection accuracy of the existing apple maturity detection technology. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the apple maturity detection method provided by the above embodiment, which will not be repeated here.
[0134] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for detecting apple maturity, characterized in that: The apple maturity detection method comprises: Obtain historical apple images and apple images to be detected; Dividing the historical apple images into a training set and a validation set, training the initial detection model, and obtaining a target detection model, wherein the target detection model includes a convolution layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer; The apple image to be detected is processed by the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain an apple maturity detection result.
2. The apple maturity detection method according to claim 1, characterized in that: The step of processing the apple image to be detected by the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain the apple maturity detection result includes: Extracting local features of the to-be-detected apple image through the convolutional layer in the target detection model to obtain a feature map; Processing the feature map through the cross-stage feature fusion layer to obtain an enhanced feature map; The enhanced feature map is processed by the spatial pyramid pooling layer to obtain a target feature image, and an apple maturity detection result is generated based on the target feature image.
3. The apple maturity detection method according to claim 2, characterized in that: The step of processing the enhanced feature map through the spatial pyramid pooling layer to obtain a target feature image includes: Performing multi-scale pooling on the enhanced feature map through the spatial pyramid pooling layer to obtain global scale features, semi-local scale features, and local scale features of the apple image to be detected; The global scale feature, the semi-local scale feature and the local scale feature are fused to obtain a target feature image.
4. The apple maturity detection method according to claim 2, characterized in that: The step of processing the feature map through the cross-stage feature fusion layer to obtain an enhanced feature map includes: The feature map is subjected to feature conversion, branch processing and feature fusion through the cross-stage feature fusion layer to obtain an enhanced feature map.
5. The method for detecting apple maturity as claimed in claim 2, characterized in that: After the step of extracting the local features of the apple image to be detected through the convolutional layer in the target detection model to obtain a feature map, the method further includes: Processing the feature map through a channel attention mechanism and a spatial attention mechanism of a neural network attention mechanism to obtain an attention-enhanced feature map; The step of performing feature conversion, branch processing and feature fusion on the feature map through the cross-stage feature fusion layer to obtain an enhanced feature map also includes: The attention enhanced feature map is subjected to feature conversion, branch processing and feature fusion through the cross-stage feature fusion layer to obtain an enhanced feature map.
6. The apple maturity detection method according to claim 1, characterized in that: After the step of obtaining the apple image to be detected, the method further includes: Performing denoising on the apple image to be detected to obtain a denoised apple image; Performing image enhancement processing on the denoised apple image to obtain an enhanced apple image to be detected; The enhanced apple image to be detected is used as the apple image to be detected.
7. The method for detecting apple maturity as claimed in claim 1, characterized in that: Before the step of dividing the historical apple images into a training set and a validation set and training the initial detection model, the method further includes: Marking the maturity of the historical apple images respectively to obtain the marked data of the historical apple images; A corresponding label file is generated based on the annotated data, and based on the label file, the historical apple images are divided into a training set and a validation set to train an initial detection model.
8. An apple maturity detection device, characterized in that: The device comprises: An image acquisition module, used to acquire historical apple images and apple images to be detected; A model building module, used for dividing the historical apple images into a training set and a validation set, training the initial detection model, and obtaining a target detection model, wherein the target detection model includes a convolution layer, a cross-stage feature fusion layer, and a spatial pyramid pooling layer; The image processing module is used to process the apple image to be detected through the convolution layer, the cross-stage feature fusion layer and the spatial pyramid pooling layer in the target detection model to obtain an apple maturity detection result.
9. An apple maturity detection device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the apple maturity detection method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the apple maturity detection method according to any one of claims 1 to 7 are implemented.
