A rice identification and screening method based on improved YOLOv3

By improving the YOLOv3 network structure and data augmentation methods, the problem of false positives and false negatives caused by shape and color in rice screening was solved, thus improving the accuracy of rice classification and screening.

CN116543382BActive Publication Date: 2026-04-24HARBIN ENG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HARBIN ENG UNIV
Filing Date
2023-04-11
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Current rice screening technologies mainly rely on the weight of rice grains for classification, failing to effectively consider the color and shape of the rice, resulting in frequent false positives and false negatives.

Method used

An improved YOLOv3 network structure was adopted, combined with data augmentation methods such as adaptive gamma correction, noise addition, and rotation, to construct a rice image dataset. By adjusting the network structure and training parameters, the ability to detect small targets was improved.

Benefits of technology

This improved the accuracy of rice screening, overcame the problems of false positives and false negatives caused by ignoring shape and color in traditional methods, and achieved more efficient classification and screening.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116543382B_ABST
    Figure CN116543382B_ABST
Patent Text Reader

Abstract

The application discloses a rice identification and screening method based on improved YOLOv3 and belongs to the technical field of rice identification, and the specific steps are as follows: acquiring a rice data set and performing data enhancement; performing data labeling on rice image data to obtain a corresponding label file; constructing a network model, changing the original DarkNet53 backbone network of YOLOv3 from 5 Resblock_body to 4, reducing one output scale 13x13, taking 26x26, 52x52 and 104x104 as feature fusion layers and prediction layers, so as to enhance the detection capability for small targets; modifying the network loading pre-training weight mode, taking the weight of the coco data set as the pre-training weight for training until the network converges, saving the model and the weight file; and testing the data set by using the best training model to obtain the result. The rice identification and screening method based on the improved YOLOv3 can make up for the missed detection caused by neglecting the shape and color of rice in the traditional classification and screening method, and improve the accuracy of rice classification and screening.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of rice identification technology, and in particular relates to a rice identification and screening method based on an improved YOLOv3. Background Technology

[0002] The production process of rice processing enterprises includes raw material acquisition, screening, destoning, magnetic separation, rice hulling, paddy separation, milling, color sorting, polishing, and finished product packaging. After each of these processing steps, the rice contains whole grains, incomplete grains, and unprocessed grains. Incomplete and unprocessed grains affect the quality of subsequent processing, as well as the packaging and sales of the rice. Therefore, it is necessary to classify and screen the rice after each processing step to improve the quality of the finished rice product. Existing screening technologies mostly rely solely on the weight of the rice grains for classification, without considering factors such as color and shape, which often leads to significant errors.

[0003] With the development of science and technology, especially the rapid improvement of image processing technology and computer hardware, deep learning methods have been gradually applied to rice variety identification tasks, significantly improving the efficiency of identification and classification. Deep learning-based automatic rice variety detection has strong feature extraction and learning generalization capabilities, making it possible to build a machine vision-based automatic rice variety detection system using image processing technology. Summary of the Invention

[0004] The purpose of this invention is to provide a rice identification and screening method based on an improved YOLOv3, which solves the problem of false detection and missed detection caused by the easy neglect of rice shape and color in traditional classification and screening methods.

[0005] To achieve the above objectives, this invention provides a rice identification and screening method based on an improved YOLOv3, comprising the following steps:

[0006] Step 1: Acquire a dataset of different types of rice using a camera;

[0007] Step 2: Data augmentation is performed using adaptive gamma correction, noise addition, and rotation.

[0008] Step 3: Use annotation tools to annotate the targets in the image to obtain a label file dataset, and divide it into training and test sets;

[0009] Step 4: Construct the network model and adjust the backbone network of the original YOLOv3;

[0010] Step 5: Use the network adjusted in Step 4 to train the labeled rice dataset until the network converges, and then save the model and weight files;

[0011] Step 6: Test the dataset using the best trained model and obtain the test results for the test set.

[0012] Preferably, the specific process of data augmentation in step 2 is as follows:

[0013] Step 2.1: Data enhancement is performed by changing the image brightness through adaptive gamma correction, so that the enhanced image retains color information and maintains the grayscale range;

[0014] Step 2.2: Based on the original dataset and Step 2.1, further data augmentation is performed by adding slight Gaussian noise, salt-and-pepper noise, and speckle noise to the image, respectively.

[0015] Step 2.3: Based on Step 2.2, rotate the image to obtain the final rice image dataset.

[0016] Preferably, step 4, constructing the network model, specifically includes the following steps:

[0017] Step 4.1: Subtract the last of the five Resblock_body structures in the DarkNet53 backbone network of YOLOv3, keeping the first four structures. Perform four downsampling operations on the input 416×416 image to extract the shallow features of the input image. Then, take the feature layers of three different scales, 26×26, 52×52, and 104×104, obtained by four, three, and two downsampling operations respectively, as the subsequent feature fusion layers.

[0018] Step 4.2: After convolution and upsampling, the 26×26 feature layer is fused with the 52×52 feature layer. The 52×52 feature layer is then fused with the 104×104 feature layer after convolution and upsampling to generate feature prediction layers for targets of three scales.

[0019] Preferably, step 5, network training, specifically includes the following steps:

[0020] Step 5.1: Use the network weights from the COCO dataset as initial weights and modify the way the YOLOv3 model loads pre-trained weights.

[0021] Step 5.2: Train the network, save the training weights for each generation, freeze the backbone network in the first 50 generations of network training, train the feature pyramid FPN and the prediction layer YOLO Head, and set appropriate training parameters.

[0022] Step 5.3: After training for 50 generations, unfreeze the model parameters of the backbone network, train the entire network, and learn the rice image features until the network converges.

[0023] Preferably, the target includes chalky rice, yellow rice, black rice, polished rice, and broken rice.

[0024] Preferably, the final rice image dataset is 16 times larger than the original dataset.

[0025] Therefore, the rice identification and screening method based on the improved YOLOv3 described above has the following beneficial effects:

[0026] (1) The YOLOv3 technology in deep learning is innovatively applied to rice identification and screening, which makes up for the false detection and missed detection caused by ignoring the size and color of rice grains in traditional rice screening, and improves the accuracy of rice screening.

[0027] (2) Modify the original YOLOv3 network structure, discard the original 13×13 feature layer which is suitable for large target detection, and add a 104×104 feature layer which is suitable for small target detection. This improves the network's detection performance for small targets and is suitable for application scenarios such as rice identification and screening.

[0028] (3) Image enhancement operations are performed by using brightness transformation, adding noise and rotation, which greatly expands the dataset under limited conditions, thereby improving the training effect of the network and obtaining a better network model.

[0029] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0030] Figure 1 A flowchart illustrating the overall structure of a rice identification and screening method based on an improved YOLOv3, provided in an embodiment of the present invention.

[0031] Figure 2 A flowchart illustrating the creation of a rice dataset based on an improved YOLOv3-based rice identification and screening method is provided in this embodiment of the invention.

[0032] Figure 3 This is a schematic diagram illustrating the effect of data augmentation using adaptive gamma correction in an embodiment of the present invention;

[0033] Figure 4 This is a schematic diagram illustrating the effect of data augmentation by adding noise in an embodiment of the present invention;

[0034] Figure 5 This is a schematic diagram of the network structure of a rice identification and screening method based on an improved YOLOv3, provided in an embodiment of the present invention.

[0035] Figure 6 This is a graph showing the decreasing trend of the loss value during network training in an embodiment of the present invention.

[0036] Figure 7 This is a schematic diagram showing the recognition accuracy of the network finally trained according to an embodiment of the present invention.

[0037] Figure 8 This is a detection effect diagram of a rice identification and screening method based on an improved YOLOv3 provided in an embodiment of the present invention. Detailed Implementation

[0038] Example

[0039] The following detailed description of embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0040] like Figure 1 A rice identification and screening method based on improved YOLOv3 includes the following steps:

[0041] Step 1: Use a camera to acquire a dataset of 400 images containing different types of rice;

[0042] Step 2: Expand the dataset by performing data augmentation through adaptive gamma correction, adding noise, and rotation;

[0043] Step 3: Use annotation tools to annotate the targets in the image. The targets include chalky rice, yellow rice, black rice, polished rice, and broken rice. Obtain the corresponding label file dataset and divide it into training and test sets.

[0044] Step 4: Construct the network model. The original YOLOv3 DarkNet53 backbone network is reduced from 5 Resblock_body elements to 4, reducing one output scale to 13×13, retaining 26×26 and 52×52 output scales. The 52×52 feature map is upsampled and doubled to 104×104, then fused with the output of the second Resblock_body to obtain a 104×104 feature scale. This adjustment of the feature scale further enhances the detection capability for small targets.

[0045] Step 5: Train the improved network on the labeled rice dataset until the network converges, and save the model and weight files;

[0046] Step 6: Test the dataset using the best trained model and obtain the test results for the test set.

[0047] Figure 2This invention provides a flowchart of a rice dataset creation method based on an improved YOLOv3 for rice identification and screening, and the specific process of enhancing the rice dataset in step 2 mainly includes the following three steps:

[0048] Step 2.1: Data augmentation is performed by changing the brightness of the original rice image through adaptive gamma transform to obtain the second-generation dataset. This ensures that the enhanced image retains color information and maintains the range of grayscale, thus avoiding color gamut issues.

[0049] The formula for calculating the adaptive gamma transform is:

[0050]

[0051] Where i and j represent the x and y coordinates of a pixel, I(i,j) is the pixel value of the input image, O(i,j) is the pixel value of the output image, and γ[i,j,N(i,j)]=2 {[128-mask(i,j)] / 128} These are control parameters. The mask is obtained by first inverting the colors of the original image, and then applying a Gaussian blur with a certain radius. If the mask value is greater than 128, it means that the point is a dark pixel and the surrounding pixels are also dark. Therefore, the γ value needs to be less than 0 to brighten it. If the mask value is less than 128, it means that the current point is a relatively bright pixel and the surrounding pixels are also relatively bright. If the mask value is 128, no change will occur. At the same time, the farther the mask value is from 128, the greater the correction amount. Figure 3 This is a schematic diagram illustrating the effect of data enhancement using adaptive gamma transform in an embodiment of the present invention. For an overexposed original image, the image brightness is automatically reduced after adaptive gamma transform processing to obtain a new image of rice.

[0052] Step 2.2: Based on the original dataset and Step 2.1, further data augmentation is performed by adding slight Gaussian noise, salt-and-pepper noise, and speckle noise to the images in the original dataset and the second-generation dataset after gamma transformation, respectively, to obtain the third-generation dataset. Rice images with different effects are obtained after adding noise, as shown below. Figure 4 As shown;

[0053] Step 2.3: Based on the previous steps, rotate all the images to obtain the final rice image dataset. The final dataset size is expanded by 16 times, resulting in 6400 rice images for network training and testing.

[0054] Step 3, dataset labeling and partitioning, specifically includes the following two steps:

[0055] Step 3.1: Use the labelimg tool to label the top-left and bottom-right corner coordinates of each target in each image, as well as the target's category. The specific categories include chalky rice, yellow rice, black rice, polished rice, and broken rice. Save the labeling results as a JSON file to obtain the label file dataset corresponding to the image dataset.

[0056] Step 3.2: Randomly divide the rice image dataset and the corresponding label file dataset into training and validation sets and test sets in a 9:1 ratio. The training and validation sets are further randomly divided into training and validation sets in a 9:1 ratio. That is, 6400 * 0.9 = 5760 images are selected from the 6400 images for training and validation, and 640 images are used for subsequent performance testing of the network.

[0057] Figure 5 This diagram illustrates the improved network structure of a rice identification and screening method based on the improved YOLOv3, as provided in an embodiment of the present invention. The network consists of a 501 DarkNet-44 backbone feature extraction network, a 502 Feature Pyramid Network (FPN), and a 503 YOLO Head prediction layer. Specifically, 504 is the smallest component in the entire network, composed of a convolutional layer, batch normalization (BN), and the LeakyReLU activation function; 505 is a convolutional structure consisting of one res_unit, used by the backbone feature extraction network to deepen the network layers and fully extract features; 506 performs feature fusion on the two input feature layers, thereby enhancing feature extraction capabilities; and 507 represents a convolutional layer, where the number of channels is adjusted to adapt the network to the prediction task.

[0058] The network improvement process specifically includes the following two steps:

[0059] Step 4.1: Subtract the last of the five Resblock_body structures in the YOLOv3 backbone network DarkNet53, resulting in 508, and retain the first four convolutional structures. The input 416×416 image is then used as the feature fusion layer for subsequent layers, taking feature layers of 26×26, 52×52, and 104×104 scales obtained by downsampling four, three, and two times respectively.

[0060] Step 4.2: In the 502 feature pyramid, the 26×26 feature layer will be fused with the 52×52 feature layer after convolution and upsampling, and the 52×52 feature layer will be fused with the 104×104 feature layer after convolution and upsampling to generate feature prediction layers for targets of three scales, thereby enhancing the detection capability for small and medium-sized targets.

[0061] In step 5, the improved network is used to train and test the labeled rice dataset. This embodiment uses 6400 rice images for training and testing, including five types of rice: chalky rice, yellow rice, black rice, polished rice, and broken rice. The specific steps include:

[0062] Step 5.1: To improve network training efficiency, the network weights from the COCO dataset are used as initial weights. First, the way the YOLOv3 model loads pre-trained weights is modified to adapt it to the new network structure.

