Agricultural product drying stage online prediction method
Through the improvement of the drying experiment and YOLOv7-tiny model, combined with attention mechanism module and image enhancement technology, the problem of online detection of agricultural products in the drying stage is solved, and efficient and accurate monitoring and judgment of the drying stage is achieved.
Patent Information
- Application Number
- CN202410332879.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-22
- Publication Date
- 2024-12-20
AI Technical Summary
The prior art is difficult to realize online detection of agricultural products in the drying stage, resulting in large drying energy consumption and low product quality, and lack of effective computer vision models for online monitoring.
The state image and weight information were obtained through drying experiments, the drying rate curve was drawn, and the drying stage was divided into constant speed and slow speed stages. The YOLOv7-tiny model was used and the attention mechanism module was introduced to image enhancement and labeling, and the model recognition accuracy was improved. speed.
It realizes rapid online detection of agricultural products drying stage, improves recognition accuracy and robustness, reduces model training complexity, and is suitable for adaptive intelligent drying systems.
Smart Images

Figure CN119167223A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of drying and relates to an online prediction method for the drying stage of agricultural products. Background Art
[0002] Nearly one-third of agricultural products are lost worldwide every year, and drying is one of the important and common agricultural product processing units. It reduces the activity of microorganisms by reducing the moisture content in the material, thereby extending the storage time. At present, domestic and foreign scholars' research on agricultural product drying mainly focuses on energy consumption and product quality. Drying is an energy-intensive unit, and its energy consumption accounts for 20% to 25% of food processing. Inappropriate drying process will not only lead to high drying energy consumption, but also lead to low product quality. The best way to reduce energy consumption and improve quality is to establish an online adaptive drying model. In the drying rate curve: the horizontal axis is the dry basis moisture content, the vertical axis is the drying rate, and the drying rate curve is divided into three stages, namely the speed increase stage, the constant speed stage and the speed decrease stage. The premise of establishing an adaptive drying model is to achieve accurate detection of the drying state of the material, that is, drying stage detection, to achieve online optimization and adjustment of drying process parameters, to ensure the quality of the final product, and to achieve green and efficient drying. Therefore, it is very necessary to realize online drying stage detection of agricultural products.
[0003] The necessary method to realize the online detection of agricultural products in the drying stage is non-destructive testing technology, such as non-destructive testing based on dielectric properties, infrared spectroscopy, computer vision or hyperspectral. Mohamed Hemis et al. studied the dielectric properties of rapeseed, corn, rice, soybean and wheat, and determined the relationship between dielectric properties and the frequency, moisture content and density of seed powder; Ning Jiang, Gao Yaping et al. used the network analyzer method to explore the relationship between the drying process of agricultural products and moisture content, but the dielectric properties are not only affected by moisture content, but also by factors such as temperature and frequency. It is difficult to realize the online detection of the drying stage of agricultural products based on dielectric properties. Hyperspectral imaging (HSI) can not only capture the spectral data of the target sample in different frequency bands, but also obtain the external image features of the sample. Its limitation is that HIS data acquisition time is long, processing is slow, instrument cost is high, and it is difficult to use for online detection. Overcoming these shortcomings mainly depends on the development of hyperspectral technology and computer computing power; near infrared spectroscopy has good internal detection capabilities, and for the drying process, the external features of agricultural products change significantly, and the use of computer vision technology is a low-cost and high-efficiency option.
[0004] In recent years, computer vision has been widely used as a simple, reliable, non-destructive and economical method to measure physical properties such as moisture content, color parameters, texture, etc. in the food drying process. For offline drying detection, Wang Rui et al. established a simple and inexpensive machine vision system to explore the relationship between the moisture content of corn kernels and images. The results showed that the machine vision technology proposed in this study has the potential to quickly measure the moisture content of grains in industry, but it has not been applied to online drying, and the recognition accuracy needs to be improved.
[0005] Most of the current research results on computer vision technology for online monitoring of agricultural products in the drying stage focus on hardware devices, and lack computer vision models for online detection of agricultural products in the drying stage. Summary of the invention
[0006] The purpose of the present invention is to overcome the deficiencies of the prior art and provide an online prediction method for the drying stage of agricultural products.
[0007] The present invention solves the technical problem by the following technical solutions:
[0008] An online prediction method for the drying stage of agricultural products, characterized in that the steps of the method are:
[0009] S1. Obtain state images and weight information of agricultural products during drying through drying experiments;
[0010] S2, using the drying weight information obtained in S1, draw a drying rate curve, and according to the changing trend of the drying rate curve, divide the drying stage into two stages: a constant rate drying stage and a decreasing rate drying stage, and group the agricultural product state images corresponding to the above two stages into a constant rate drying group and a decreasing rate drying group;
[0011] S3, annotate the state images grouped in S2 according to the proportions, and obtain an annotation file;
[0012] S4. Use image enhancement technology to increase the data set and improve model robustness and recognition accuracy;
[0013] S5. Modify the YOLOv7-tiny model header file, introduce different attention mechanism modules into the head and backbone to improve the model recognition accuracy and speed;
[0014] S6. Output prediction model of agricultural product drying stage and comparative evaluation of models.
[0015] Moreover, S1 specifically includes: cutting and numbering the agricultural products according to the size required by the test experiment, placing them in a hot air drying oven to dry them under constant drying conditions, and collecting images and weight information of the agricultural products every 15 minutes until the weight change is less than the absolute dry weight, and the drying is considered to be completed.
[0016] Moreover, the S2 is specifically:
[0017] 1) Calculate the dry basis moisture content based on the collected agricultural product weight information, and use data processing software to draw a drying rate curve. The dry basis moisture content calculation method is shown in formula (1). Under constant drying conditions, the drying rate calculation method is shown in formula (2):
[0018]
[0019]
[0020] Where: M is the dry basis moisture content of the material, g / g;
[0021] m i is the mass of the material at time i, g;
[0022] m is the absolute dry mass, g;
[0023] U is the drying rate, g / (m 2 s);
[0024] S is the contact area between material and air, m 2 ;
[0025] The drying rate curve is the UM curve;
[0026] 2) The drying rate curve of agricultural products changes significantly according to the slope, with the AB section being the preheating stage, the BC section being the constant speed stage, and the CD section being the speed-decreasing drying stage;
[0027] 3) The images corresponding to the AB and BC segments of the drying curve are combined and recorded as a constant-speed drying group, and the images corresponding to the CD segment are combined and recorded as a decreasing-speed drying group.
[0028] Moreover, the S3 is specifically:
[0029] 1) Group the XML tag file containing classification information and coordinate information and the agricultural product image in a ratio of 8:1:1 to obtain the training group train, the training process test group val and the model test group test, place them in the YOLOv7-tiny model specified folder, configure the training parameters, start training and obtain the training results;
[0030] 2) Use the online annotation tool make sense to annotate all images, label the constant speed drying group as constant, label the reduced speed drying group as J1, and output the labeled file.
[0031] Moreover, the S4 specifically includes: using image enhancement technology to perform geometric transformation and light and shadow transformation on the collected images and annotation files to increase the data set and improve the robustness of the model.
[0032] Moreover, the S5 is specifically:
[0033] 1) Change the prior frame size of the YOLOv7-tiny model, use the K-means algorithm to cluster the image data group to obtain new anchors parameters, so that the newly obtained anchors parameters are more consistent with the pixel ratio of the target image in the potato drying process in the entire picture, thereby improving the model accuracy;
[0034] 2) Modify the YOLOv7-tiny model. On the basis of the original network, add an attention mechanism module, add a lightweight SimAM attention mechanism module to the original backbone structure of yolov7-tiny, and introduce the GAM global attention mechanism module at the front end of the head structure output to obtain a new network model.
[0035] Moreover, the S6 is specifically:
[0036] 1) Run the unmodified and newly modified yolov7-tiny network models to obtain the best.pt and best-xin.pt files respectively, wherein the best-xin.pt file is the online prediction model for the drying stage of agricultural products of the present invention, and the best.pt file is the experimental control model;
[0037] 2) Calculate the performance parameters of the above two models respectively and compare them; obtain the confusion matrices of the two models, namely: the model group obtained by modifying the network model and the control group obtained by not modifying the network model. According to the confusion matrix, the precision rate P, recall rate R, accuracy rate A, F1 value, and mAP are calculated. The specific formula is as follows:
[0038]
[0039]
[0040]
[0041]
[0042] Among them: TP represents the true positive example, that is, the positive example that is correctly classified;
[0043] TN represents a true negative example, i.e. a negative example that is correctly classified;
[0044] FP stands for false positive, which means a negative example is mistakenly classified as a positive example.
[0045] FN (represents a false negative example, that is, a positive example that is mistakenly classified as a negative example;
[0046] The two models were tested in the test group. The obtained best-xin.pt and best.pt files were used to detect the images in the test group files and the frame rate FPS was calculated. The formula is as follows:
[0047]
[0048] Tot=Nms+Inf (9)
[0049] Where: Inf is the inference speed; Nms is the post-processing time; Tot is the detection time.
[0050] The advantages and beneficial effects of the present invention are:
[0051] It can be used to quickly detect changes in the drying stage of agricultural products online, laying the foundation for the establishment of an adaptive intelligent drying system. Labeling the drying information of agricultural products in the image and modifying the size of the prior frame can effectively improve the accuracy and precision of deep learning; using the Yolov7 model, it can accurately detect and judge the drying stage in real-time applications while maintaining a high processing speed; using data enhancement methods to expand the constant-speed drying stage data to improve the robustness and accuracy of the model; modifying the Yolov7 network and adding an attention mechanism module to greatly improve the model recognition accuracy; performing layer pruning and channel pruning on the Yolov7 network to reduce the complexity of model training and greatly reduce the time of model training, providing convenience for the subsequent expansion of agricultural product detection types. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 is a flow chart of the present invention;
[0053] Figure 2 This is a drying rate curve obtained in an embodiment of the present invention;
[0054] Figure 3 This is a structural diagram of an image enhancement technology used in an embodiment of the present invention;
[0055] Figure 4 This is a structural diagram of the K-means clustering method used in the embodiment of the present invention;
[0056] Figure 5 This is a structural diagram of the SimAM and GAM attention mechanisms added to yolov7-tiny in an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The present invention is further described in detail below through specific examples. The following examples are only illustrative and not restrictive, and the protection scope of the present invention cannot be limited thereto.
[0058] like Figure 1 As shown, an online prediction method for the drying stage of agricultural products is innovative in that the method comprises the following steps:
[0059] 1. Obtain pictures and quality information of agricultural products during drying process through drying experiments;
[0060] An experiment was designed to peel the potatoes and cut them into several circular slices with diameters of 48 mm and 35 mm and a thickness of about 5 mm. The slices were numbered and placed in a hot air drying oven to dry under constant drying conditions. Images and quality information were collected every 15 minutes until the mass change was less than 0.02 g, at which point the drying was considered complete.
[0061] 2. Draw a drying rate curve based on the drying quality information obtained in step 1. According to the changing trend of the drying rate curve, the drying stage is divided into two stages: constant rate drying stage and decreasing rate drying stage. Group the pictures corresponding to the two stages into a constant rate drying group and a decreasing rate drying group:
[0062] 1) Calculate the dry basis moisture content based on the collected quality information, and use Origin2019 (or other data processing software) to draw the drying rate curve. The moisture content calculation method is shown in formula (1). Under constant drying conditions, the drying rate calculation method is shown in formula (2).
[0063]
[0064]
[0065] Where: M is the dry basis moisture content of the material, g / g;
[0066] mi is the mass of the material at time i, g;
[0067] m is the absolute dry mass, g;
[0068] U is the drying rate, g / (m 2 s);
[0069] S is the contact area between material and air, m 2 .
[0070] The drying rate curve is the UM curve. The drying rate curve of each potato slice is drawn according to the formula using Origin2019 drawing software. Some of the drawn drying rate curves are shown below: Figure 2 shown.
[0071] 2) If Figure 2As shown in the markings, the drying rate curve of each potato slice changes significantly according to the slope. The AB segment is the preheating stage, the BC segment is the constant speed stage, and the CD segment is the speed reduction drying stage.
[0072] 3) The images corresponding to the AB and BC segments of the drying curve are combined and recorded as a constant-speed drying group, and the images corresponding to the CD segment are combined and recorded as a decreasing-speed drying group.
[0073] 3. Group the images according to proportion and mark them to obtain the annotation files to form the data set:
[0074] 1) Group the XML tag file containing classification information and coordinate information with the agricultural product image in a ratio of 8:1:1 to obtain the training group (train), the training process test group (val), and the model test group (test), and place them in the YOLOv7-tiny specified folder. Configure the training parameters, start training, and get the training results.
[0075] 2) Use the online annotation tool make sense to annotate all the images. The constant speed drying group is labeled as constant, and the reduced speed drying group is labeled as J1. The labeled file is output.
[0076] 4. Use image enhancement technology to increase the data set and improve model robustness and recognition accuracy: Use image enhancement technology to perform geometric transformation and light and shadow transformation on the collected images and annotation files to increase the data set and improve model robustness. The structure diagram of the image enhancement algorithm is shown in Figure 3.
[0077] The images of the constant-speed drying stage were enhanced from 342 to 1368, and 1072 images of the reduced-speed drying stage were collected, forming a data set of 2440 images.
[0078] 5. Modify the original yolov7-tiny network:
[0079] 1) Modify the YOLOv7-tiny network model and change the header file to improve the model recognition accuracy and enhance the YOLOv7-tiny model: change the size of the prior box and use the K-means algorithm to obtain new anchors parameters to make it more consistent with the pixel ratio of the target image of the potato drying process in the entire picture, thereby improving the model accuracy. The steps are as follows: Figure 4 shown.
[0080] The original anchors are:
[0081]
[0082] The row anchors values obtained by the clustering algorithm are:
[0083]
[0084] 2) Modify the YOLOv7-tiny model and add an attention mechanism module based on the original network. Specifically, add a lightweight SimAM attention mechanism module to the original backbone structure of yolov7-tiny and introduce a GAM global attention mechanism module at the head output front end of the head structure. Get a new network model. See the idea route Figure 5 .
[0085] 6. Carry out model evaluation and output the drying stage prediction model:
[0086] 1) Run the unmodified and newly modified yolov7-tiny network models to obtain the best.pt and best-xin.pt files respectively, wherein the best-xin.pt file is the online prediction model for the drying stage of agricultural products of the present invention, and the best.pt file is the experimental control model;
[0087] 2) Calculate the performance parameters of the above two models respectively and compare them.
[0088] The confusion matrices of the two models were obtained, namely the model group obtained by modifying the network model and the control group obtained by not modifying the network model, as shown in Tables 1 and 2;
[0089] Table 1
[0090] Best-xin.pt Group Constant J1 Constant 0.97(TP) 0.03(FP) J1 0.03(FN) 0.97(TN)
[0091] Table 2
[0092]
[0093]
[0094] According to the confusion matrix, we can calculate the precision rate P, recall rate R, accuracy rate A, F1 value, and mAP. The specific formula is as follows:
[0095]
[0096]
[0097]
[0098]
[0099] Among them: TP represents the true positive example, that is, the positive example that is correctly classified;
[0100] TN represents a true negative example, i.e. a negative example that is correctly classified;
[0101] FP stands for false positive, which means a negative example is mistakenly classified as a positive example.
[0102] FN (represents a false negative example, that is, a positive example that is mistakenly classified as a negative example;
[0103] The two models were tested in the test group. The obtained best-xin.pt and best.pt files were used to detect the images in the test group files and the frame rate FPS was calculated. The formula is as follows:
[0104]
[0105] Tot=Nms+Inf (9)
[0106] Where: Inf is the inference speed; Nms is the post-processing time; Tot is the detection time.
[0107] The running result of Best-xin.pt is: NMS=1.5ms, Inf=3.9ms, and the calculated FPS=185.18.
[0108] The running result of Best.pt is: NMS=1.5ms, Inf=17.2ms, and the calculated FPS=53.476
[0109] 3) The performance parameters of the two models are compared, as shown in Table 3.
[0110] Table 3
[0111]
[0112]
[0113] By comparison, it can be seen that the parameters of the online prediction model best-xin.pt for the drying stage of agricultural products proposed in the present invention are better than those of the unmodified YOLOv7-tiny model, the recognition accuracy A is increased by 7 percentage points, and the running inference time is reduced from 17.2ms to 3.9ms.
[0114] Note: The closer the P, R, A, and F1 values are to 1, the higher the model accuracy is; the larger the FPS value (the inverse of the total recognition time), the faster the recognition speed is.
[0115] The present invention completes the online monitoring of the drying stage through model improvement, and has the following advantages and outstanding effects:
[0116] ① The present invention fills the gap in the online detection method of the drying stage of agricultural products, and can collect image information online and convert it into the drying stage information of agricultural products.
[0117] ② The present invention adopts an improved yolov7-tiny model, adds a GAM global attention mechanism to the head part, and adds a SimAM lightweight attention mechanism module to the backbone part, so that the model detection accuracy is improved from 88.6% of the original model to 97%.
[0118] ③Compared with the original model, the improved model runs much faster, with the inference speed increased from 17.2ms to 3.9ms.
[0119] Although the embodiments and drawings of the present invention are disclosed for illustrative purposes, those skilled in the art will appreciate that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the scope of the present invention is not limited to the contents disclosed in the embodiments and drawings.
Claims
1. An online prediction method for the drying stage of agricultural products, characterized by: The steps of the method are: S1. Obtain state images and weight information of agricultural products during drying through drying experiments; S2, using the drying weight information obtained in S1, draw a drying rate curve, and according to the changing trend of the drying rate curve, divide the drying stage into two stages: a constant rate drying stage and a decreasing rate drying stage, and group the agricultural product state images corresponding to the above two stages into a constant rate drying group and a decreasing rate drying group; S3, annotate the state images grouped in S2 according to the proportions, and obtain an annotation file; S4. Use image enhancement technology to increase the data set and improve model robustness and recognition accuracy; S5. Modify the YOLOv7-tiny model header file, introduce different attention mechanism modules into the head and backbone to improve the model recognition accuracy and speed; S6. Output prediction model of agricultural product drying stage and comparative evaluation of models.
2. The method for online prediction of the drying stage of agricultural products according to claim 1, characterized in that: Specifically, S1 includes: cutting and numbering the agricultural products according to the size required by the test, placing them in a hot air drying oven and drying them under constant drying conditions, collecting images and weight information of the agricultural products every 15 minutes, until the weight change is less than the absolute dry weight, and the drying is considered to be complete.
3. The method for online prediction of drying stage of agricultural products according to claim 1, characterized in that: The S2 is specifically: 1) Calculate the dry basis moisture content based on the collected agricultural product weight information, and use data processing software to draw a drying rate curve. The dry basis moisture content calculation method is shown in formula (1). Under constant drying conditions, the drying rate calculation method is shown in formula (2): Where: M is the dry basis moisture content of the material, g / g; m i is the mass of the material at time i, g; m is the absolute dry mass, g; U is the drying rate, g / (m 2 s); S is the contact area between material and air, m 2 ; The drying rate curve is the UM curve; 2) The drying rate curve of agricultural products changes significantly according to the slope, with the AB section being the preheating stage, the BC section being the constant speed stage, and the CD section being the speed-decreasing drying stage; 3) The images corresponding to the AB and BC segments of the drying curve are combined and recorded as a constant-speed drying group, and the images corresponding to the CD segment are combined and recorded as a decreasing-speed drying group.
4. The method for online prediction of drying stage of agricultural products according to claim 1, characterized in that: The S3 is specifically: 1) Group the XML tag file containing classification information and coordinate information and the agricultural product image in a ratio of 8:1:1 to obtain the training group train, the training process test group val and the model test group test, place them in the YOLOv7-tiny model specified folder, configure the training parameters, start training and obtain the training results; 2) Use the online annotation tool make sense to annotate all images, label the constant speed drying group as constant, label the reduced speed drying group as J1, and output the labeled file.
5. The method for online prediction of drying stage of agricultural products according to claim 1, characterized in that: Specifically, S4 includes: using image enhancement technology to perform geometric transformation and light and shadow transformation on the collected images and annotation files to increase the data set and improve the robustness of the model.
6. The method for online prediction of the drying stage of agricultural products according to claim 1, characterized in that: The S5 is specifically: 1) Change the prior frame size of the YOLOv7-tiny model, use the K-means algorithm to cluster the image data group to obtain new anchors parameters, so that the newly obtained anchors parameters are more consistent with the pixel ratio of the target image in the potato drying process in the entire picture, thereby improving the model accuracy; 2) Modify the YOLOv7-tiny model. On the basis of the original network, add an attention mechanism module, add a lightweight SimAM attention mechanism module to the original backbone structure of yolov7-tiny, and introduce the GAM global attention mechanism module at the front end of the head structure output to obtain a new network model.
7. The method for online prediction of drying stage of agricultural products according to claim 1, characterized in that: The S6 is specifically: 1) Run the unmodified and newly modified yolov7-tiny network models to obtain the best.pt and best-xin.pt files respectively, wherein the best-xin.pt file is the online prediction model for the drying stage of agricultural products of the present invention, and the best.pt file is the experimental control model; 2) Calculate the performance parameters of the above two models respectively and compare them; obtain the confusion matrices of the two models, namely: the model group obtained by modifying the network model and the control group obtained by not modifying the network model. According to the confusion matrix, the precision rate P, recall rate R, accuracy rate A, F1 value, and mAP are calculated. The specific formula is as follows: Among them: TP represents the true positive example, that is, the positive example that is correctly classified; TN represents a true negative example, i.e. a negative example that is correctly classified; FP stands for false positive, which means a negative example is mistakenly classified as a positive example. FN (represents a false negative example, that is, a positive example that is mistakenly classified as a negative example; The two models were tested in the test group. The obtained best-xin.pt and best.pt files were used to detect the images in the test group files and the frame rate FPS was calculated. The formula is as follows: Tot=Nms+Inf (9) Where: Inf is the inference speed; Nms is the post-processing time; Tot is the detection time.
Citation Information
Patent Citations
Methods for manufacturing encapsulated granular material, methods for drying coating materials, and fluidized bed dryers
CA2953660A1
Heat pump drying controller for crop drying and control method thereof
CN104729174A
Device for measuring content of water having different forms in sludge
CN108562513A
Multi-scale high-precision lightweight target detection method based on large receptive field and attention mechanism
CN117058542A
PCB surface defect detection method based on improved YOLOv7-tiny
CN117593277A
Cited By
Molybdenum concentrate dryness evaluation method and system based on material images
CN121259799A
