SegFormer optimization-based rice particle and impurity segmentation method

By introducing the FPN feature fusion module, LKA attention mechanism and bottleneck gnConv module into the SegFormer network, combined with data enhancement technology, the problems of inaccurate identification and large amount of calculation in the segmentation of rice particles and impurities are solved, achieving a more efficient and accurate Impurity detection.

CN118762174APending Publication Date: 2024-10-11JIANGSU UNIV OF SCI & TECH
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410641069.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

In the process of segmenting rice grains and impurities, the existing technology has problems such as inaccurate identification and slow processing speed caused by large amounts of calculations. In particular, it is difficult to effectively identify impurities in complex scenarios.

Method used

Based on the SegFormer optimization method, the MLP module is replaced with the FPN feature fusion module in the decoder, and the LKA attention mechanism and bottleneck gnConv module are added to the feature map, combined with data enhancement technology, to improve the semantic information and spatial information interaction of the feature map. , reduce the amount of calculation.

Benefits of technology

It improves the segmentation accuracy and detection speed of rice grains and impurities, especially in complex backgrounds, and reduces the computational cost and parameter amount of the network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118762174A_ABST
    Figure CN118762174A_ABST
Patent Text Reader

Abstract

The invention discloses a rice particle and impurity segmentation method based on SegFormer optimization, and the method comprises the steps: collecting rice particle and impurity images, generating a rice particle and impurity image data set, marking the rice particle and impurity image data in the data set, and obtaining a rice particle and impurity segmentation result; obtaining an expanded rice grain and impurity data set through a data enhancement technology, and further dividing the expanded rice grain and impurity data set into a training set, a verification set and a test set; an improved SegFormer network model is built; training the improved SegFormer network model by using the training set, and verifying the improved SegFormer network model by using the verification set to obtain a trained improved SegFormer network model; and finally, inputting the test set into the trained improved SegFormer network model, and comparing the obtained marked information of the segmented rice grains and impurities with the original marked information. The categories of the rice grains and impurities segmented by the method can be accurately identified, and technical support can be provided for online quality control of the rice combine harvester.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to computer image processing technology, and in particular to a rice grain and impurity segmentation method based on SegFormer optimization. Background Art

[0002] With the continuous development of information technology and modern science and technology, agricultural intelligence has become an inevitable trend in agricultural development. In recent years, deep learning has been widely used in various fields. The segmentation algorithm based on deep learning has achieved excellent results in the field of image processing and has been vigorously promoted in many industries. my country is a major agricultural country, and its rice production ranks first in the world. The impurity rate of rice grains is one of the important indicators to measure the quality of rice. For farmers, excessively high impurity rates in harvested grains will bring a certain degree of economic losses. When farmers sell grains with high impurity rates, the price will be lowered. Therefore, accurate semantic segmentation of rice impurities is of great significance to multiple links such as rice harvesting and processing.

[0003] At present, there are a lot of research and applications on the field of grain appearance detection and recognition by machine vision. For example, Mahirah et al. in Japan designed a machine vision device to calculate the proportion of impurities and broken grains in rice for combine harvester drivers, and the measurement accuracy of the device is greater than 75%. Chen Xuan combined K-Means and watershed algorithms to segment grain images, then extracted shape and color features, and used BP neural network to identify impurities and broken grains.

[0004] The above are some research results of impurity recognition algorithms in grain images, but the research is about grains in ideal conditions. The adhesion between grain grains is not as complicated as in actual conditions. In addition, segmentation errors lead to inaccurate recognition, and the large amount of calculation of neural networks affects the processing speed. The rice grain and impurity segmentation method optimized by SegFormer can effectively extract target features in complex scenes and overcome the limitations of traditional algorithms. Summary of the invention

[0005] Purpose of the invention: In order to detect various impurities in rice grains, the present invention proposes a method for segmenting rice grains and impurities based on SegFormer optimization, which effectively solves the time-consuming and labor-intensive problem caused by excessive impurities during rice harvesting and processing.

[0006] Technical solution: A method for segmenting rice grains and impurities based on SegFormer optimization of the present invention comprises the following steps:

