A fruit and vegetable defect detection method and system based on an AI algorithm
By using a convolutional neural network model based on AI algorithms, a training sample image database was established and fruit and vegetable images were collected in real time. This solved the problems of high manpower consumption and error rate in fruit and vegetable defect detection, achieving efficient and accurate defect detection and improving the efficiency and profit of the fruit and vegetable processing industry.
Patent Information
- Application Number
- CN202211583703.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-09
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-12-09
AI Technical Summary
Existing technologies for detecting defects in fruits and vegetables are labor-intensive, have low efficiency and a high error rate. Manual identification is costly, while machine identification has a high rate of missed and false detections. It is also difficult to detect multiple defects simultaneously and distinguish between dark spots and background colors.
An AI-based method for detecting defects in fruits and vegetables is adopted. By using a convolutional neural network model, a training sample image database is established, and fruit and vegetable image information is collected in real time for identification. The model is then trained to improve detection accuracy and efficiency.
It effectively reduces the rate of missed detections and false detections, improves the accuracy and efficiency of fruit and vegetable defect detection, frees up human resources, and increases the efficiency of fruit and vegetable production line processing and industry profits.
Smart Images

Figure CN116843605B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application discloses a fruit and vegetable defect detection method and system based on an AI algorithm and belongs to the technical field of detection. BACKGROUND
[0002] Fruit and vegetable defect detection is an important part of the fruit and vegetable food industry, mainly the identification and detection of defects such as fruit and vegetable surface scars, rot, dirt and the like, and the removal of unqualified fruits and vegetables to ensure food safety. Now, artificial defect identification and fruit and vegetable surface defect identification technology based on machine identification are generally selected. However, the two methods have the following defects:
[0003] First, although artificial defect identification ensures the accuracy of fruit and vegetable surface defect identification to a certain extent, it consumes relatively large costs in terms of time and human resource costs, and occupies part of the economic expenditure of the fruit and vegetable industry.
[0004] Second, the fruit and vegetable surface identification technology based on machine identification has high missed detection and false detection rates, and the detection effect is not ideal. It is difficult to detect multiple defects in a picture and to distinguish dark spots from background colors. SUMMARY
[0005] The application provides a fruit and vegetable defect detection method and system based on an AI algorithm to solve the problems of high labor cost, low detection efficiency and high error rate of the fruit and vegetable defect detection method in the prior art. The technical scheme adopted is as follows:
[0006] A fruit and vegetable defect detection method based on an AI algorithm, the fruit and vegetable defect detection method comprising:
[0007] establishing a training sample image database by using fruit and vegetable defect pictures;
[0008] using a training sample image in the training sample image database as a to-be-identified image to input into a convolutional neural network model for model identification training to obtain a trained convolutional neural network model;
[0009] real-time collection of actual image information of fruits and vegetables, input of the actual image information into the convolutional neural network model as a to-be-identified image for image identification, and output of an image identification result by the convolutional neural network model.
[0010] Further, the training sample image database is established by using fruit and vegetable defect pictures, and the method comprises the following steps:
[0011] determination of the variety type of a to-be-detected fruit and vegetable of a fruit and vegetable defect detection user by acquiring user information;
[0012] According to the variety type of the fruit and vegetable to be detected, a plurality of fruit and vegetable defect pictures corresponding to the variety type of the fruit and vegetable to be detected are obtained; wherein the fruit and vegetable defect pictures corresponding to each variety category are not less than 100;
[0013] Real-time detection of whether there is a new fruit and vegetable variety category, when there is a new fruit and vegetable variety category, a plurality of fruit and vegetable defect pictures corresponding to the new fruit and vegetable variety category are obtained;
[0014] A plurality of fruit and vegetable defect pictures are used to construct a training sample image database.
[0015] Further, the training sample images in the training sample image database are used as to-be-recognized images input into a convolutional neural network model for model recognition training to obtain a trained convolutional neural network model, including:
[0016] According to the fruit and vegetable category, fruit and vegetable defect pictures corresponding to each fruit and vegetable category are extracted in sequence, and fruit and vegetable defect picture sets corresponding to each fruit and vegetable category are formed in units of fruit and vegetable categories;
[0017] The convolutional neural network in the convolutional neural network model is initialized to obtain a convolutional neural network that has completed initialization;
[0018] According to the number of orthogonal paths contained in the convolutional neural network, the fruit and vegetable defect picture sets are divided into sub-sets to obtain a plurality of sub-sets corresponding to each fruit and vegetable defect picture set;
[0019] A fruit and vegetable defect picture set is input into the convolutional neural network, and a plurality of sub-sets corresponding to the fruit and vegetable defect picture set are input into each orthogonal path in sequence, so that each orthogonal path traverses all sub-sets; ensure that a plurality of fruit and vegetable defect pictures exist in each orthogonal path at the same time; and the sub-sets in each orthogonal path at the same time are not the same;
[0020] A plurality of picture prediction results are output through an orthogonal path, the plurality of picture prediction results are compared with the original pictures of the fruit and vegetable defect pictures corresponding to the plurality of picture prediction results, and prediction differences are obtained;
[0021] The prediction differences are used to update the parameters of the convolutional neural network, and the next fruit and vegetable defect picture set is used to train the convolutional neural network, until all fruit and vegetable defect picture sets are traversed, the model training is completed, and a trained convolutional neural network model is obtained.
[0022] Further, according to the number of orthogonal paths contained in the convolutional neural network, the fruit and vegetable defect picture sets are divided into sub-sets to obtain a plurality of sub-sets corresponding to each fruit and vegetable defect picture set, including:
[0023] extracting an orthogonal path number value and a total number of fruit and vegetable defect images in the set of fruit and vegetable defect images;
[0024] determining the number of fruit and vegetable defect images in each subset according to a relationship of M / (2N+1), and forming a plurality of subsets; wherein M represents the total number of fruit and vegetable defect images, and N represents the orthogonal path number value.
[0025] An AI algorithm-based fruit and vegetable defect detection system, comprising:
[0026] A database establishing module configured to establish a training sample image database using fruit and vegetable defect images;
[0027] A model training module configured to input training sample images in the training sample image database into a convolutional neural network model as to-be-identified images for model identification training, and obtain a trained convolutional neural network model.
[0028] A real-time acquisition module configured to acquire actual image information of fruit and vegetables in real time, input the actual image information into the convolutional neural network model as to-be-identified images for image identification, and output an image identification result through the convolutional neural network model.
[0029] Further, the database establishing module comprises:
[0030] A type determining module configured to determine the variety type of to-be-detected fruit and vegetables of a fruit and vegetable defect detection user by acquiring user information;
[0031] A picture acquiring module configured to acquire a plurality of fruit and vegetable defect images corresponding to the variety type of the to-be-detected fruit and vegetables according to the variety type of the to-be-detected fruit and vegetables; wherein the fruit and vegetable defect images corresponding to each variety type are not less than 100;
[0032] A category detection module configured to detect in real time whether there is a newly-added variety category of fruit and vegetables, and acquire a plurality of fruit and vegetable defect images corresponding to the newly-added variety category of fruit and vegetables when the newly-added variety category of fruit and vegetables exists;
[0033] A construction module configured to construct a training sample image database using the plurality of fruit and vegetable defect images.
[0034] Further, the model training module comprises:
[0035] A defect image extracting module configured to extract fruit and vegetable defect images corresponding to each fruit and vegetable category in sequence according to the fruit and vegetable category, and form a set of fruit and vegetable defect images corresponding to each fruit and vegetable category in units of fruit and vegetable category;
[0036] An initialization module is configured to initialize a convolutional neural network in the convolutional neural network model to obtain an initialized convolutional neural network.
[0037] A set division module is configured to divide the fruit and vegetable defect picture set into sub-sets according to the number of orthogonal paths contained in the convolutional neural network to obtain a plurality of sub-sets corresponding to each fruit and vegetable defect picture set.
[0038] An input module is configured to input a fruit and vegetable defect picture set into the convolutional neural network, and sequentially and cyclically input a plurality of sub-sets corresponding to the fruit and vegetable defect picture set into each orthogonal path to make each orthogonal path traverse all sub-sets; ensure that a plurality of fruit and vegetable defect pictures exist in each orthogonal path at the same time; and ensure that the sub-sets in each orthogonal path at the same time are different.
[0039] A difference acquisition module is configured to output a plurality of picture prediction results through an orthogonal path, compare the plurality of picture prediction results with corresponding fruit and vegetable defect picture original pictures to obtain a prediction difference.
[0040] A parameter updating module is configured to update parameters of the convolutional neural network using the prediction difference, and train the convolutional neural network using a next fruit and vegetable defect picture set until all fruit and vegetable defect picture sets are traversed to complete model training to obtain a trained convolutional neural network model.
[0041] Further, the set division module comprises:
[0042] An element extraction module is configured to extract a number of orthogonal paths and a total number of fruit and vegetable defect pictures in the fruit and vegetable defect picture set.
[0043] A sub-set forming module is configured to determine the number of fruit and vegetable defect pictures in each sub-set according to a relationship of M / (2N+1) and form a plurality of sub-sets; wherein M represents the total number of fruit and vegetable defect pictures, and N represents the number of orthogonal paths.
[0044] The present application has the following advantages:
[0045] The fruit and vegetable defect detection method and system based on an AI algorithm can effectively improve the accuracy and efficiency of fruit and vegetable defect detection through neural network processing of fruit and vegetable defect pictures, effectively reduce the missed detection rate and false detection rate through picture acquisition and centralized recognition processing, and effectively reduce the error rate of fruit and vegetable defect detection and improve the accuracy of fruit and vegetable defect detection. At the same time, the centralized image acquisition method can effectively improve the acquisition rate of the target image to be detected, thereby improving the fruit and vegetable defect recognition and detection efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0046] Figure 1a flow chart of the method of the present application;
[0047] Figure 2 a system block diagram of the system of the present application. DETAILED DESCRIPTION
[0048] The preferred embodiments of the present application are described below in conjunction with the accompanying drawings, it should be understood that the preferred embodiments described here are only used to illustrate and explain the present application, and are not used to limit the present application.
[0049] The embodiment of the present application proposes a fruit and vegetable defect detection method based on AI algorithm, as shown in the figure, the fruit and vegetable defect detection method comprises: Figure 1
[0050] S1, a training sample image database is established by using fruit and vegetable defect pictures;
[0051] S2, the training sample images in the training sample image database are used as to-be-identified images and input into a convolutional neural network model for model identification training, and a trained convolutional neural network model is obtained;
[0052] S3, real-time acquisition of actual image information of fruit and vegetable, the actual image information is input into the convolutional neural network model as to-be-identified image for image recognition, and the image recognition result is output through the convolutional neural network model.
[0053] The working principle of the above technical solution is: first, a training sample image database is established by using fruit and vegetable defect pictures; then, the training sample images in the training sample image database are used as to-be-identified images and input into a convolutional neural network model for model identification training, and a trained convolutional neural network model is obtained; finally, real-time acquisition of actual image information of fruit and vegetable, the actual image information is input into the convolutional neural network model as to-be-identified image for image recognition, and the image recognition result is output through the convolutional neural network model.
[0054] The effect of the above technical solution is: the fruit and vegetable defect detection method based on AI algorithm proposed in the embodiment can effectively improve the accuracy and efficiency of fruit and vegetable defect detection by using neural network to process fruit and vegetable defect pictures, and can effectively reduce the missed detection rate and false detection rate by using the picture acquisition and centralized recognition processing mode, thereby effectively reducing the error rate of fruit and vegetable defect detection and improving the accuracy of fruit and vegetable defect detection. At the same time, the centralized image acquisition mode can effectively improve the acquisition rate of to-be-detected image targets, thereby improving the fruit and vegetable defect recognition and detection efficiency. On the other hand, the fruit and vegetable surface defects can be accurately and efficiently detected, which can liberate manpower, improve the efficiency of fruit and vegetable processing line, and improve the industrial profit in fruit and vegetable food processing industry.
[0055] One embodiment of the present application uses fruit and vegetable defect pictures to establish a training sample image database, which includes:
[0056] S101, determine the variety type of the fruit and vegetable to be detected of the fruit and vegetable defect detection user by acquiring user information;
[0057] S102, acquire a plurality of fruit and vegetable defect pictures corresponding to the variety type of the fruit and vegetable to be detected according to the variety type of the fruit and vegetable to be detected; wherein the fruit and vegetable defect pictures corresponding to each variety category are not less than 100;
[0058] S103, real-time detect whether there is a new variety category of fruit and vegetable, and when there is a new variety category of fruit and vegetable, acquire a plurality of fruit and vegetable defect pictures corresponding to the new variety category of fruit and vegetable;
[0059] S104, construct a training sample image database using the plurality of fruit and vegetable defect pictures.
[0060] The working principle of the above technical solution is as follows: first, determine the variety type of the fruit and vegetable to be detected of the fruit and vegetable defect detection user by acquiring user information; then, acquire a plurality of fruit and vegetable defect pictures corresponding to the variety type of the fruit and vegetable to be detected according to the variety type of the fruit and vegetable to be detected; wherein the fruit and vegetable defect pictures corresponding to each variety category are not less than 100; subsequently, real-time detect whether there is a new variety category of fruit and vegetable, and when there is a new variety category of fruit and vegetable, acquire a plurality of fruit and vegetable defect pictures corresponding to the new variety category of fruit and vegetable; finally, construct a training sample image database using the plurality of fruit and vegetable defect pictures.
[0061] The effect of the above technical solution is that the image collection method can effectively improve the collection rate of the target image to be detected, thereby improving the fruit and vegetable defect recognition and detection efficiency. On the other hand, the fruit and vegetable surface defects can be accurately and efficiently detected, which can liberate manpower, improve the efficiency of fruit and vegetable processing line, and increase the profit of the industry.
[0062] One embodiment of the present application uses the training sample images in the training sample image database as the to-be-recognized images to input into the convolutional neural network model for model recognition training to obtain a trained convolutional neural network model, which includes:
[0063] S201, sequentially extract the fruit and vegetable defect pictures corresponding to each fruit and vegetable category according to the fruit and vegetable category, and form a fruit and vegetable defect picture set corresponding to each fruit and vegetable category according to the fruit and vegetable category unit;
[0064] S202, initialize the convolutional neural network in the convolutional neural network model to obtain a completed initialization convolutional neural network;
[0065] S203, divide the fruit and vegetable defect picture set into sub-sets according to the number of orthogonal paths contained in the convolutional neural network, and obtain a plurality of sub-sets corresponding to each fruit and vegetable defect picture set;
[0066] S204, input a fruit and vegetable defect picture set into the convolutional neural network, and sequentially and cyclically input a plurality of sub-sets corresponding to the fruit and vegetable defect picture set into each orthogonal path, so that each orthogonal path traverses all sub-sets; ensure that there are a plurality of fruit and vegetable defect pictures in each orthogonal path at the same time; and the sub-sets in each orthogonal path at the same time are different;
[0067] S205, output a plurality of picture prediction results through an orthogonal path, compare the plurality of picture prediction results with the corresponding fruit and vegetable defect picture original image, and obtain a prediction difference;
[0068] S206, update the parameters of the convolutional neural network using the prediction difference, and train the convolutional neural network using the next fruit and vegetable defect picture set, until all fruit and vegetable defect picture sets are traversed, the model training is completed, and a trained convolutional neural network model is obtained.
[0069] The working principle of the above technical solution is as follows: first, fruit and vegetable defect pictures corresponding to each fruit and vegetable category are extracted in sequence according to the fruit and vegetable category, and fruit and vegetable defect picture sets corresponding to each fruit and vegetable category are formed according to the fruit and vegetable category as a unit; the convolutional neural network in the convolutional neural network model is initialized to obtain a completed initialization convolutional neural network; then, the fruit and vegetable defect picture set is divided into sub-sets according to the number of orthogonal paths contained in the convolutional neural network, and a plurality of sub-sets corresponding to each fruit and vegetable defect picture set are obtained; a fruit and vegetable defect picture set is input into the convolutional neural network, and a plurality of sub-sets corresponding to the fruit and vegetable defect picture set are sequentially and cyclically input into each orthogonal path, so that each orthogonal path traverses all sub-sets; ensure that there are a plurality of fruit and vegetable defect pictures in each orthogonal path at the same time; and the sub-sets in each orthogonal path at the same time are different; finally, a plurality of picture prediction results are output through an orthogonal path, the plurality of picture prediction results are compared with the corresponding fruit and vegetable defect picture original image, and a prediction difference is obtained; the parameters of the convolutional neural network are updated using the prediction difference, and the convolutional neural network is trained using the next fruit and vegetable defect picture set, until all fruit and vegetable defect picture sets are traversed, the model training is completed, and a trained convolutional neural network model is obtained.
[0070] The technical scheme has the effects that: the image collection mode can effectively improve the collection rate of the image target to be detected, and further improve the fruit and vegetable defect recognition and detection efficiency. On the other hand, the fruit and vegetable surface defects can be accurately and efficiently detected, the manpower is liberated, the efficiency of the fruit and vegetable assembly line processing is improved, and the industrial profit is improved.
[0071] In an embodiment of the present application, the fruit and vegetable defect picture set is divided into sub-sets according to the number of orthogonal paths contained in the convolutional neural network, and a plurality of sub-sets corresponding to each fruit and vegetable defect picture set are obtained, including:
[0072] S2031, extracting the number of orthogonal paths and the total number of fruit and vegetable defect pictures in the fruit and vegetable defect picture set;
[0073] S2032, determining the number of fruit and vegetable defect pictures in each sub-set according to the relationship of M / (2N+1), and forming a plurality of sub-sets; wherein M represents the total number of fruit and vegetable defect pictures, and N represents the number of orthogonal paths.
[0074] The working principle of the above technical scheme is that: first, the number of orthogonal paths and the total number of fruit and vegetable defect pictures in the fruit and vegetable defect picture set are extracted; then, the number of fruit and vegetable defect pictures in each sub-set is determined according to the relationship of M / (2N+1), and a plurality of sub-sets are formed; wherein M represents the total number of fruit and vegetable defect pictures, and N represents the number of orthogonal paths.
[0075] The effects of the above technical scheme are that: through the above way of sub-set formation and batch processing, the image processing efficiency can be effectively improved, and at the same time, through the sub-set setting, the order of processing can be ensured in the batch processing process, and the problem of detection error caused by image confusion can be prevented. At the same time, the accuracy and efficiency of fruit and vegetable defect detection can be effectively improved, the miss rate and the false detection rate can be effectively reduced through the picture collection and centralized recognition processing mode, and the error rate of fruit and vegetable defect detection can be effectively reduced, and the accuracy of fruit and vegetable defect detection can be improved. At the same time, the image collection mode can effectively improve the collection rate of the image target to be detected, and further improve the fruit and vegetable defect recognition and detection efficiency. On the other hand, the fruit and vegetable surface defects can be accurately and efficiently detected, the manpower is liberated, the efficiency of the fruit and vegetable assembly line processing is improved, and the industrial profit is improved.
[0076] An embodiment of the present application proposes a fruit and vegetable defect detection system based on an AI algorithm, as shown in Figure 2 The fruit and vegetable defect detection system comprises:
[0077] A database establishment module is configured to establish a training sample image database by using fruit and vegetable defect pictures;
[0078] a model training module, configured to input training sample images in the training sample image database into a convolutional neural network model as to-be-identified images for model identification training, and obtain a trained convolutional neural network model;
[0079] a real-time acquisition module, configured to acquire actual image information of the fruits and vegetables in real time, input the actual image information into the convolutional neural network model as to-be-identified images for image identification, and output an image identification result through the convolutional neural network model.
[0080] The working principle of the technical solution is as follows: first, the database establishment module establishes a training sample image database by using fruit and vegetable defect pictures; then, the model training module inputs training sample images in the training sample image database into a convolutional neural network model as to-be-identified images for model identification training, and obtains a trained convolutional neural network model; finally, the real-time acquisition module acquires actual image information of the fruits and vegetables in real time, inputs the actual image information into the convolutional neural network model as to-be-identified images for image identification, and outputs an image identification result through the convolutional neural network model.
[0081] The technical solution has the following effects: the fruit and vegetable defect detection system based on an AI algorithm can effectively improve the accuracy and efficiency of fruit and vegetable defect detection by using a neural network to process fruit and vegetable defect pictures, effectively reduce the omission rate and the false detection rate by using the picture acquisition and centralized identification processing mode, and effectively reduce the error rate of fruit and vegetable defect detection and improve the accuracy of fruit and vegetable defect detection. Meanwhile, the centralized image acquisition mode can effectively improve the acquisition rate of to-be-detected image targets, and thus improve the fruit and vegetable defect identification and detection efficiency.
[0082] In an embodiment of the present application, the database establishment module comprises:
[0083] a type determination module, configured to determine the variety type of the to-be-detected fruits and vegetables of the fruit and vegetable defect detection user by acquiring user information;
[0084] a picture acquisition module, configured to acquire a plurality of fruit and vegetable defect pictures corresponding to the variety type of the to-be-detected fruits and vegetables according to the variety type of the to-be-detected fruits and vegetables; wherein the fruit and vegetable defect pictures corresponding to each variety type are not less than 100;
[0085] a category detection module, configured to detect in real time whether there is a newly-added variety category of fruits and vegetables, and when there is a newly-added variety category of fruits and vegetables, acquire a plurality of fruit and vegetable defect pictures corresponding to the newly-added variety category of fruits and vegetables;
[0086] a construction module, configured to construct a training sample image database by using the plurality of fruit and vegetable defect pictures.
[0087] The working principle of the technical solution is as follows: first, the type determination module determines the variety type of the fruit and vegetable to be detected of the fruit and vegetable defect detection user by acquiring user information; then, the picture acquisition module acquires a plurality of fruit and vegetable defect pictures corresponding to the variety type of the fruit and vegetable to be detected according to the variety type of the fruit and vegetable to be detected; wherein the fruit and vegetable defect pictures corresponding to each variety category are not less than 100; subsequently, the category detection module detects whether there is a new fruit and vegetable variety category in real time, and when there is a new fruit and vegetable variety category, a plurality of fruit and vegetable defect pictures corresponding to the new fruit and vegetable variety category are acquired; finally, the construction module constructs a training sample image database by using the plurality of fruit and vegetable defect pictures.
[0088] The effect of the technical solution is that: through the above-mentioned way of sub-set formation and batch processing, the image processing efficiency can be effectively improved, and at the same time, through the sub-set setting, the order of processing can be ensured in the batch processing process to prevent detection errors caused by image confusion. At the same time, the accuracy and efficiency of fruit and vegetable defect detection can be effectively improved, and through the picture acquisition and centralized recognition processing, the miss rate and false detection rate can be effectively reduced, thereby effectively reducing the error rate of fruit and vegetable defect detection and improving the accuracy of fruit and vegetable defect detection. At the same time, through the centralized image acquisition, the acquisition rate of the target image to be detected can be effectively improved, thereby improving the fruit and vegetable defect recognition and detection efficiency. On the other hand, the surface defects of fruits and vegetables can be accurately and efficiently detected, which can liberate manpower in the fruit and vegetable food processing industry, improve the efficiency of fruit and vegetable assembly line processing, and improve the industrial profit.
[0089] In an embodiment of the present application, the model training module comprises:
[0090] The defect picture extraction module is configured to extract fruit and vegetable defect pictures corresponding to each fruit and vegetable category in sequence according to the fruit and vegetable category, and form a fruit and vegetable defect picture set corresponding to each fruit and vegetable category in units of fruit and vegetable category;
[0091] The initialization module is configured to initialize the convolutional neural network in the convolutional neural network model to obtain a convolutional neural network after initialization;
[0092] The set division module is configured to divide the fruit and vegetable defect picture set into sub-sets according to the number of orthogonal paths contained in the convolutional neural network, and obtain a plurality of sub-sets corresponding to each fruit and vegetable defect picture set;
[0093] The input module is configured to input a fruit and vegetable defect picture set into the convolutional neural network, and sequentially and cyclically input a plurality of sub-sets corresponding to the fruit and vegetable defect picture set into each orthogonal path, so that each orthogonal path traverses all the sub-sets; and multiple fruit and vegetable defect pictures exist in each orthogonal path at the same time; and the sub-sets in each orthogonal path at the same time are different;
[0094] The difference acquisition module is configured to output a plurality of picture prediction results through one orthogonal path, compare the plurality of picture prediction results with corresponding fruit and vegetable defect picture original pictures, and acquire prediction differences;
[0095] The parameter updating module is configured to update parameters of the convolutional neural network by using the prediction differences, and train the convolutional neural network by using a next fruit and vegetable defect picture set until all fruit and vegetable defect picture sets are traversed, so that model training is completed, and a trained convolutional neural network model is obtained.
[0096] The working principle of the above technical solution is as follows: first, the defect picture extraction module extracts fruit and vegetable defect pictures corresponding to each fruit and vegetable category in sequence according to the fruit and vegetable category, and forms a fruit and vegetable defect picture set corresponding to each fruit and vegetable category according to the fruit and vegetable category as a unit; the initialization module is used to initialize the convolutional neural network in the convolutional neural network model, and a completed initialization convolutional neural network is obtained; then, the set division module is used to divide the fruit and vegetable defect picture set into a plurality of sub-sets according to the number of orthogonal paths contained in the convolutional neural network, and a plurality of sub-sets corresponding to each fruit and vegetable defect picture set are obtained; the input module is used to input a fruit and vegetable defect picture set into the convolutional neural network, and sequentially and cyclically input a plurality of sub-sets corresponding to the fruit and vegetable defect picture set into each orthogonal path, so that each orthogonal path traverses all the sub-sets; and multiple fruit and vegetable defect pictures exist in each orthogonal path at the same time; and the sub-sets in each orthogonal path at the same time are different; finally, the difference acquisition module is used to output a plurality of picture prediction results through one orthogonal path, compare the plurality of picture prediction results with corresponding fruit and vegetable defect picture original pictures, and acquire prediction differences; the parameter updating module is used to update parameters of the convolutional neural network by using the prediction differences, and train the convolutional neural network by using a next fruit and vegetable defect picture set until all fruit and vegetable defect picture sets are traversed, so that model training is completed, and a trained convolutional neural network model is obtained.
[0097] The technical scheme has the following beneficial effects: through the above manner of sub-set formation and batch processing, the image processing efficiency can be effectively improved, meanwhile, through the sub-set setting, the order of processing can be ensured in the batch processing process, and the problem of detection error caused by image confusion can be prevented. Meanwhile, the accuracy and efficiency of fruit and vegetable defect detection can be effectively improved, through the picture acquisition and centralized recognition processing manner, the missed detection rate and the false detection rate can be effectively reduced, and then the error rate of fruit and vegetable defect detection can be effectively reduced, and the accuracy of fruit and vegetable defect detection can be improved. Meanwhile, through the centralized image acquisition manner, the acquisition rate of the image target to be detected can be effectively improved, and then the fruit and vegetable defect recognition and detection efficiency can be improved. On the other hand, the surface defects of the fruit and vegetable can be accurately and efficiently detected, in the fruit and vegetable food processing industry, the manpower can be liberated, the efficiency of the fruit and vegetable assembly line processing can be improved, and the industrial profit can be improved.
[0098] In one embodiment of the present application, the set division module comprises:
[0099] An element extraction module is configured to extract the orthogonal path quantity value and the total number of fruit and vegetable defect pictures in the fruit and vegetable defect picture set.
[0100] A sub-set formation module is configured to determine the number of fruit and vegetable defect pictures in each sub-set according to the relationship of M / (2N+1), and form a plurality of sub-sets; wherein M represents the total number of fruit and vegetable defect pictures, and N represents the orthogonal path quantity value.
[0101] The working principle of the technical scheme is as follows: first, the element extraction module extracts the orthogonal path quantity value and the total number of fruit and vegetable defect pictures in the fruit and vegetable defect picture set; then, the sub-set formation module determines the number of fruit and vegetable defect pictures in each sub-set according to the relationship of M / (2N+1), and forms a plurality of sub-sets; wherein M represents the total number of fruit and vegetable defect pictures, and N represents the orthogonal path quantity value.
[0102] The technical scheme has the following beneficial effects: through the above manner of sub-set formation and batch processing, the image processing efficiency can be effectively improved, meanwhile, through the sub-set setting, the order of processing can be ensured in the batch processing process, and the problem of detection error caused by image confusion can be prevented. Meanwhile, the accuracy and efficiency of fruit and vegetable defect detection can be effectively improved, through the picture acquisition and centralized recognition processing manner, the missed detection rate and the false detection rate can be effectively reduced, and then the error rate of fruit and vegetable defect detection can be effectively reduced, and the accuracy of fruit and vegetable defect detection can be improved. Meanwhile, through the centralized image acquisition manner, the acquisition rate of the image target to be detected can be effectively improved, and then the fruit and vegetable defect recognition and detection efficiency can be improved. On the other hand, the surface defects of the fruit and vegetable can be accurately and efficiently detected, in the fruit and vegetable food processing industry, the manpower can be liberated, the efficiency of the fruit and vegetable assembly line processing can be improved, and the industrial profit can be improved.
[0103] Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.
Claims
1. A method for detecting defects in fruits and vegetables based on AI algorithms, characterized in that, The method for detecting defects in fruits and vegetables includes: A training sample image database was established using images of fruit and vegetable defects. The training sample images in the training sample image database are used as the images to be recognized and input into the convolutional neural network model to perform model recognition training, thereby obtaining a trained convolutional neural network model. The system collects real-time image information of fruits and vegetables, inputs the real-time image information as the image to be recognized into a convolutional neural network model for image recognition, and outputs the image recognition result through the convolutional neural network model. Specifically, the training sample images from the training sample image database are used as inputs to the convolutional neural network model for model recognition training to obtain a trained convolutional neural network model, including: Extract the defective fruit and vegetable images corresponding to each fruit and vegetable category in sequence, and form a set of defective fruit and vegetable images corresponding to each fruit and vegetable category by category; The convolutional neural network in the convolutional neural network model is initialized to obtain a fully initialized convolutional neural network; The set of fruit and vegetable defect images is divided into subsets based on the number of orthogonal paths contained in the convolutional neural network, resulting in multiple subsets corresponding to each set of fruit and vegetable defect images. A set of fruit and vegetable defect images is input into a convolutional neural network. Multiple subsets corresponding to the set of fruit and vegetable defect images are sequentially and cyclically input into each orthogonal path, so that each orthogonal path traverses all subsets. This ensures that multiple fruit and vegetable defect images exist simultaneously in each orthogonal path, and that the subsets of each orthogonal path are different at the same time. Multiple image prediction results are output through an orthogonal path. The multiple image prediction results are compared with their corresponding original images of fruit and vegetable defects to obtain the prediction differences. The parameters of the convolutional neural network are updated using the predicted differences, and the convolutional neural network is trained using the next set of fruit and vegetable defect images until all fruit and vegetable defect image sets have been traversed, thus completing the model training and obtaining a trained convolutional neural network model.
2. The method for detecting defects in fruits and vegetables according to claim 1, characterized in that, A training sample image database was established using images of fruit and vegetable defects, including: The types of fruits and vegetables to be tested for users are determined by obtaining user information; Based on the variety type of the fruit and vegetable to be tested, obtain multiple fruit and vegetable defect images corresponding to the variety type of the fruit and vegetable to be tested; wherein, there shall be no less than 100 fruit and vegetable defect images corresponding to each variety category; Real-time detection of whether new fruit and vegetable varieties are added; when new fruit and vegetable varieties are added, multiple fruit and vegetable defect images corresponding to the new fruit and vegetable varieties are obtained. A training sample image database was constructed using the aforementioned images of fruit and vegetable defects.
3. The method for detecting defects in fruits and vegetables according to claim 1, characterized in that, The set of fruit and vegetable defect images is divided into subsets based on the number of orthogonal paths contained within the convolutional neural network, resulting in multiple subsets corresponding to each set of fruit and vegetable defect images, including: Extract the orthogonal path count and the total number of fruit and vegetable defect images in the fruit and vegetable defect image set; The number of fruit and vegetable defect images in each subset is determined according to the relationship M / (2N+1), forming multiple subsets; where M represents the total number of fruit and vegetable defect images and N represents the number of orthogonal paths.
4. A fruit and vegetable defect detection system based on AI algorithms, characterized in that, The fruit and vegetable defect detection system includes: The database creation module is used to build a training sample image database using images of fruit and vegetable defects. The model training module is used to use the training sample images in the training sample image database as the images to be recognized and input them into the convolutional neural network model to perform model recognition training, so as to obtain a trained convolutional neural network model. The real-time acquisition module is used to acquire actual image information of fruits and vegetables in real time, input the actual image information as the image to be identified into the convolutional neural network model for image recognition, and output the image recognition result through the convolutional neural network model; The model training module includes: The defect image extraction module is used to extract the defect images of fruits and vegetables corresponding to each fruit and vegetable category in sequence, and form a set of defect images of fruits and vegetables corresponding to each fruit and vegetable category by category. An initialization module is used to initialize the convolutional neural network in the convolutional neural network model to obtain a fully initialized convolutional neural network. The set partitioning module is used to partition the set of fruit and vegetable defect images into subsets based on the number of orthogonal paths contained in the convolutional neural network, thereby obtaining multiple subsets corresponding to each set of fruit and vegetable defect images. The input module is used to input a set of fruit and vegetable defect images into a convolutional neural network, and to sequentially input multiple subsets corresponding to the set of fruit and vegetable defect images into each orthogonal path, so that each orthogonal path traverses all subsets; ensuring that multiple fruit and vegetable defect images exist in each orthogonal path at the same time; and that the subsets of each orthogonal path are different at the same time. The difference acquisition module is used to output multiple image prediction results through an orthogonal path, compare the multiple image prediction results with their corresponding original fruit and vegetable defect images, and obtain the prediction difference. The parameter update module is used to update the parameters of the convolutional neural network using the predicted differences, and to train the convolutional neural network using the next set of fruit and vegetable defect images until all fruit and vegetable defect image sets have been traversed, thus completing the model training and obtaining a trained convolutional neural network model.
5. The fruit and vegetable defect detection system according to claim 4, characterized in that, The database creation module includes: The type determination module is used to determine the variety type of fruits and vegetables to be tested by the user by obtaining user information; The image acquisition module is used to acquire multiple fruit and vegetable defect images corresponding to the variety type of the fruit and vegetable to be detected; wherein, there shall be no less than 100 fruit and vegetable defect images corresponding to each variety category. The category detection module is used to detect in real time whether there are any new fruit and vegetable varieties. When there are new fruit and vegetable varieties, it acquires multiple fruit and vegetable defect images corresponding to the new fruit and vegetable varieties. A construction module is used to build a training sample image database using the multiple fruit and vegetable defect images.
6. The fruit and vegetable defect detection system according to claim 5, characterized in that, The set partitioning module includes: The element extraction module is used to extract the orthogonal path count and the total number of fruit and vegetable defect images in the fruit and vegetable defect image set. The subset formation module is used to determine the number of fruit and vegetable defect images in each subset according to the relationship M / (2N+1) and form multiple subsets; where M represents the total number of fruit and vegetable defect images and N represents the number of orthogonal paths.
Citation Information
Patent Citations
Fruit defect nondestructive testing method based on neural network and fruit grading method
CN112697984A
Automatic fruit and vegetable inspection method and system, electronic equipment and computer readable medium
CN112966541A