Deep learning-based fruit appearance quality detection method

By improving the deep convolutional generative adversarial network and introducing the ECA attention mechanism module, the problem of insufficient small target detection capabilities and insufficient data sets in fruit appearance quality detection is solved, achieving higher detection accuracy and speed, and is suitable for outer skin defects. detection.

CN118675167APending Publication Date: 2024-09-20ANHUI NORMAL UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410736845.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

Among the existing deep learning-based fruit appearance quality detection methods, the single-stage detection model has weak detection capabilities for small targets, and the training data set is insufficient. In particular, the data set of fruit pictures containing outer skin defects is difficult to obtain.

Method used

By improving the discriminator loss function of the deep convolutional adversarial network, using the ECA attention mechanism module to enhance the feature extraction capabilities of the YOLOv5L network, combined with data set expansion and simulated image generation, a high-quality training data set is constructed to improve the performance of the detection model. .

Benefits of technology

It effectively reduces the convergence difficulty of model training, improves the ability to extract small target features, significantly improves the accuracy and speed of fruit appearance quality detection, and is suitable for fruit detection scenarios with a large number of outer skin defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118675167A
    Figure CN118675167A
Patent Text Reader

Abstract

The invention discloses a fruit appearance quality detection method based on deep learning, and the method can carry out the expansion of a picture data set containing a small number of fruit appearance defects, and improves the small target detection capability of a YOLOv5L algorithm. According to the method, firstly, traditional expansion methods such as overturning, zooming and gray scale changing are carried out on pictures in an initial data set, so that the robustness of subsequent model training is improved; aiming at the problem of neuron death in the training process of the deep convolutional generative adversarial network, the invention provides a method for improving a discriminator loss function, so that the problem of neuron death is effectively solved, the convergence speed of a model during training is improved, and the generated simulation picture is helpful to the training of a subsequent detection model to a certain extent. In order to solve the problem that a YOLOv5L network is weak in small target detection capability, the invention provides a method for introducing an attention mechanism into a feature extraction network, and the small target feature extraction capability of a model is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning, and in particular to a method for detecting fruit appearance quality based on deep learning. Background Art

[0002] The object detection algorithm based on deep learning is one of the most popular branches in the field of deep learning. It uses deep neural networks to learn data representation and extract features. There are two main types of object detection algorithms based on deep learning: One-Stage and Two-Stage. The One-Stage object detection model mainly regards the object detection problem as a single regression problem. It usually uses anchor-based detection methods such as YOLO, SSD, RetinaNet, etc. These methods divide the image into different anchor points and classify and regress each anchor point to determine whether there is a target object and the location and size of the object.

[0003] The advantages of the One-Stage algorithm are fast speed and good real-time performance, and it has great application value in some scenarios that require real-time monitoring. However, its disadvantage is that the accuracy is relatively low, the detection effect for small targets is not ideal, and it is prone to false detection or missed detection. In addition, no matter what kind of detection algorithm is used, a large number of image data sets are required during training. In the application scenario of fruit appearance quality detection, the trained detection model needs to be trained with the support of a large number of image data sets containing damaged outer skin. However, there are few open source data sets of fruit images with damaged outer skin, and it is difficult to produce such data sets on a large scale. Therefore, it is impossible to train the data set. The lack of data sets also restricts the realization of the recognition model of fruit appearance quality. Summary of the invention

[0004] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a fruit appearance quality detection method based on deep learning, aiming to solve the problems that a training data set for the appearance quality of fruits containing outer skin defects is difficult to obtain and the single-stage detection model has poor detection ability for small targets.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is: a method for detecting fruit appearance quality based on deep learning, comprising the following steps:

[0006] S1, expanding and enhancing the fruit image data in the original data set to achieve the purpose of preliminary enhancement and expansion of the initial data set, and obtain the initial data set;

[0007] S2. Use the improved deep convolutional generative adversarial network to train on the initial data set. The trained improved deep convolutional generative adversarial network generates simulated fruit pictures, and mixes the obtained simulated pictures with the real pictures to obtain the final training data set.