[0007] Rice grain and impurity images are collected to generate a rice grain and impurity image dataset, the rice grain and impurity image data in the dataset are annotated, and the expanded rice grain and impurity dataset is obtained through data enhancement technology, which is further divided into training set, validation set and test set; an improved SegFormer network model is built; the improved SegFormer network model is trained with the training set and verified with the validation set to obtain the trained improved SegFormer network model; finally, the test set is input into the trained improved SegFormer network model to obtain the annotation information of the segmented rice grains and impurities and compare it with the original annotation information.

[0008] Among them, the improved SegFormer network model is improved on the basis of the SegFormer network, including: replacing part of the four MLP modules in the decoder with the FPN feature fusion module; adding the LKA attention mechanism module to each feature map after feature fusion; adding the bottleneck g after the MLP dimension reduction n Conv module.

[0009] Furthermore, the 1×1 convolution in the FPN feature fusion module upgrades the low-level features generated by the backbone network and fuses them with the upsampled high-level features, so that the final feature map has rich semantic information.

[0010] Furthermore, the LKA attention mechanism module obtains attention features for a given input feature image of size H×W×C through deep convolution, deep hole convolution and point-by-point convolution, and multiplies it with the feature image to capture long-distance dependencies.

[0011] Furthermore, bottleneck g n In the Conv module, the features are first reduced in dimension by 1×1 convolution and then passed through g n Conv then performs 1×1 convolution to increase the dimension, thereby reducing the amount of network computation.

[0012] Furthermore, LabelImg software was used to label the rice grain and impurity image data.

[0013] Furthermore, data enhancement processing includes:

[0014] (a) Mirror the image horizontally or vertically;

[0015] (b) dithering the image contrast and brightness;

[0016] (c) Cut the image and change its size;

[0017] (d) Introducing Gaussian noise interference into the image to change the image clarity;

[0018] (e) Distort the image features.

[0019] In another embodiment of the present invention, a rice grain and impurity segmentation detection system based on SegFormer optimization includes:

[0020] The data acquisition and processing module is used to collect rice grain and impurity images, generate a rice grain and impurity image data set, annotate the rice grain and impurity image data in the data set, and perform enhancement preprocessing to obtain an extended answer sheet image data set, which is further divided into a training set, a validation set, and a test set;

[0021] The model building and training module is used to build an improved SegFormer network model, train the improved SegFormer network model with a training set, and verify it with a verification set to obtain a trained improved SegFormer network model;

[0022] The detection module is used to input the test set into the trained improved SegFormer network model to obtain the detected rice grains and impurity labeling information;

[0023] Among them, the improved SegFormer network model is improved on the basis of the SegFormer network, including: replacing part of the four MLP modules in the decoder with the FPN feature fusion module; adding the LKA attention mechanism module to each feature map after feature fusion; adding the bottleneck g after the MLP dimension reduction n Conv module.

[0024] In another embodiment of the present invention, an electronic device includes:

[0025] at least one processor, and

[0026] a memory communicatively connected to the at least one processor; wherein,

[0027] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the above-mentioned method for segmenting rice particles and impurities based on SegFormer optimization.

[0028] In one embodiment of the present invention, a storage medium stores a computer program, and when the computer program is executed by at least one processor, the steps of the above-mentioned method for segmenting rice grains and impurities based on SegFormer optimization are implemented.

[0029] Beneficial effects: Compared with the prior art, the significant technical effects of the present invention are as follows: 1. Based on the SegFormer network, the present invention replaces the four MLP parts with the FPN feature fusion module, which ensures that each feature map has richer semantic information while ensuring that the parameters remain unchanged, and at the same time ensures the improvement of detection accuracy; 2. The present invention adds the LKA attention mechanism after the FPN feature fusion module, which can capture long-term relationships with a small amount of computational cost and parameters; 3. The bottleneck g n In the Conv module, the features are first reduced in dimension by 1×1 convolution and then passed through g n Conv then performs 1×1 convolution to increase the dimension, achieving efficient and high-order spatial information interaction and reducing training parameters; 4. The present invention is more accurate in segmenting rice particles and impurities under complex backgrounds.

[0030] The present invention integrates artificial intelligence and industrial development, scientifically guiding people in the agricultural field to conduct effective identification, while improving the accuracy of detecting the impurity rate of rice. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 is a flow chart of the method of the present invention;

