Fruit quality detection method, device, equipment and medium
By designing an asymmetric fruit quality detection model consisting of 4 encoders, 2 convolutional networks, 3 decoders and a bilinear convolutional layer, the problems of low detection accuracy and efficiency in the existing technology are solved, and efficient detection of small fruit targets is achieved, which is suitable for high-precision and real-time industrial detection.
Patent Information
- Application Number
- CN202510539773.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-09-05
AI Technical Summary
Existing fruit quality detection algorithms rely on computer vision and machine learning technologies, but suffer from low detection accuracy and efficiency, especially poor detection effects on small targets, and cannot be applied on low-performance chips.
A fruit quality detection model consisting of 4 encoders, 2 convolutional networks, 3 decoders and bilinear convolutional layers is adopted. Each encoder contains an attention module, and each decoder contains a depthwise separable convolutional layer. The asymmetric structure design is used to compress redundant information, enhance the weight of key areas, suppress background interference, and reduce the amount of computation.
It improves the accuracy and efficiency of fruit quality detection, is suitable for high-precision and real-time industrial detection scenarios, and can achieve efficient calculation and detail recovery with a small number of training images.
Smart Images

Figure CN120599599A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology and provides a fruit quality detection method, device, equipment and medium. Background Art
[0002] As we all know, fruits entering the market are graded according to standards such as size, color and shape to improve the market competitiveness of the products. As the market has strict requirements on fruit quality, the subdivision of fruit quality is becoming more and more strict, which also poses new challenges to the detection algorithm.
[0003] However, existing fruit quality detection algorithms mainly rely on computer vision and machine learning technologies. When performing image acquisition, they need to use high-resolution cameras under good lighting conditions to obtain qualified images. When performing image annotation, at least 1,000 images need to be annotated to achieve the fruit quality detection effect. Therefore, the current fruit quality detection model often has the following problems: (1) It is completely dependent on data. If the data is insufficient, the fruit quality detection effect is poor; (2) The detection accuracy of small targets is low; (3) The detection efficiency of small targets is low, and it cannot be applied to low-performance chips.
[0004] Therefore, how to improve the accuracy and efficiency of fruit quality detection has become an urgent problem to be solved. Summary of the Invention
[0005] The present application provides a fruit quality detection method, device, equipment and medium, which are used to solve the technical problems of low detection accuracy and efficiency in existing fruit quality detection algorithms.
[0006] In one aspect, a method for detecting fruit quality is provided, comprising:
[0007] Capturing images of target fruits to obtain captured images;
[0008] Inputting the collected image into a trained fruit quality detection model to obtain a detection result; wherein the trained fruit quality detection model is composed of 4 encoders, 2 convolutional networks, 3 decoders and a bilinear convolutional layer, and each encoder includes an attention module, and each decoder includes a depthwise separable convolutional layer;
[0009] According to the detection result, it is determined whether the target fruit has defects.
[0010] Optionally, the step of inputting the collected image into a trained fruit quality detection model to obtain a detection result includes:
[0011] Inputting the collected image into a first encoder, a second encoder, a third encoder, and a fourth encoder of a trained fruit quality detection model in sequence to obtain a first eigenvector, a second eigenvector, a third eigenvector, and a fourth eigenvector;
[0012] Inputting the fourth eigenvector into a first decoder of a trained fruit quality detection model to obtain a first feature map;
[0013] The first convolutional feature vector obtained by processing the third feature vector using the first convolutional network of the trained fruit quality detection model is compared with the first feature vector. Figure 1 Input the second decoder to obtain a second feature map;
[0014] The second convolutional feature vector obtained by processing the second feature vector with the second convolutional network of the trained fruit quality detection model is compared with the second feature vector. Figure 1 Input the third decoder of the trained fruit quality detection model to obtain a third feature map;
[0015] Inputting the third feature map into the bilinear convolution layer of the trained fruit quality detection model to obtain the third feature map;
[0016] The third feature map is input into the prediction head of the trained fruit quality detection model to obtain a detection result.
[0017] Optionally, each encoder includes a fully convolutional neural network (FCN), a normalization layer, an attention module, a normalization layer, and a multi-layer perceptron (MLP) network connected in sequence.
[0018] Optionally, each convolutional network includes a convolution layer Conv, a split operation layer, a convolution layer Conv, a convolution layer Conv, an add operation layer, a concat operation layer, and a convolution layer Conv, which are connected in sequence.
[0019] Optionally, each decoder contains a convolutional layer Conv, three 3×3 depth-wise separable convolutional layers, and an upsampling layer connected in sequence.
[0020] Optionally, before inputting the collected image into a trained fruit quality detection model to obtain a detection result, the method further includes:
[0021] Use image acquisition equipment to capture images of various fruits and obtain multiple original defect images;
[0022] The plurality of original defect images are obtained according to a preset ratio to obtain a training set, a test set and a validation set;
[0023] The training set, test set and validation set are used to train the original fruit quality detection model to obtain a trained fruit quality detection model.
[0024] Optionally, the step of obtaining a training set, a test set, and a validation set from the plurality of original defect images according to a preset ratio includes:
[0025] Performing geometric transformation and color transformation on the plurality of original defect images to obtain a plurality of pre-processed defect images; wherein the geometric transformation includes flipping, rotating, cropping, deforming and scaling; and the color transformation includes blurring, erasing, filling and brightness enhancement;
[0026] The plurality of pre-processed defect images are used in a preset ratio to obtain a training set, a test set and a validation set.
[0027] In one aspect, a fruit quality detection device is provided, comprising:
[0028] An image acquisition unit is used to acquire images of target fruits and obtain acquired images;
[0029] A quality detection unit is used to input the collected image into a trained fruit quality detection model to obtain a detection result; wherein the trained fruit quality detection model is composed of 4 encoders, 2 convolutional networks, 3 decoders and a bilinear convolutional layer, and each encoder includes an attention module, and each decoder includes a depthwise separable convolutional layer;
[0030] A defect determination unit is used to determine whether the target fruit has defects based on the detection result.
[0031] On the one hand, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any one of the above methods when executing the computer program.
[0032] In one aspect, a storage medium is provided, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, any of the above methods is implemented.
[0033] Compared with the prior art, the present invention has the following advantages:
[0034] In the present application, when performing fruit quality inspection, first, the target fruit can be imaged to obtain an image; then, the image can be input into a trained fruit quality inspection model to obtain the inspection result; wherein, the trained fruit quality inspection model is composed of 4 encoders, 2 convolutional networks, 3 decoders and a bilinear convolution layer, and each encoder includes an attention module, and each decoder includes a depth-separable convolution layer; finally, the inspection result can be used to determine whether the target fruit has defects.
[0035] It can be seen that in the present application, since the trained fruit quality detection model is generated based on the asymmetric structure of 4 encoders and 3 decoders, compared with the prior art, the present application can not only efficiently compress redundant information by setting the number of encoders to be greater than the number of decoders to reduce the amount of computational complexity of subsequent processing, but also achieve a balance between computing resources and model performance through this hierarchical asymmetric design, so as to further improve the detection accuracy and efficiency of fruits (small targets) under the premise of a small number of training images. Therefore, the present application is more suitable for industrial detection scenarios that require high precision and real-time performance.
[0036] Moreover, since each encoder includes an attention module, the present application can dynamically enhance the weights of key areas of the fruit (such as damaged and discolored areas), thereby suppressing background interference. In addition, since each decoder also includes a depth-separable convolution layer, the present application can also reduce the amount of computation through a lightweight design such as depth-separable convolution. In addition, since the trained fruit quality detection model is also provided with a bilinear convolution layer (convolution layer Conv + bilinear interpolation upsampling Bilinear), the present application can improve detail recovery capabilities while ensuring computational efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0038] Figure 1 An electronic device provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of a fruit quality detection method provided in an embodiment of the present application;
[0040] Figure 3 A structural diagram of a trained fruit quality detection model provided in an embodiment of the present application;
[0041] Figure 4 A schematic diagram of the structure of an encoder provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of the structure of a convolutional network provided in an embodiment of the present application;
[0043] Figure 6 A schematic diagram of the structure of a decoder provided in an embodiment of the present application;
[0044] Figure 7 A schematic diagram of a fruit quality detection device provided in an embodiment of the present application.
[0045] Markings in the figure: 10-fruit quality detection equipment, 101-processor, 102-memory, 103-I / O interface, 104-database, 70-fruit quality detection device, 701-image acquisition unit, 702-quality detection unit, 703-defect determination unit, 704-model training unit. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other in any way. In addition, although a logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0047] As we all know, fruits entering the market are graded according to standards such as size, color and shape to improve the market competitiveness of the products. As the market has strict requirements on fruit quality, the subdivision of fruit quality is becoming more and more strict, which also poses new challenges to the detection algorithm.
[0048] However, existing fruit quality detection algorithms mainly rely on computer vision and machine learning technologies. When performing image acquisition, they need to use high-resolution cameras under good lighting conditions to obtain qualified images. When performing image annotation, at least 1,000 images need to be annotated to achieve the fruit quality detection effect. Therefore, the current fruit quality detection model often has the following problems: (1) It is completely dependent on data. If the data is insufficient, the fruit quality detection effect is poor; (2) The detection accuracy of small targets is low; (3) The detection efficiency of small targets is low, and it cannot be applied to low-performance chips.
[0049] Based on this, an embodiment of the present application provides a fruit quality detection method, in which, first, an image of the target fruit can be captured to obtain a captured image; then, the captured image can be input into a trained fruit quality detection model to obtain a detection result; wherein the trained fruit quality detection model consists of 4 encoders, 2 convolutional networks, 3 decoders, and a bilinear convolutional layer, and each encoder includes an attention module, and each decoder includes a depthwise separable convolutional layer; finally, the target fruit can be determined based on the detection result to determine whether it has defects. It can be seen that in the present application, since the trained fruit quality detection model is generated based on the asymmetric structure of 4 encoders and 3 decoders, compared with the prior art, the present application can not only efficiently compress redundant information by setting the number of encoders to be greater than the number of decoders to reduce the computational complexity of subsequent processing, but also achieve a balance between computing resources and model performance through this hierarchical asymmetric design, so as to further improve the detection accuracy and efficiency of fruit (small targets) under the premise of a small number of training images. Therefore, the present application is more suitable for industrial detection scenarios that require high precision and real-time performance. Moreover, since each encoder includes an attention module, the present application can dynamically enhance the weights of key areas of the fruit (such as damaged and discolored areas), thereby suppressing background interference. In addition, since each decoder also includes a depth-separable convolution layer, the present application can also reduce the amount of computation through a lightweight design such as depth-separable convolution. In addition, since the trained fruit quality detection model is also provided with a bilinear convolution layer (convolution layer Conv + bilinear interpolation upsampling Bilinear), the present application can improve detail recovery capabilities while ensuring computational efficiency.
[0050] After introducing the design concepts of the embodiments of the present application, the following briefly introduces the application scenarios to which the technical solutions of the embodiments of the present application can be applied. It should be noted that the application scenarios introduced below are only used to illustrate the embodiments of the present application and are not limiting. In the specific implementation process, the technical solutions provided by the embodiments of the present application can be flexibly applied according to actual needs.
[0051] like Figure 1 As shown, an electronic device provided in an embodiment of the present application is shown, and the electronic device may specifically be a fruit quality detection device 10.
[0052] The fruit quality inspection device 10 can perform quality inspection on small objects such as fruit. For example, it can be a personal computer (PC), a server, or a laptop. The fruit quality inspection device 10 may include one or more processors 101, a memory 102, an I / O interface 103, and a database 104. Specifically, the processor 101 may be a central processing unit (CPU) or a digital processing unit (DPU). The memory 102 may be a volatile memory, such as a random-access memory (RAM); a non-volatile memory, such as a read-only memory, flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited to these. The memory 102 may be a combination of the above-mentioned memories. Memory 102 can store some program instructions for the fruit quality detection method provided in the embodiments of the present application. When executed by processor 101, these program instructions can be used to implement the steps of the fruit quality detection method provided in the embodiments of the present application, thereby addressing the technical issues of low detection accuracy and efficiency of existing fruit quality detection algorithms. Database 104 can be used to store data such as the original fruit quality detection model, trained fruit quality detection models, multiple original defect images, training sets, test sets, and validation sets involved in the solutions provided in the embodiments of the present application.
[0053] In the embodiment of the present application, the fruit quality inspection device 10 can obtain fruit quality inspection instructions through the I / O interface 103. Then, the processor 101 of the fruit quality inspection device 10 will improve the accuracy and efficiency of fruit quality inspection according to the code instructions of the fruit quality inspection method provided in the embodiment of the present application stored in the memory 102. In addition, data such as the original fruit quality inspection model, the trained fruit quality inspection model, multiple original defect images, training sets, test sets, and validation sets can also be stored in the database 104.
[0054] Of course, the method provided in the embodiment of the present application is not limited to Figure 1 The application scenarios shown can also be used in other possible application scenarios, and the embodiments of this application are not limited thereto. Figure 1The functions that can be realized by each device in the application scenario shown will be described in the subsequent method embodiments, and will not be described in detail here.
[0055] like Figure 2 FIG. 1 is a schematic diagram of a fruit quality detection method provided by an embodiment of the present application. The method can be performed by Figure 1 The fruit quality detection device 10 is used to perform the above steps. Specifically, the process of the method is described as follows.
[0056] Step 201: Capture images of target fruits to obtain captured images.
[0057] Specifically, industrial-grade image acquisition equipment such as a high-resolution RGB camera can be used to capture images of the target fruit to obtain captured images.
[0058] Step 202: Input the collected image into the trained fruit quality detection model to obtain the detection result.
[0059] In the embodiments of this application, Figure 3 As shown, a structural diagram of a trained fruit quality detection model provided in an embodiment of the present application is shown. The trained fruit quality detection model can be composed of 4 encoders, 2 convolutional networks, 3 decoders and a bilinear convolution layer (Conv+Bilinear), and each encoder includes an attention module, and each decoder includes a depth-separable convolution layer.
[0060] Specifically, first, the collected image can be sequentially input into the first encoder, the second encoder, the third encoder and the fourth encoder of the trained fruit quality detection model to obtain the first eigenvector, the second eigenvector, the third eigenvector and the fourth eigenvector; then, the fourth eigenvector can be input into the first decoder of the trained fruit quality detection model to obtain the first feature map; next, the first convolution feature vector obtained by processing the third eigenvector using the first convolution network of the trained fruit quality detection model can be combined with the first feature map. Figure 1 Then, the second convolution feature vector obtained by processing the second feature vector using the second convolution network of the trained fruit quality detection model can be combined with the second feature map. Figure 1 The third feature map can be input into the third decoder of the trained fruit quality detection model to obtain the third feature map; next, the third feature map can be input into the bilinear convolution layer of the trained fruit quality detection model to obtain the third feature map; finally, the third feature map can be input into the prediction head of the trained fruit quality detection model to obtain the detection result.
[0061] Step 203: Determine whether the target fruit has defects based on the detection results.
[0062] In the embodiment of the present application, defects may include color abnormality, surface scratches, surface mildew, surface decay, and shape distortion.
[0063] In one possible implementation, Figure 4 As shown, it is a structural diagram of the encoder provided in an embodiment of the present application. Each encoder includes a fully convolutional neural network FCN, a normalization layer, an attention module, a normalization layer and a multi-layer perceptron MLP network connected in sequence.
[0064] Among them, the attention module can be specifically an SE module to calculate the global correlation of each channel and adjust the channel weight to focus on important semantic information. In an embodiment of the present application, the channels of each encoder encoder level increase in sequence (96→192→384→768). For example, the number of channels output by encoder_1 is 96×80×128, the number of channels output by encoder_2 is 192×40×64, the number of channels output by encoder_3 is 384×20×32, and the number of channels output by encoder_4 is 768×10×16. Based on this, it can be ensured that multi-scale features are retained and spatial information is not lost.
[0065] In one possible implementation, Figure 5 As shown, it is a structural diagram of the convolutional network provided in an embodiment of the present application. Each convolutional network includes a convolutional layer Conv, a split operation layer, a convolutional layer Conv, a convolutional layer Conv, an add operation layer, a concat operation layer and a convolutional layer Conv connected in sequence.
[0066] The convolutional network C4 is mainly composed of four convolutional layers, which can reduce the number of channels (the number of channels is reduced by 2 times) and increase the feature extraction capability. For example, the number of channels of the output of encoder_3 is 384×20×32. After passing through the first convolutional network C4, the number of channels of the output becomes 192×20×32.
[0067] The number of channels output by encoder_2 is 192×40×64. After passing through the second convolutional network C4, the number of channels output becomes 96×40×64.
[0068] In one possible implementation, Figure 6Figure 1 shows a schematic diagram of the decoder structure provided by an embodiment of the present application. Each decoder includes a sequentially connected convolution layer Conv, three 3×3 depthwise separable convolution layers (DSC), and an upsampling layer. Therefore, in this application, decoding can be used to reduce the number of channels to achieve the purpose of restoring the original acquired image mask size and reducing the amount of computation.
[0069] In one possible implementation, an activation function, sigmoid(1.702*x)*x, can be used to adjust model parameters to balance model nonlinearity and gradient stability. Therefore, in this application, a fixed scaling factor can be used to balance dynamic gating and computational efficiency, further improving the accuracy and efficiency of fruit quality detection.
[0070] In a possible implementation, before inputting the captured image into the trained fruit quality detection model and obtaining the detection result, the original fruit quality detection model may be trained.
[0071] Specifically, first, image acquisition equipment can be used to capture images of various fruits to obtain multiple original defect images; then, the multiple original defect images can be arranged in a preset ratio (for example, 7:2:1) to obtain a training set, a test set, and a validation set; finally, the training set, the test set, and the validation set can be directly used to train the original fruit quality detection model to obtain a trained fruit quality detection model.
[0072] In one possible implementation, in order to further improve the accuracy and efficiency of fruit quality detection, in an embodiment of the present application, when obtaining a training set, a test set, and a validation set according to a preset ratio from multiple original defect images, the multiple original defect images can also be subjected to geometric transformation and color transformation to obtain multiple pre-processed defect images; wherein, the geometric transformation includes flipping, rotation, cropping, deformation, and scaling; the color transformation includes blurring, erasing, filling, and brightness enhancement; based on this, the multiple pre-processed defect images can be directly obtained according to a preset ratio to obtain a training set, a test set, and a validation set, so as to improve the accuracy and efficiency of fruit quality detection.
[0073] To sum up, in the embodiment of the present application, since the trained fruit quality detection model is generated based on the asymmetric structure of 4 encoders and 3 decoders, compared with the prior art, the present application can not only efficiently compress redundant information by setting the number of encoders to be greater than the number of decoders to reduce the amount of computational complexity of subsequent processing, but also achieve a balance between computing resources and model performance through this hierarchical asymmetric design, so as to further improve the detection accuracy and efficiency of fruits (small targets) under the premise of a small number of training images. Therefore, the present application is more suitable for industrial detection scenarios that require high precision and real-time performance.
[0074] Moreover, since each encoder includes an attention module, the present application can dynamically enhance the weights of key areas of the fruit (such as damaged and discolored areas), thereby suppressing background interference. In addition, since each decoder also includes a depth-separable convolution layer, the present application can also reduce the amount of computation through a lightweight design such as depth-separable convolution. In addition, since the trained fruit quality detection model is also provided with a bilinear convolution layer (convolution layer Conv + bilinear interpolation upsampling Bilinear), the present application can improve detail recovery capabilities while ensuring computational efficiency.
[0075] In addition, through verification on the Qualcomm QCS6490 chip, it can be seen that the technical solution of this application can achieve a single inference of 30ms at 16-bit integer (int16) precision, which is significantly better than the current mainstream segmentation models, such as UNet++ and SAM (SegmentAnything Model) inference speed.
[0076] Based on the same inventive concept, the embodiment of the present application provides a fruit quality detection device 70, such as Figure 7 As shown, the fruit quality detection device 70 includes:
[0077] The image acquisition unit 701 is used to acquire an image of the target fruit and obtain an acquired image;
[0078] The quality detection unit 702 is used to input the collected image into the trained fruit quality detection model to obtain the detection result; wherein the trained fruit quality detection model is composed of 4 encoders, 2 convolutional networks, 3 decoders and bilinear convolutional layers, and each encoder includes an attention module, and each decoder includes a depthwise separable convolutional layer;
[0079] The defect determination unit 703 is used to determine whether the target fruit has defects based on the detection results.
[0080] Optionally, the quality detection unit 702 is further configured to:
[0081] The collected image is sequentially input into a first encoder, a second encoder, a third encoder, and a fourth encoder of a trained fruit quality detection model to obtain a first eigenvector, a second eigenvector, a third eigenvector, and a fourth eigenvector;
[0082] Inputting the fourth eigenvector into a first decoder of a trained fruit quality detection model to obtain a first feature map;
[0083] The first convolutional feature vector obtained by processing the third feature vector using the first convolutional network of the trained fruit quality detection model is compared with the first feature vector. Figure 1 Input the second decoder to obtain a second feature map;
[0084] The second convolutional feature vector obtained by processing the second feature vector with the second convolutional network of the trained fruit quality detection model is compared with the second feature vector. Figure 1 Input the third decoder of the trained fruit quality detection model to obtain a third feature map;
[0085] Input the third feature map into the bilinear convolution layer of the trained fruit quality detection model to obtain the third feature map;
[0086] The third feature map is input into the prediction head of the trained fruit quality detection model to obtain the detection results.
[0087] Optionally, the fruit quality detection device 70 further includes a model training unit 704, which is used to:
[0088] Use image acquisition equipment to capture images of various fruits and obtain multiple original defect images;
[0089] Multiple original defect images are obtained according to the preset ratio to obtain training set, test set and validation set;
[0090] The original fruit quality detection model is trained using the training set, test set, and validation set to obtain a trained fruit quality detection model.
[0091] Optionally, the model training unit 704 is further configured to:
[0092] Perform geometric transformation and color transformation on multiple original defect images to obtain multiple pre-processed defect images; wherein the geometric transformation includes flipping, rotation, cropping, deformation and scaling; the color transformation includes blurring, erasing, filling and brightness enhancement;
[0093] Multiple preprocessed defect images are used in a preset ratio to obtain training sets, test sets, and validation sets.
[0094] The fruit quality detection device 70 can be used to perform Figure 2-Figure 6The method implemented in the embodiment shown in FIG. 1 is a method implemented in the embodiment shown in FIG. 1 , and therefore, the functions that can be realized by each functional module of the fruit quality detection device 70 can be referred to. Figure 2-Figure 6 The description of the illustrated embodiment is omitted for brevity.
[0095] In some possible implementations, various aspects of the method provided in the present application may also be implemented in the form of a program component, which includes program code. When the program component is run on a computer device, the program code is used to enable the computer device to execute the steps of the method according to various exemplary embodiments of the present application described above in this specification. For example, the computer device may execute the following steps: Figure 2-Figure 6 The method performed in the illustrated embodiment.
[0096] Those skilled in the art will understand that all or part of the steps of the above-mentioned method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks or optical disks. Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent part, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application, or the part that contributes to the prior art, can be embodied in the form of a software part, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the methods described in each embodiment of the present application. And the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0097] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0098] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A method for detecting fruit quality, characterized in that: The method comprises: Capturing images of target fruits to obtain captured images; Inputting the collected image into a trained fruit quality detection model to obtain a detection result; wherein the trained fruit quality detection model is composed of 4 encoders, 2 convolutional networks, 3 decoders and a bilinear convolutional layer, and each encoder includes an attention module, and each decoder includes a depthwise separable convolutional layer; According to the detection result, it is determined whether the target fruit has defects.
2. The method according to claim 1, wherein The step of inputting the collected image into a trained fruit quality detection model to obtain a detection result includes: Inputting the collected image into a first encoder, a second encoder, a third encoder, and a fourth encoder of a trained fruit quality detection model in sequence to obtain a first eigenvector, a second eigenvector, a third eigenvector, and a fourth eigenvector; Inputting the fourth eigenvector into a first decoder of a trained fruit quality detection model to obtain a first feature map; Inputting a first convolutional feature vector obtained by processing the third feature vector using the first convolutional network of the trained fruit quality detection model into a second decoder together with the first feature map to obtain a second feature map; Inputting a second convolutional feature vector obtained by processing the second feature vector using a second convolutional network of the trained fruit quality detection model, together with the second feature map, into a third decoder of the trained fruit quality detection model to obtain a third feature map; Inputting the third feature map into the bilinear convolution layer of the trained fruit quality detection model to obtain the third feature map; The third feature map is input into the prediction head of the trained fruit quality detection model to obtain a detection result.
3. The method according to claim 1, wherein Each encoder contains a fully convolutional neural network (FCN), a normalization layer, an attention module, a normalization layer, and a multi-layer perceptron (MLP) network connected in sequence.
4. The method according to claim 1, wherein Each convolutional network contains a convolutional layer Conv, a split operation layer, a convolutional layer Conv, a convolutional layer Conv, an add operation layer, a concat operation layer, and a convolutional layer Conv connected in sequence.
5. The method according to claim 1, wherein Each decoder consists of a sequentially connected convolutional layer Conv, three 3×3 depth-wise separable convolutional layers, and an upsampling layer.
6. The method according to claim 1, wherein Before inputting the collected image into the trained fruit quality detection model to obtain the detection result, the method further includes: Use image acquisition equipment to capture images of various fruits and obtain multiple original defect images; The plurality of original defect images are obtained according to a preset ratio to obtain a training set, a test set and a validation set; The training set, test set and validation set are used to train the original fruit quality detection model to obtain a trained fruit quality detection model.
7. The method according to claim 6, wherein The step of obtaining a training set, a test set, and a validation set by using the plurality of original defect images in a preset ratio includes: Performing geometric transformation and color transformation on the plurality of original defect images to obtain a plurality of pre-processed defect images; wherein the geometric transformation includes flipping, rotating, cropping, deforming and scaling; and the color transformation includes blurring, erasing, filling and brightness enhancement; The plurality of pre-processed defect images are processed according to a preset ratio to obtain a training set, a test set and a validation set.
8. A fruit quality detection device, characterized in that: The device comprises: An image acquisition unit is used to acquire images of target fruits and obtain acquired images; A quality detection unit is used to input the collected image into a trained fruit quality detection model to obtain a detection result; wherein the trained fruit quality detection model is composed of 4 encoders, 2 convolutional networks, 3 decoders and a bilinear convolutional layer, and each encoder includes an attention module, and each decoder includes a depthwise separable convolutional layer; A defect determination unit is used to determine whether the target fruit has defects based on the detection result.
9. An electronic device, characterized in that: The device comprises: a memory for storing program instructions; A processor is configured to call program instructions stored in the memory and execute the method according to any one of claims 1 to 7 according to the obtained program instructions.
10. A storage medium, characterized in that: The storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Lightweight network real-time semantic segmentation method based on attention mechanism
CN112330681A
Object recognition method and device, electronic equipment and storage medium
CN118397266A
Greenhouse strawberry fruit target detection algorithm based on improved DETR
CN118570443A
Semiconductor chip defect detection method, system and medium
CN119624918A
Cited By
Winter jujube defect identification method and system based on deep learning
CN122368643A
Winter jujube defect identification method and system based on deep learning
CN122368643B