[0008] S3, using the improved YOLOv5L network as the detection model, and using the final training data set to train the improved YOLOv5L network to obtain a fruit appearance quality detection model after training;

[0009] S4. Use the fruit appearance quality model to detect the appearance of the fruit.

[0010] The improved deep convolutional generative adversarial network refers to modifying the loss function of the discriminator of the deep convolutional generative adversarial network to solve the problem of neuron death during training, which causes the model to fail to converge.

[0011] The discriminator loss function of the deep convolutional generative adversarial network is modified from LeakyReLU to ReLU activation function to obtain an improved deep convolutional generative adversarial network.

[0012] The improved YOLOv5L network refers to adding an ECA attention mechanism module to the last layer of the feature extraction part of the YOLOv5L network model.

[0013] The method for expanding and enhancing the original data set in step S1 includes: collecting and collating a data set containing appearance pictures of fruits with damaged outer skins and pictures of fruits with intact outer skins as the original data set, processing the fruit pictures in the original data set by expansion methods such as rotation change, flip change, scaling change and grayscale change, and adding the processed fruit pictures to the original data set to obtain an initial data set.

[0014] The training method for the improved deep convolutional generative adversarial network includes:

[0015] (1) The images in the initial dataset are uniformly cropped to a set size and then divided into a test dataset and a training dataset;

[0016] (2) Set training parameters: set batch size, learning rate of generator and discriminator, and number of iterations;

[0017] (3) Use the training data set for training and the test data set for testing.

[0018] Step (3) includes:

[0019] ① First, fix the generator so that it continuously outputs simulated sample images. At this time, it does not participate in training iterations. The discriminator obtains a batch of real samples from the training set and calculates the loss function log2[D(x)]. D(x) is the probability judgment of the discriminator D that the input image x is a real image.

[0020] ② Get fake images from the generator, calculate the loss function log2[1-D(z)], and summarize after the calculation is completed. Where D(z) represents the judgment of the discriminator D on the authenticity of the generated sample.

[0021] ③ The discriminator is updated with data optimization through the Adam optimizer and stochastic gradient descent algorithm.

[0022] ④Finally, fix the discriminator of the model so that it only outputs the judgment result and does not participate in the training iteration. The generator is updated with data optimization through the loss function log2{1-D[G(z)]}. Where D[G(z)] represents the evaluation of the discriminator D on the sample G(z) generated by the generator G based on the random noise z.

[0023] The generator network is set to update 5 times and the discriminator network is updated once, and the alternating update method is repeated during the training process until the training is completed.

[0024] Step S2 includes: combining the simulated images generated by the improved deep convolutional generative adversarial network and the real sample images into a picture dataset as a dataset sample for subsequent detection model training, which is the final dataset.

[0025] The improved YOLOv5L network model is used as the detection model, and the final data set is used as the training set of the detection model for training. The training parameters include batch size, learning rate, number of iterations, confidence threshold, and intersection-over-union ratio. After the training is completed, it becomes a fruit detection model.

[0026] The advantages of the present invention are: by improving the loss function of the discriminator in the deep convolutional generative adversarial network, the convergence difficulty of the deep convolutional generative adversarial network model during training is reduced, and the problem of difficulty in obtaining a sample image data set containing fruit appearance defects is solved; a method for introducing an ECA attention mechanism module into the feature extraction network of YOLOv5L is proposed, and the method automatically assigns weight coefficients to feature channels through the ECA attention mechanism, thereby enhancing the ability of the YOLOv5L network to extract small target features. Experimental results show that the proposed method performs better when processing a data set containing a large number of small fruit appearance defect features, obtains better results, and has better practical guiding significance. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The following is a brief description of the contents expressed in the drawings of the present invention and the symbols in the drawings:

[0028] Figure 1 An overall flow chart of a fruit appearance quality detection method based on deep learning provided for the implementation of the present invention;

[0029] Figure 2A schematic diagram of the expansion of the initial data set provided for the implementation of the present invention;

[0030] Figure 3 Schematic diagram of LeakyReLU and GeLU activation functions provided for the implementation of the present invention;

[0031] Figure 4 A schematic diagram of the DCGAN network training process provided for the implementation of the present invention;