[0032] Figure 2 are original images of rice grains and impurities in an embodiment of the present invention; wherein (a) is an example of a rice grain image, (b) is an example of a stem impurity image, and (c) is an example of a branch impurity image;

[0033] Figure 3 yes Figure 2 The images of rice grains and impurities after the original image is preprocessed; (a) is the original image, (b) is the saturation enhanced preprocessed image, (c) is the contrast enhanced preprocessed image, (d) is the flipped preprocessed image, and (e) is the feature distorted preprocessed image;

[0034] Figure 4 is a schematic diagram of the improved SegFormer network structure in an embodiment of the present invention;

[0035] Figure 5 Schematic diagram of the Mix-FFN structure in the present invention;

[0036] Figure 6 It is a schematic diagram of the FPN structure in the present invention;

[0037] Figure 7 It is a schematic diagram of the structure of the LKA attention mechanism module in the present invention;

[0038] Figure 8 is the bottleneck g in the present invention nConv module structure diagram; (a) is the bottleneck g n Conv module schematic diagram, (b) is g n Conv module diagram;

[0039] Fig. 9 is the image of the segmented rice grains and impurities; DETAILED DESCRIPTION

[0040] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0041] The present invention provides a method for segmenting rice grains and impurities based on SegFormer optimization. First, a Daheng MER-500-14GC industrial camera and a C1218-5M industrial machine vision lens with a focal length of 12 mm and an aperture range of f1.8-f16 are selected, and a ring-shaped white light LED (model: YSC-R9060-W) is used as a light source for sampling to form an image acquisition system. 1,000 pictures were taken, and the data set was expanded to 3,000 pictures by data enhancement preprocessing operations; secondly, a lightweight convolutional neural network based on SegFormer improvement was established, and the original four MLP modules were replaced with the FPN feature fusion module in the decoder part, and the LKA attention mechanism module was added after fusion, and the bottleneck g was added after the dimensionality reduction in the second MLP module part. n Conv module. Then the rice grains and impurity images are sent to the built model in batches, and the training hyperparameters are set to generate the detection weight file. Finally, the test set is input into the trained model to obtain the annotation results of the segmented rice grains and impurities. The rice grains and impurities segmented by the present invention can clearly identify objects, providing technical support for the online quality control of rice combine harvesters. Figure 1 As shown, the specific steps include:

[0042] (1) Select 1000 images of rice grains and impurities taken by the image acquisition system, annotate them, and perform data enhancement preprocessing on the image dataset; divide the training set, validation set, and test set into a ratio of 8:1:1;

[0043] The methods of image data enhancement preprocessing include:

[0044] (a) Mirror the image horizontally or vertically;

[0045] (b) dithering the image contrast and brightness;

[0046] (c) Cut the image and change its size;

[0047] (d) Introducing Gaussian noise interference into the image to change the image clarity;

[0048] (e) Distorting the features of the image.

[0049] Each image undergoes at least one of the above preprocessing operations.

[0050] Specifically, the LabelImg software was first used to label rice grains, stems, and branches, and the size was limited to 800 × 800. In order to expand the number of images, each image was horizontally or vertically flipped, contrast enhanced or weakened, cut to size, introduced Gaussian noise interference, and feature distorted to expand the image to 3000 images. Figure 3 (a) is the original image. Figure 3 (b) to (f) are images after data enhancement.

[0051] (2) Build an improved SegFormer network model, which consists of two parts: encoder and decoder. First, the encoder is stacked by Transformer Block; it contains three modules: Efficient Self-Attention, Mix-FFN and Overlap Patch Embedding. Secondly, the four MLP modules in the decoder are partially replaced with FPN feature fusion modules; an LKA attention mechanism module is added to each feature map after feature fusion; and a bottleneck g is added after MLP dimensionality reduction. n Conv module. The improved SegFormer network model structure is as follows Figure 4 shown.

[0052] In order to enhance the role of high-order spatial interactions and enable the network to further improve its modeling capabilities, g n Conv is optimized to design the bottleneck g n Conv module, bottleneck g n The Conv module consists of two cheap 1×1 convolutions and g n Conv module is used to maintain accuracy while reducing the number of network parameters. n The Conv module reduces the dimension of the obtained feature information first and then increases the dimension to fully generalize the network performance.