[0063] Step 5.2: Train the network and save the training weights for each generation. For the first 50 generations of network training, freeze the backbone network (501), and train only the feature pyramid (FPN, 502) and the prediction layer (YOLO Head, 503). Use the SGD optimizer with an initial learning rate of 0.01 and a batch size of 16.

[0064] Step 5.3: After training for 50 generations, unfreeze the model parameters of the backbone network, set the batch size to 8, and train the entire network until the network converges. Figure 6 Figures 601 and 602 illustrate the decreasing trends of training loss and validation loss during the training process, respectively. In the 50th generation, as the entire network is trained and the batch size is adjusted, the loss curve becomes significantly steeper. After the 70th generation, the curve gradually stabilizes, and the network eventually converges.

[0065] Finally, the best trained network was used to perform recognition tests on a rice image test set, using 640 pre-divided rice images to test the network performance. Figure 7 This is a schematic diagram illustrating the recognition accuracy of the network finally trained according to an embodiment of the present invention. Figure 8 The image shows the detection effect of a rice identification and screening method based on an improved YOLOv3, as provided in this embodiment of the invention. The improved YOLOv3 model demonstrates excellent performance in rice detection and identification, fully illustrating the effectiveness of the improved algorithm. This invention's model possesses autonomous learning capabilities and a high detection rate, making it an effective method to overcome the shortcomings of traditional rice identification and screening methods.

[0066] Therefore, the present invention adopts the above-mentioned rice identification and screening method based on improved YOLOv3 to solve the problem of false detection and missed detection caused by the easy neglect of rice shape and color in the existing traditional classification and screening methods, and at the same time improves the accuracy of rice classification and screening.

[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A rice identification and screening method based on an improved YOLOv3, characterized in that, Includes the following steps: Step 1: Acquire a dataset of different types of rice using a camera; Step 2: Data augmentation is performed using adaptive gamma correction, noise addition, and rotation. Step 3: Use annotation tools to annotate the targets in the image to obtain a label file dataset, and divide it into training and test sets; Step 4: Construct the network model and adjust the backbone network of the original YOLOv3; Step 4, which involves constructing the network model, specifically includes the following steps: Step 4.1: Subtract the last of the five Resblock_body structures in the DarkNet53 backbone network of YOLOv3, keeping the first four structures. Perform four downsampling operations on the input 416×416 image to extract the shallow features of the input image. Then, take the feature layers of three different scales, 26×26, 52×52, and 104×104, obtained by four, three, and two downsampling operations respectively, as the subsequent feature fusion layers. Step 4.2: After convolution and upsampling, the 26×26 feature layer is fused with the 52×52 feature layer. The 52×52 feature layer is then fused with the 104×104 feature layer after convolution and upsampling to generate feature prediction layers for targets of three scales. Step 5: Use the network adjusted in Step 4 to train the labeled rice dataset until the network converges, and then save the model and weight files; Step 6: Test the dataset using the best trained model and obtain the test results for the test set.

2. The rice identification and screening method based on improved YOLOv3 according to claim 1, characterized in that, The specific process of data augmentation in step 2 is as follows: Step 2.1: Data enhancement is performed by changing the image brightness through adaptive gamma correction, so that the enhanced image retains color information and maintains the grayscale range; Step 2.2: Based on the original dataset and Step 2.1, further data augmentation is performed by adding slight Gaussian noise, salt-and-pepper noise, and speckle noise to the image, respectively. Step 2.3: Based on Step 2.2, rotate the image to obtain the final rice image dataset.

3. The rice identification and screening method based on improved YOLOv3 according to claim 1, characterized in that, Step 5, network training, specifically includes the following steps: Step 5.1: Use the network weights from the COCO dataset as initial weights and modify the way the YOLOv3 model loads pre-trained weights. Step 5.2: Train the network, save the training weights for each generation, and freeze the backbone network during the first 50 generations of network training. Train the Feature Pyramid Network (FPN) and the YOLO Head prediction layer, and set appropriate training parameters; Step 5.3: After training for 50 generations, unfreeze the model parameters of the backbone network, train the entire network, and learn the rice image features until the network converges.

4. The rice identification and screening method based on improved YOLOv3 according to claim 1, characterized in that: The targets include chalky rice, yellow rice, black rice, polished rice, and broken rice.

5. The rice identification and screening method based on improved YOLOv3 according to claim 2, characterized in that: The final rice image dataset was 16 times larger than the original dataset.

Citation Information

Patent Citations

  • Sea surface target detection and identification method and system based on deep learning

    CN114140680A

  • Broken rice detection method and system

    CN115511803A