[0032] Figure 5 A schematic diagram of the FID indicator provided for the implementation of the present invention;

[0033] Figure 6 Schematic diagram of simulated fruit pictures under different iterative training times provided for the implementation of the present invention;

[0034] Figure 7 A picture similarity evaluation result diagram provided for the implementation of the present invention;

[0035] Figure 8 The experimental results of the implementation of the present invention are compared with YOLOv5L itself and YOLOv8 algorithm;

[0036] Fig. 9 A schematic diagram of the ECA attention mechanism structure provided for the implementation of the present invention;

[0037] Fig.10 This is a schematic diagram of the YOLOv5L structure with the ECA attention mechanism introduced;

[0038] Fig.11 A schematic diagram showing a comparison between the RCNN, Faster RCNN, SSD and YOLOv8 algorithms provided by the present invention. DETAILED DESCRIPTION

[0039] The specific implementation of the present invention will be further explained in detail below by describing the optimal embodiment with reference to the accompanying drawings.

[0040] In view of the problem that fruit pictures in the prior art cannot be produced on a large scale by themselves, this embodiment uses a deep convolutional generative adversarial network to generate pictures of simulated pictures to construct training set pictures. The deep convolutional generative adversarial network is a new network framework that combines traditional convolutional neural networks and generative adversarial networks. The deep convolutional generative adversarial network has a wide range of applications in image generation, image super-resolution and image restoration. However, the generative adversarial network also has shortcomings: the problem of neuron death often occurs during the training process, that is, the output is often 0 during the training process, which increases the difficulty of model convergence. In view of these problems, the present invention proposes a fruit appearance quality detection method based on deep learning, by improving the loss function of the discriminator in the deep convolutional generative adversarial network, solving the problem of neuron death in the deep convolutional generative adversarial network, and then using the generated simulated pictures as a training data set for the training of the detection model. In addition, in view of the problem that the single-stage detection model has a weak detection ability for small targets, the YOLOv5L series algorithm is selected as the research target, and the ECA attention mechanism is introduced into the feature network of the model to strengthen the extraction ability of YOLOv5L for small target features, so as to enhance the detection and recognition ability of YOLOv5L for small fruit appearance defects.

[0041] This embodiment provides a method for detecting fruit appearance quality based on deep learning, and the method specifically comprises the following steps:

[0042] S1. Expand and enhance the image data in the original data set by using the traditional sample image expansion method to achieve the purpose of preliminary enhancement and expansion of the initial data set;

[0043] S2. For the problem that the deep convolutional generative adversarial network has neuron death during training, which causes the model to fail to converge, the loss function of the discriminator is improved;

[0044] S3, training the improved deep convolutional generative adversarial network on the dataset initially expanded and enhanced in step S1, mixing the obtained simulated images with the real images to obtain the final training dataset;

[0045] S4. Introduce the attention mechanism module into the feature extraction module in the YOLOv5L network to enhance the YOLOv5L network’s ability to extract small target features;

[0046] S5. Train the improved YOLOV5L network on the final data set in step S3 to obtain a fruit appearance quality detection model.

[0047] Furthermore, the traditional sample image expansion method for the initial data set is as follows:

[0048] S11. Obtain images of fruits with damaged skin and intact skin through web crawlers and offline self-photography. Among them, there are more than 2,400 images of fruits with intact skin and more than 2,900 images of fruits with varying degrees of damage, totaling about 5,000 images.

[0049] S12, process the fruit images in S11 by traditional sample image expansion methods such as rotation change, flip change, scaling change and grayscale change. The original images and the final processed images are used as the initial data set.

[0050] Furthermore, the improvements and training methods for deep convolutional generative adversarial networks are as follows:

[0051] S21. Improve the loss function of the discriminator in the deep convolutional generative adversarial network, LeakyReLU, to the GeLU activation function. The LeakyReLU and GeLU activation functions are shown in formula (1) and formula (2):

[0052] f(x)=max(0,x)+α*min(0,x) (1)

[0053] f(x)=x*Φ(x) (2)