[0053] Specific:

[0054] In the encoder part, an 800×800×3 image is input, and first passes through the Overlap PatchEmbedding module, which is a (7, 4, 3) ordinary convolution. Then, it passes through four Transformer Blocks, each of which passes through three modules: Efficient Self-Attention, Mix-FFN, and Overlap PatchEmbedding. After that, the Overlap Patch Embedding of the three Transformer Blocks is a (3, 2, 1) ordinary convolution. Each Transformer Block will output a feature image. The first output image feature size is 200×200×32, the second output image feature size is 100×100×64, the third output image feature size is 50×50×160, and the fourth output image feature size is 25×25×256.

[0055] Note: (7, 4, 3) represents the convolution size with a kernel of 7, a stride of 4, and a padding of 3;

[0056] (3, 2, 1) represents the convolution size with a kernel of 3, a stride of 2, and a padding of 1.

[0057] In the decoder part, the four images output by the encoder are passed through the FPN feature fusion module, so that the image is still the same size as the encoder output but with the same number of channels and the fourth feature Figure 1 Similarly, four output image feature sizes of 200×200×256, 100×100×256, 50×50×256, and 25×25×256 are obtained, but each feature map has richer semantic information. The four feature maps output from the FPN feature fusion module are then passed through the LKA attention module to capture long-distance dependencies. After that, the first three feature maps are upsampled to 200×200 and concatenated to obtain an output image feature size of 200×200×1024. Then, an MLP is used to reduce the dimension of the concatenated features to obtain an output image feature size of 200×200×256. Then, after the bottleneck g n The Conv module is mainly for high-order spatial information interaction. Finally, a feature map of size 200×200×256 is obtained. Finally, a 1×1 convolution is used to reduce the number of feature map channels to the number of categories, resulting in a feature map of size 200×200×4.

[0058] The Transformer Block module passes through three modules: Efficient Self-Attention, Mix-FFN and OverlapPatch Embedding. The first is the Efficient Self-Attention module. After three linear changes, Q, K, and V are obtained. After the Self-Attention calculation, the calculation formula is as follows:

[0059]

[0060] Then, after passing through the Mix-FFN module, a 3×3 convolution is inserted between the two MLPs and then added to the original features. The purpose of inserting a 3×3 convolution is to dynamically express the positional relationship between patches. The Mix-FFN module structure is as follows Figure 5 As shown. Finally, through the Overlap Patch Embedding module, that is, through a normal convolution, the features can be divided into multiple patches of the same size, and each patch has an overlapping part with the previous patch. The Mix-FFN module structure is as follows Figure 5 as shown in .

[0061] The structure of the FPN feature fusion module is to upsample the fourth output feature map and add it to the feature map after the third output feature map is upgraded by 1×1 convolution to obtain a fused image. Then, the fused feature map is continued to perform the same operation with the second output feature map. The first output feature map is also fused with the feature map after the second output feature map is fused. The structure of the FPN feature fusion module is as follows: Figure 6 as shown in .

[0062] The LKA attention module absorbs the advantages of convolution and Self-Attention, including local structural information, long-range dependency and adaptability. At the same time, it also avoids their shortcomings such as ignoring adaptability in the channel dimension. LKA is similar to MobileNet. LKA decomposes the convolution into three parts: depth convolution, depth hole convolution and point convolution. After the depth convolution, depth hole convolution and point convolution, the attention map is obtained, and finally the point multiplication is performed with the original feature map. LKA not only achieves adaptability in the spatial dimension, but also achieves adaptability in the channel dimension. The structure of the LKA attention module is as follows: Figure 7 as shown in .

[0063] Bottleneck n The Conv module is composed of two 1×1 convolutions and g n Conv module, first through a 1 × 1 convolution to reduce the number of channels, and then through g nConv module, and finally restores the original channel size through 1×1 convolution. This reduces the number of network parameters while maintaining accuracy. n The Conv module module structure is as follows Figure 8 As shown in (a).

[0064] g n The Conv module improves the modeling ability of the network by improving high-order spatial interactions. First, the number of channels is doubled through convolution, and then the feature map is divided according to the channels, with a division ratio of 1:7. Then the feature map at one end is subjected to deep convolution, and the number of channels remains unchanged. Then the feature map after deep convolution is divided again, with a division ratio of 1:2:4. Then the feature map with a division ratio of 1 is dot-multiplied with the feature map at the other end of the first division, and then the number of channels is doubled through convolution, which completes the first-order spatial interaction. Then the feature map that completes the first-order spatial interaction continues to be dot-multiplied with the feature map with a secondary division ratio of 2, and then the number of channels is doubled through convolution, completing the second-order spatial interaction. The feature map of the second-order spatial interaction is dot-multiplied with the feature map with a secondary division ratio of 4 again, and then the number of channels is kept consistent with the number of input channels through convolution, and finally the third-order spatial interaction is completed. Through these three spatial interactions, the modeling ability of the network is improved.

[0065] (3) Input the training set into the improved SegFormer network model built above, start training for 800 rounds after setting the hyperparameters, and verify the trained network model with the validation set. Finally, select the model with the best detection weight file as the trained improved SegFormer network model, and save the detection weight file.

[0066] During the training process, the training set is used as the image for each round of epch training, mainly used to determine the parameter variables obtained by the model through learning, such as weight w and bias b; the validation set is used to determine the network structure and adjust the parameters of the model in the later stage of epch during the training process. During network training, the learning rate update method is set to segmented update.

[0067] In this embodiment, the hyperparameters set are: picture size / pixel is 800×800, batch processing number is 8, number of iterations is 800, optimizer is Adam, initial learning rate is 0.001, and the learning rate will be adjusted automatically according to the cosine method.

[0068] The hardware system used in this experiment is Windows 10, the processor CPU is Intel (R) Platinum 8255C (40GB), the GPU is RTX 3080Ti (10GB), Python 3.8 and PyTorch 1.11.0, and the CUDA version is 11.3.

[0069] (4) Input the test set into the above-trained improved SegFormer network model to obtain the detected rice grain and impurity labeling results. Fig. 9 (a)~(f) are the results after testing the test set.

[0070] In order to detect impurities in rice grains, the present invention proposes a rice grain and impurity segmentation method based on SegFormer optimization, which effectively solves the time-consuming and labor-intensive problem caused by excessive impurities during rice harvesting and processing. By introducing the FPN feature fusion module in the decoder part, the feature map has richer semantic information, while ensuring the improvement of detection accuracy; adding the LKA attention mechanism after the FPN module can capture long-term relationships with a small amount of computational cost and parameters, especially for impurity detection. Finally, after the MLP is reduced in dimension, the bottleneck g is added. n The Conv module realizes efficient and high-order spatial information interaction and reduces training parameters, further improving the modeling capability.

[0071] In another embodiment of the present invention, a rice grain and impurity segmentation detection system based on SegFormer optimization includes:

[0072] The data acquisition and processing module is used to collect rice grain and impurity images, generate a rice grain and impurity image data set, annotate the rice grain and impurity image data in the data set, and perform enhancement preprocessing to obtain an extended answer sheet image data set, which is further divided into a training set, a validation set, and a test set;

[0073] The model building and training module is used to build an improved SegFormer network model, train the improved SegFormer network model with a training set, and verify it with a verification set to obtain a trained improved SegFormer network model;

[0074] The detection module is used to input the test set into the trained improved SegFormer network model to obtain the detected rice grains and impurity labeling information;

[0075] Among them, the improved SegFormer network model is improved on the basis of the SegFormer network, including: replacing part of the four MLP modules in the decoder with the FPN feature fusion module; adding the LKA attention mechanism module to each feature map after feature fusion; adding the bottleneck g after the MLP dimension reduction n Conv module.

[0076] In another embodiment of the present invention, an electronic device includes:

[0077] at least one processor, and

[0078] a memory communicatively connected to the at least one processor; wherein,

[0079] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the above-mentioned method for segmenting rice particles and impurities based on SegFormer optimization.

[0080] The electronic device includes a grain collecting device, which is mainly composed of a collecting trough, a push-pull electromagnet, a movable baffle at the bottom, and an industrial camera. The collecting trough is used to stack the collected grains. The electromagnet is connected to the baffle, and when the electromagnet is energized, the baffle can be pushed away to release the grains. The industrial camera can capture images of the grains falling into the collecting trough in real time for system detection; when executed, the steps of the above-mentioned method for segmenting rice grains and impurities based on SegFormer optimization are implemented.