[0054] In formula (1), α is a small positive number (e.g., 0.01) used to keep the gradient small when the input is negative. In formula (2), Φ(x) represents the definite integral of the Gaussian distribution in the interval (-∞, x].

[0055] S22. Cropping the images in the initial data set to a size of 256 pixels * 256 pixels. Select about 600 images as the test data set and about 2300 images as the training data set. The training parameter settings are shown in Table 1: the batch size is 64, the learning rate of the generator and the discriminator are both 0.0002, and 2000 rounds of training iterations are performed. The software and hardware parameters of the experiment are shown in Tables 1 and 2:

[0056] Table 1 Training parameters

[0057]

[0058] Table 2 Experimental hardware and software parameters

[0059]

[0060] The specific experimental steps are as follows:

[0061] ① First, fix the generator so that it continuously outputs simulated sample images. At this time, it does not participate in training iterations. The discriminator obtains a batch of real samples from the training set and calculates the loss function log2[D(x)]. D(x) is the probability judgment of the discriminator D that the input image x is a real image.

[0062] ② Get fake images from the generator, calculate the loss function log2[1-D(z)], and summarize after the calculation is completed. Where D(z) represents the judgment of the discriminator D on the authenticity of the generated sample.

[0063] ③ The discriminator is updated with data optimization through the Adam optimizer and stochastic gradient descent algorithm.

[0064] ④Finally, fix the discriminator of the model so that it only outputs the judgment result and does not participate in the training iteration. The generator is updated with data optimization through the loss function log2{1-D[G(z)]}. Where D[G(z)] represents the evaluation of the discriminator D on the sample G(z) generated by the generator G based on the random noise z.

[0065] In addition, in order to prevent the discriminator from always being in the upper hand in the game with the generator, which would cause the gradient to vanish, the generator network is set to update once every 5 updates. This alternating update method is repeated during the training process until the end of the training. This can maintain the balance between the discriminator and the generator, so that they both have sufficient training and learning opportunities, thereby improving the generator's ability to generate realistic images.

[0066] S23. Combine the simulated images generated by the improved deep convolutional generative adversarial network and the real sample images into a picture dataset as a dataset sample for subsequent detection model training.

[0067] Further, the improvements and training methods to enhance YOLOv5L’s small target detection capabilities are as follows:

[0068] S31. Introduce the ECA attention mechanism into the last layer of the feature extraction part of YOLOv5L. The ECA attention mechanism is a channel attention mechanism that automatically obtains the importance of each feature channel through network learning, and then assigns different weight coefficients to these feature channels to obtain the final feature map.

[0069] S32, the YOLOv5L model integrated with the ECA attention mechanism is trained on the data set described in S23, wherein the specific training parameters are shown in Table 3:

[0070] Table 3 Training parameters

[0071]

[0072]

[0073] The YOLOv5L model integrated with the ECA attention mechanism is trained using the final data set. After the training is completed, it is used as a fruit appearance quality detection model, and the fruit appearance quality model is used to identify and detect the appearance of the fruit.

[0074] By adopting the above scheme, the technical advantages of this application include reducing the convergence difficulty of the deep convolutional generative adversarial network model during training by improving the loss function of the discriminator in the deep convolutional generative adversarial network, solving the problem of difficulty in obtaining a sample image dataset containing fruit appearance defects; a method of introducing an ECA attention mechanism module into the feature extraction network of YOLOv5L is proposed. This method automatically assigns weight coefficients to feature channels through the ECA attention mechanism, thereby enhancing the ability of the YOLOv5L network to extract small target features. Experimental results show that the proposed method performs better when processing a dataset containing a large number of small fruit appearance defect features, achieves better results, and has better practical guiding significance.

[0075] The following is combined with Figure 1-11 To explain:

[0076] Figure 1 The overall flow chart of a fruit appearance quality detection method based on deep learning provided for the implementation of the present invention comprises the following steps:

[0077] S1. The image data in the original data set is expanded and enhanced by the traditional sample image expansion method to achieve the purpose of preliminary enhancement and expansion of the initial data set. The traditional sample image expansion method is as follows:

[0078] S11. Obtain images of fruits with damaged skin and intact skin through web crawlers and offline self-photography. Among them, there are more than 2,400 images of fruits with intact skin and more than 2,900 images of fruits with varying degrees of damage, totaling about 5,000 images.

[0079] S12, the fruit image in S11 is processed by traditional sample image expansion methods such as rotation change, flip change, scaling change and grayscale change. Figure 2 This is an example of expanding the capacity of traditional sample images. The original image and the final processed image are used as the initial data set.

[0080] S2. For the problem that the deep convolutional generative adversarial network has neuron death during training, which causes the model to fail to converge, the loss function of the discriminator is improved. The specific method for improving the loss function of the discriminator is as follows:

[0081] S21. Improve the loss function LeakyReLU of the discriminator in the deep convolutional generative adversarial network to GeLU activation function. The function images of LeakyReLU activation function and GeLU activation function are as follows: Figure 3 shown.

[0082] S22. Cropping the images in the initial dataset to a size of 256 pixels * 256 pixels. Select about 600 images as the test dataset and about 2300 images as the training dataset. The training parameter settings are shown in Table 1: the batch size is 64, the learning rate of the generator and the discriminator are both 0.0002, and 2000 rounds of training iterations are performed. The training flow chart of the deep convolutional generative adversarial network is shown in Figure 4 As shown, the maximum number of iterations and the parameters of D and G are initialized, and then the noise Z is introduced into G to generate a fake image; then D is updated with the real image and the fake image; G is updated using the loss function of D for the fake image; then it is determined whether the maximum number of iterations has been reached, and if so, the training of the deep convolutional generative adversarial network is terminated, otherwise the value is returned. Step 2: Introduce the noise Z into G to generate a fake image, and then execute sequentially until the maximum number of iterations is met. Where D is the discriminator and G is the generator.

[0083] The specific experimental steps are as follows:

[0084] ① First, fix the generator so that it continuously outputs simulated sample images. At this time, it does not participate in training iterations. The discriminator obtains a batch of real samples from the training set and calculates the loss function log2[D(x)]. D(x) is the probability judgment of the discriminator D that the input image x is a real image.

[0085] ② Get fake images from the generator, calculate the loss function log2[1-D(z)], and summarize after the calculation is completed. Where D(z) represents the judgment of the discriminator D on the authenticity of the generated sample.

[0086] ③ The discriminator is updated with data optimization through the Adam optimizer and stochastic gradient descent algorithm.

[0087] ④Finally, fix the discriminator of the model so that it only outputs the judgment result and does not participate in the training iteration. The generator is updated with data optimization through the loss function log2{1-D[G(z)]}. Where D[G(z)] represents the evaluation of the discriminator D on the sample G(z) generated by the generator G based on the random noise z.

[0088] In addition, in order to prevent the discriminator from always being in the upper hand in the game with the generator, which would cause the gradient to vanish, the generator network is set to update once every 5 updates. This alternating update method is repeated during the training process until the end of the training. This can maintain the balance between the discriminator and the generator, so that they have sufficient training and learning opportunities, thereby improving the generator's ability to generate realistic images. The fruit pictures generated at different iterations are shown below. Figure 6 shown.

[0089] S3. The improvements and training methods to improve YOLOv5L's small target detection capabilities are as follows:

[0090] S31. Introduce the ECA attention mechanism into the last layer of the feature extraction part of YOLOv5L. The ECA attention mechanism is a channel attention mechanism that automatically obtains the importance of each feature channel through network learning, and then assigns different weight coefficients to these feature channels to obtain the final feature map. Among them, the structure diagram of the ECA attention mechanism is as follows Fig. 9 shown.

[0091] S32, train the YOLOv5L model integrated with the ECA attention mechanism on the data set described in S23. The YOLOv5L network structure diagram with the ECA attention mechanism module is shown in the figure below: Fig.10 As shown in the figure, the trained YOLOv5L model integrated with the ECA attention mechanism is used as a fruit appearance detection model to identify and detect the appearance of real fruit photos and output the detection results.

[0092] The fruit appearance quality detection method based on deep learning provided by the present invention has the following beneficial technical effects:

[0093] By improving the loss function of the discriminator in the deep convolutional generative adversarial network, the convergence difficulty of the model during training is reduced, and the problem of difficulty in obtaining sample image datasets containing fruit appearance defects is solved; a method of introducing the ECA attention mechanism module into the feature extraction network of YOLOv5L is proposed. This method automatically assigns weight coefficients to feature channels through the ECA attention mechanism, which enhances the ability of the YOLOv5L network to extract small target features. Experimental results show that the proposed method performs better when processing datasets containing a large number of small fruit appearance defect features, achieves better results, and has better practical guiding significance.

[0094] The method is suitable for fruit detection scenarios with a large number of outer skin defects. Both theoretical analysis and experimental results show that the present invention has higher detection accuracy and faster detection speed.

[0095] Figure 5 The result graph of the FID (Fréchet Inception Distance, FID) evaluation index during the training process of the deep convolutional generative adversarial network with improved activation function is given. FID is a quality index used to evaluate the images simulated by the generative adversarial network. It measures the difference between the generated image and the real image by comparing their feature statistics. The smaller the value, the better the authenticity of the simulated image, and vice versa. As can be seen from the figure, as the number of iterations increases, the FID curve reaches the lowest when the number of iterations is about 2000. At this time, the simulated image generated by the network is theoretically the best. Figure 6 Iteration pictures of two different fruits when the iteration times are 500, 1000, 1500 and 2000 are given. The iteration times increase from left to right. It can be seen from the pictures that the best effect is achieved when the iteration times are around 2000.

[0096] Figure 7 In order to improve the deep convolutional generative adversarial network with the activation function to simulate the fruit pictures with outer skin defects, the present invention uses two evaluation indicators of picture similarity to evaluate them, namely: Multiscale Structure Similarity (MS-SSIM) and Peak Signal-to-Noise Ratio (PSNR). The evaluation values ​​of both are close to 1, which means that the more similar the evaluated pictures are to the real pictures. It can be seen from the figure that the fruit pictures generated by the DCGAN algorithm based on the improved discriminator activation function have a high similarity with the real pictures, and can be used as simulated images as a data set for subsequent YOLOv5L.

[0097] For the rigor of the experiment, this method is used to train YOLOv5L and YOLOv8 on the initial dataset and compare the models obtained by training on the expanded dataset. The specific experimental results are as follows Figure 8 As shown in the figure. As can be seen from the figure, after using the dataset enhanced by the adversarial generative network with the improved discriminator activation function, the detection accuracy of YOLOv5L has been significantly improved. Specifically, the average precision (AP) value has increased by 1.8%, and the average precision at an IoU threshold of 0.5 has also increased by 1.3%. The reason why the accuracy of YOLOv8 is lower than that of YOLOv5L is largely because it is difficult for YOLOv8 to learn the feature information of small targets. This is because the downsampling multiple of YOLOv8 is much larger than that of YOLOv5L; and because the YOLOv8 model is larger, the number of parameters is too large during calculation, resulting in a long training time, and the FPS value in the detection task is also lower than that of YOLOv5L.

[0098] Fig.11 A comparison diagram of the method described in the present invention with RCNN, Faster RCNN, SSD and YOLOv8 algorithms is given, mainly comparing the two indicators of average precision value and detection speed. It can be seen from the figure that when YOLOv5L introduces the ECA attention mechanism and the model trained by the DCGAN network enhancement and expansion of the data set with improved generation function in the discriminator, it is superior to the other algorithms in terms of average precision value and detection speed, which in a sense illustrates the effectiveness of the invention.

[0099] Obviously, the specific implementation of the present invention is not limited to the above-mentioned methods. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention, they are all within the protection scope of the present invention.

Claims

1. A method for detecting fruit appearance quality based on deep learning, characterized in that: The steps include: S1, expanding and enhancing the fruit image data in the original data set to achieve the purpose of preliminary enhancement and expansion of the initial data set, and obtain the initial data set; S2. Use the improved deep convolutional generative adversarial network to train on the initial data set. The trained improved deep convolutional generative adversarial network generates simulated fruit pictures, and mixes the obtained simulated pictures with the real pictures to obtain the final training data set. S3, using the improved YOLOv5L network as the detection model, and using the final training data set to train the improved YOLOv5L network to obtain a fruit appearance quality detection model after training; S4. Use the fruit appearance quality model to detect the appearance of the fruit.