[0081] In one embodiment of the present invention, a storage medium stores a computer program, and when the computer program is executed by at least one processor, the steps of the above-mentioned method for segmenting rice grains and impurities based on SegFormer optimization are implemented.

[0082] The storage medium includes Qt and OpenCV. A rice grain and impurity detection page system is established through Qt; OpenCV is used to recognize images and realize human-computer image information interaction. When executed, the steps of the rice grain and impurity segmentation method based on SegFormer optimization are realized.

[0083] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0084] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

Claims

1. A method for segmenting rice grains and impurities based on SegFormer optimization, characterized in that: The following steps are involved: S1, collecting rice grains and impurity images, generating a rice grains and impurity image dataset, annotating the rice grains and impurity image data in the dataset, and obtaining an expanded rice grains and impurity dataset through data enhancement technology, which is further divided into a training set, a validation set, and a test set; S2. Build an improved SegFormer network model; S3, train the improved SegFormer network model with the training set, and verify it with the verification set to obtain the trained improved SegFormer network model; S4. Finally, the test set is input into the trained improved SegFormer network model to obtain the annotation information of the segmented rice grains and impurities, which is then compared with the original annotated image. The improved SegFormer network model is improved on the basis of the SegFormer network, including: replacing the four MLP modules in the decoder with the FPN feature fusion module; adding the LKA attention mechanism module to each feature map after feature fusion; adding the bottleneck g after the MLP dimension reduction n Conv module.

2. The method for segmenting rice grains and impurities based on SegFormer optimization according to claim 1, characterized in that: The 1×1 convolution in the FPN feature fusion module upgrades the low-level features generated by the backbone network and fuses them with the upsampled high-level features, so that the final feature map has rich semantic information.

3. The method for segmenting rice grains and impurities based on SegFormer optimization according to claim 1, characterized in that: For a given input feature image of size H×W×C, the LKA attention mechanism module obtains attention features through deep convolution, deep hole convolution and point-by-point convolution, and multiplies it with the feature image to capture long-distance dependencies.

4. The method for segmenting rice grains and impurities based on SegFormer optimization according to claim 1, characterized in that: Bottleneck n In the Conv module, the features are first reduced in dimension by 1×1 convolution and then passed through g n Conv then performs 1×1 convolution to increase the dimension, thereby reducing the amount of network computation.

5. The method for segmenting rice grains and impurities based on SegFormer optimization according to claim 1, characterized in that: LabelImg software was used to label rice grain and impurity image data.

6. The method for segmenting rice grains and impurities based on SegFormer optimization according to claim 1, characterized in that: Data enhancement processing includes: (a) Mirror the image horizontally or vertically; (b) dithering the image contrast and brightness; (c) Cut the image and change its size; (d) Introducing Gaussian noise interference into the image to change the image clarity; (e) Distort the image features.

7. A method for segmenting rice grains and impurities based on SegFormer optimization, characterized in that: include: The data acquisition and processing module is used to collect rice grain and impurity images, generate a rice grain and impurity image data set, annotate the rice grain and impurity image data in the data set, and perform enhancement preprocessing to obtain an extended answer sheet image data set, which is further divided into a training set, a validation set, and a test set; The model building and training module is used to build an improved SegFormer network model, train the improved SegFormer network model with a training set, and verify it with a verification set to obtain a trained improved SegFormer network model; The detection module is used to input the test set into the trained improved SegFormer network model to obtain the detected rice grains and impurity labeling information; The improved SegFormer network model is improved on the basis of the SegFormer network model, including: replacing the four MLP modules in the decoder with the FPN feature fusion module; adding the LKA attention mechanism module to each feature map after feature fusion; adding the bottleneck g after the MLP dimension reduction. n Conv module.

8. An electronic device, characterized in that: include: at least one processor, and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of a method for segmenting rice particles and impurities based on SegFormer optimization as described in any one of claims 1 to 7.

9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by at least one processor, the steps of the method for segmenting rice grains and impurities based on SegFormer optimization as described in any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Crop growth prediction method and device, equipment and storage medium

    CN121838124A

  • Crop growth prediction method, device, equipment and storage medium

    CN121838124B