2. A method for detecting fruit appearance quality based on deep learning as claimed in claim 1, characterized in that: The improved deep convolutional generative adversarial network refers to modifying the loss function of the discriminator of the deep convolutional generative adversarial network to solve the problem of neuron death during training, which causes the model to fail to converge.

3. A method for detecting fruit appearance quality based on deep learning as claimed in claim 2, characterized in that: The discriminator loss function of the deep convolutional generative adversarial network is modified from LeakyReLU to ReLU activation function to obtain an improved deep convolutional generative adversarial network.

4. A method for detecting fruit appearance quality based on deep learning as claimed in claim 1, characterized in that: The improved YOLOv5L network refers to adding an ECA attention mechanism module to the last layer of the feature extraction part of the YOLOv5L network model.

5. A method for detecting fruit appearance quality based on deep learning as described in any one of claims 1 to 4, characterized in that: The method for expanding and enhancing the original data set in step S1 includes: collecting and collating a data set containing appearance pictures of fruits with damaged outer skins and pictures of fruits with intact outer skins as the original data set, processing the fruit pictures in the original data set by expansion methods such as rotation change, flip change, scaling change and grayscale change, and adding the processed fruit pictures to the original data set to obtain an initial data set.

6. A method for detecting fruit appearance quality based on deep learning as described in any one of claims 1 to 4, characterized in that: The training method for the improved deep convolutional generative adversarial network includes: (1) The images in the initial dataset are uniformly cropped to a set size and then divided into a test dataset and a training dataset; (2) Set training parameters: set batch size, learning rate of generator and discriminator, and number of iterations; (3) Use the training data set for training and the test data set for testing.

7. A method for detecting fruit appearance quality based on deep learning as claimed in claim 6, characterized in that: Step (3) includes: ① First, fix the generator so that it continuously outputs simulated sample images. At this time, it does not participate in training iterations. The discriminator obtains a batch of real samples from the training set and calculates the loss function log2[D(x)]; where D(x) is the probability judgment of the discriminator D that the input image x is a real image; ② Get the fake image from the generator, calculate the loss function log2[1-D(z)], and summarize it after the calculation is completed; where D(z) represents the judgment of the discriminator D on the authenticity of the generated sample; ③ Use the Adam optimizer and stochastic gradient descent algorithm to optimize and update the discriminator data; ④Finally, fix the discriminator of the model so that it only outputs the judgment result and does not participate in the training iteration. The generator is updated with data optimization through the loss function log2{1-D[G(z)]}; where D[G(z)] represents the evaluation of the discriminator D on the sample G(z) generated by the generator G based on the random noise z.

8. A method for detecting fruit appearance quality based on deep learning as claimed in claim 7, characterized in that: The generator network is set to update 5 times and the discriminator network is updated once, and the alternating update method is repeated during the training process until the training is completed.

9. A method for detecting fruit appearance quality based on deep learning as described in any one of claims 1 to 4, characterized in that: Step S2 includes: combining the simulated images generated by the improved deep convolutional generative adversarial network and the real sample images into a picture dataset as a dataset sample for subsequent detection model training, which is the final dataset.

10. A method for detecting fruit appearance quality based on deep learning according to any one of claims 1 to 4, characterized in that: The improved YOLOv5L network model is used as the detection model, and the final data set is used as the training set of the detection model for training. The training parameters include batch size, learning rate, number of iterations, confidence threshold, and intersection-over-union ratio. After the training is completed, it becomes a fruit detection model.

Citation Information

Patent Citations

  • Fruit identification method based on improved YOLOv5 network

    CN115641577A

  • Earphone cover defect detection method, device and equipment and storage medium

    CN116152209A

  • Small sample chip appearance defect detection method and detection system based on improved YOLOv5

    CN116228740A

  • Method and system for detecting grape clusters in hard core period based on improved YOLOv5s

    CN117392529A