Method and device for training quality physicochemical index prediction model of sun rose grape
Patent Information
- Application Number
- CN202610962609.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-30
- Publication Date
- 2026-09-18
AI Technical Summary
[0004]本发明提供了一种阳光玫瑰葡萄的品质理化指标预测模型的训练方法、装置、电子设备、存储介质及程序产品,以解决当前的品质理化指标检测技术无法满足当前应用需求的问题
在通过上述的训练方式得到目标品质理化指标预测模型的情况下,在目标品质理化指标预测模型的使用过程中,本方案只需要拍摄阳光玫瑰葡萄的图像,将图像输入到目标品质理化指标预测模型,由目标品质理化指标预测模型基于图像中的信息识别出目标品质理化指标。这样,无需在每次检测过程中,都对阳光玫瑰葡萄进行破坏性检测。并且,拍摄图像较为方便,目标品质理化指标预测模型的识别速度较快,在需要检测大量阳光玫瑰葡萄的情况下,也可以高效完成,适用于批量化、在线化、低成本检测需求。另外,本方案只需要拍摄简单的图像即可,无需部署高光谱和近红外技术,也即本方案在满足自动化检测的情况下,可以降低设备成本、系统复杂性等,并且便于模型迁移和现场部署。
Smart Images

Figure CN122780943A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quality physicochemical index detection technology, specifically to a training method and apparatus for a predictive model of quality physicochemical indexes of Sunshine Rose grapes. Background Technology
[0002] The quality of Shine Muscat grapes depends not only on appearance indicators such as berry size, color, and integrity, but also on internal qualities such as total soluble solids (TSS) and titratable acidity (TA).
[0003] Traditional methods for determining soluble solids content and titratable acid content rely on refractometers, juicing, and titration experiments. These methods are destructive, time-consuming, and have sampling limitations, making them unsuitable for current applications requiring batch processing, online testing, and low-cost detection. Summary of the Invention
[0004] This invention provides a training method, apparatus, electronic device, storage medium, and program product for predicting the quality physicochemical indicators of Sunshine Rose grapes, in order to solve the problem that current quality physicochemical indicator detection technologies cannot meet current application needs.
[0005] In a first aspect, the present invention provides a training method for a predictive model of the quality physicochemical indicators of Shine Muscat grapes, the method comprising: Obtain the training dataset for Shine Muscat grapes, which includes multiple sample images and the corresponding real quality physicochemical indicators for each sample image. Feature extraction is performed on multiple sample images to obtain feature vectors corresponding to each sample image. In the current training round, the feature vectors corresponding to multiple sample images are input into the quality physicochemical index prediction model to be trained, and the predicted quality physicochemical indexes corresponding to multiple sample images are obtained from the output of the quality physicochemical index prediction model to be trained. Based on the actual and predicted quality physicochemical indicators corresponding to multiple sample images, the quality physicochemical indicator prediction model to be trained is updated to obtain the quality physicochemical indicator prediction model corresponding to the current training round. When the conditions for stopping training are met, the quality physicochemical index prediction model corresponding to the current training round is determined as the target quality physicochemical index prediction model. Alternatively, if the training stop condition is not met, proceed to the next training round corresponding to the current training round until the training stop condition is met in the target training round. Then stop training and determine the quality physicochemical index prediction model corresponding to the target training round as the target quality physicochemical index prediction model. The target quality physicochemical index prediction model is used for image recognition of quality physicochemical indexes based on Sunshine Rose grapes.
[0006] The training method for the quality physicochemical index prediction model provided in this application has the following advantages: Having obtained the target quality physicochemical index prediction model through the above training method, this solution only requires capturing images of Shine Muscat grapes and inputting them into the prediction model. The model then identifies the target quality physicochemical indexes based on the information in the images. This eliminates the need for destructive testing of the Shine Muscat grapes in each inspection. Furthermore, image capture is convenient, and the prediction model has a fast recognition speed, allowing for efficient testing of large quantities of Shine Muscat grapes, making it suitable for batch, online, and low-cost inspection needs. Additionally, this solution only requires capturing simple images, eliminating the need for hyperspectral and near-infrared technologies. This means that while meeting automated inspection requirements, this solution reduces equipment costs and system complexity, and facilitates model migration and field deployment.
[0007] In one optional implementation, the sample images are all in the master format, and the sample images include pixel information from multiple channels in the master format; feature extraction is performed on multiple sample images respectively to obtain feature vectors corresponding to multiple sample images, including: The first sample image is converted using a preset sub-format to obtain the second sample image. The first sample image is any one of multiple sample images, and the second sample image includes pixel information from multiple channels under the sub-format. Based on the pixel information of multiple channels in the primary format of the first sample image and the pixel information of multiple channels in the secondary format of the second sample image, the target feature vector corresponding to the first sample image is determined.
[0008] In this way, by combining image information in multiple formats, the model can learn richer color information during training, thus providing more accurate prediction results for quality physicochemical indicators in subsequent predictions.
[0009] In one optional implementation, the pixel information includes pixel values of multiple pixels; based on the pixel information of multiple channels in the main format of the first sample image and the pixel information of multiple channels in the sub-format of the second sample image, a target feature vector corresponding to the first sample image is determined, including: Based on the pixel values of multiple pixels included in the pixel information of the first channel, the mean and standard deviation of the pixel values of the first channel are determined respectively, wherein the first channel is one of the multiple channels under the main format; Calculate the color ratio between the first channel and the second channel, where the second channel is one of the other channels in the main format besides the first channel; Based on the pixel values of multiple pixels included in the pixel information of the third channel, the mean and standard deviation of the pixel values of the third channel are determined respectively, where the third channel is one of the multiple channels under the sub-format; Calculate the color ratio between the third and fourth channels, where the fourth channel is one of the channels other than the third channel in the sub-format; The mean and standard deviation of pixel values in the first channel, the color ratio between the first and second channels, the mean and standard deviation of pixel values in the third channel, and the color ratio between the third and fourth channels are concatenated to form the target feature vector.
[0010] Since the quality physicochemical indicators are usually related to the color information of Sunshine Rose grapes, from the perspective of channels, the mean can represent the overall color level and the standard deviation can represent the dispersion of color distribution. Therefore, this solution uses the information of each channel itself, as well as the color correlation information between different channels, as feature vectors, which can more accurately identify the quality physicochemical indicators under different color characteristics.
[0011] In one alternative implementation, a training dataset of Shine Muscat grapes is obtained, including: Acquire multiple raw images; Perform a preset first image preprocessing operation on multiple original images to obtain sample images corresponding to the multiple original images.
[0012] In this way, after performing the first image preprocessing operation on the original image, the original image can be made to conform to a unified standard, thereby making the trained model more accurate.
[0013] In one alternative implementation, the method further includes: Obtain the test dataset; Using a test dataset, the prediction model for the target quality physicochemical indicators was tested, and the evaluation results corresponding to the prediction model for the target quality physicochemical indicators were obtained. If the evaluation result indicates that the prediction model for the target quality physicochemical indicators is unqualified, a second image preprocessing operation is performed on multiple original images to obtain updated sample images corresponding to the original images. The number of operation types included in the second image preprocessing operation is greater than the number of operation types in the first image preprocessing operation. The updated sample images corresponding to the multiple original images are used to retrain the prediction model for the quality physicochemical indicators to be trained in order to obtain the latest prediction model for the quality physicochemical indicators.
[0014] Thus, since the model obtained from the first training iteration is not accurate enough, the second image preprocessing operation can include more types of operations in subsequent training processes to improve model accuracy. Furthermore, performing the second image preprocessing operation on multiple original images separately ensures the accuracy of the sample images and improves the model's accuracy. Moreover, if a simpler image preprocessing operation can yield an accurate model during the initial training, resources can be saved. However, when the model is inadequate, choosing a more rigorous image preprocessing method can guarantee the model's accuracy.
[0015] In one optional implementation, when the evaluation result indicates that the prediction model for the target quality physicochemical indicators is unqualified, a second image preprocessing operation is performed on multiple original images to obtain updated sample images corresponding to each of the original images, including: Perform background segmentation on the target original image to obtain the initial foreground region in the target original image, where the target original image is any one of multiple original images; Morphological processing is performed on the initial foreground regions to obtain candidate foreground regions; Identify at least one connected sub-region within the candidate foreground region; Obtain the spatial distribution features of at least one connected sub-region in the original target image; Based on the spatial distribution characteristics of at least one connected sub-region in the original target image, select the target connected sub-region from at least one connected sub-region; Perform background segmentation on the target connected sub-region to obtain the region of interest; Cropping the first sub-image corresponding to the region of interest from the original target image; The first sub-image is cropped and / or supplemented according to the preset image size to obtain the second sub-image; Normalize the pixel values of multiple pixels in the second sub-image to obtain the third sample image, which is any sample image in the training dataset.
[0016] In this way, by performing multi-level background segmentation, the background and stem regions are removed, retaining only the fruit regions relevant to quality and physicochemical indicators. This allows for a more accurate model to be obtained during subsequent training, resulting in more accurate predictions. Furthermore, by standardizing the scale, the model can avoid learning false information. Additionally, pixel normalization concentrates pixel values within a smaller scale, accelerating model convergence and improving training efficiency.
[0017] In one optional implementation, after normalizing the pixel values of multiple pixels in the second sub-image to obtain the third sample image, the method further includes: Perform a geometric transformation on the third sample image to obtain at least one sample image.
[0018] In this way, image enhancement operations can increase the richness of images and improve the accuracy of model predictions.
[0019] Secondly, the present invention provides a training device for a predictive model of the quality physicochemical indicators of Shine Muscat grapes, the device comprising: The acquisition module is used to acquire the training dataset for Sunshine Rose grapes. The training dataset includes multiple sample images and the corresponding real quality physicochemical indicators for each sample image. The extraction module is used to extract features from multiple sample images to obtain feature vectors corresponding to each sample image. The training module is used to input the feature vectors corresponding to multiple sample images into the quality and physicochemical index prediction model to be trained in the current training round, so as to obtain the predicted quality and physicochemical indexes corresponding to the multiple sample images output by the quality and physicochemical index prediction model to be trained. Based on the real and predicted quality and physicochemical indexes corresponding to the multiple sample images, the quality and physicochemical index prediction model to be trained is updated to obtain the quality and physicochemical index prediction model corresponding to the current training round. When it is determined that the training stop condition is met, the quality and physicochemical index prediction model corresponding to the current training round is determined as the target quality and physicochemical index prediction model. Alternatively, when it is determined that the training stop condition is not met, the next training round corresponding to the current training round is entered until the training stop condition is determined to be met in the target training round, at which point training stops, and the quality and physicochemical index prediction model corresponding to the target training round is determined as the target quality and physicochemical index prediction model. The target quality and physicochemical index prediction model is used for image recognition of quality and physicochemical indexes based on Sunshine Rose grapes.
[0020] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the training method for the prediction model of the quality physicochemical indicators of Sunshine Rose grapes as described in the first aspect or any corresponding embodiment.
[0021] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute a training method for a prediction model of the quality physicochemical indicators of Sunshine Rose grapes according to the first aspect or any corresponding embodiment described above.
[0022] Fifthly, the present invention provides a computer program product, including computer instructions, which are used to cause the computer to execute the training method for the prediction model of the quality physicochemical indicators of Sunshine Rose grapes according to the first aspect or any corresponding embodiment described above. Attached Figure Description
[0023] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0024] Figure 1 This is a schematic diagram of the first process for training a predictive model of the quality physicochemical indicators of Sunshine Rose grapes according to an embodiment of the present invention. Figure 2 This is a schematic flowchart of image preprocessing operations according to an embodiment of the present invention; Figure 3 This is a schematic diagram according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the second process for training a predictive model of the quality physicochemical indicators of Sunshine Rose grapes according to an embodiment of the present invention. Figure 5 This is a schematic diagram of the training and prediction time series of the quality physicochemical index prediction model for Sunshine Rose grapes according to an embodiment of the present invention. Figure 6 This is a schematic diagram of the first type of evaluation data according to an embodiment of the present invention; Figure 7 This is a schematic diagram of the second type of evaluation data according to an embodiment of the present invention; Figure 8 This is a schematic diagram of the third type of evaluation data according to an embodiment of the present invention; Figure 9This is a schematic diagram of the fourth type of evaluation data according to an embodiment of the present invention; Figure 10 This is a structural block diagram of a training device for a predictive model of the quality physicochemical indicators of Sunshine Rose grapes according to an embodiment of the present invention. Figure 11 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0027] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0028] Shine Muscat grapes possess a combination of high sugar content, low acidity, a rose aroma, edible skin, and a crisp, sweet taste, making them a high-value variety for fresh consumption. With the expansion of planting areas and concentrated market entry, the Shine Muscat grape market has gradually shifted from a stage of high price and scarcity to a stage of quality competition. The quality of the product now depends not only on appearance indicators such as berry size, color, and integrity, but also on internal qualities such as total soluble solids (TSS) and titratable acidity (TA).
[0029] Traditional determinations of soluble solids and titratable acid content rely on refractometers, juicing, and titration experiments. Generally, traditional determinations of sugar content and acidity require sampling, juicing, refractometer readings, or titration. These methods damage the samples and are slow, making it difficult to cover every batch or string of samples. In other words, current experimental methods are destructive, time-consuming, and have sampling limitations, making it difficult to meet the needs of batch, online, and low-cost testing.
[0030] While hyperspectral and near-infrared technologies can be used for internal quality inspection, they typically rely on dedicated light sources, spectrometers, probes, calibration modules, and light-shielding structures, resulting in high equipment and maintenance costs. This makes them unsuitable for low-cost deployment at ordinary production sites and retail outlets.
[0031] According to an embodiment of the present invention, a training method embodiment for a predictive model of the quality physicochemical indicators of Sunshine Rose grapes is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0032] This embodiment provides a training method for a quality physicochemical index prediction model, which can be executed by an electronic device, such as a server or computer. Figure 1 This is a flowchart of a training method for a predictive model of the quality physicochemical indicators of Shine Muscat grapes according to an embodiment of the present invention, as shown below. Figure 1 As shown, the process includes the following steps: Step S101: Obtain the training dataset for Sunshine Rose grapes.
[0033] The training dataset may include multiple sample images and their corresponding true quality physicochemical indicators. These true quality physicochemical indicators may include one or more indicators such as soluble solids content and titratable acid content.
[0034] Specifically, technicians can pre-photograph samples of Shine Muscat grapes and upload the images to an electronic device, which can then acquire the sample images. Additionally, technicians can measure the physicochemical properties of each collected sample, using these measured properties as supervised learning labels. For example, soluble solids content can be measured using a handheld saccharimeter, and titratable acid content can be determined using acid-base titration.
[0035] Step S102: Extract features from multiple sample images to obtain feature vectors corresponding to each sample image.
[0036] Specifically, taking a single sample image as an example, an electronic device can use an image feature extraction algorithm to extract features from the sample image, obtaining its feature vector. Similarly, feature vectors corresponding to multiple sample images can be extracted.
[0037] Step S103: In the current training round, the feature vectors corresponding to multiple sample images are input into the quality physicochemical index prediction model to be trained, so as to obtain the predicted quality physicochemical indexes corresponding to multiple sample images output by the quality physicochemical index prediction model to be trained.
[0038] The quality physicochemical index prediction model to be trained can be any of the following: Partial Least Squares Regression (PLSR), Support Vector Regression (SVR), Random Forest (RF), Neural Network (NN), One Dimensional Convolutional Neural Network (1D CNN), or multi-model fusion model. In this application, the internal structure of the model is not changed; instead, the current model structure and training method are used to perform the training operation.
[0039] Specifically, the electronic device can train the quality physicochemical index prediction model in multiple rounds based on the feature vectors corresponding to multiple sample images and the actual quality physicochemical indices. In each training round, the electronic device can input the feature vectors corresponding to multiple sample images into the quality physicochemical index prediction model to be trained, and the model will perform prediction operations to obtain the predicted quality physicochemical indices corresponding to the multiple sample images.
[0040] Step S104: Based on the real and predicted quality physicochemical indicators corresponding to multiple sample images, update the quality physicochemical indicator prediction model to be trained to obtain the quality physicochemical indicator prediction model corresponding to the current training round.
[0041] Specifically, during the training process, the electronic device can simultaneously input the real quality physicochemical indicators corresponding to multiple sample images into the quality physicochemical indicator prediction model to be trained. Then, after the prediction operation is completed, the loss value can be calculated based on the real quality physicochemical indicators and the predicted quality physicochemical indicators corresponding to multiple sample images, and the model parameters in the quality physicochemical indicator prediction model to be trained can be updated based on the loss value.
[0042] Step S105: When it is determined that the training stop condition is met, the quality physicochemical index prediction model corresponding to the current training round is determined as the target quality physicochemical index prediction model.
[0043] The conditions for stopping training can include the loss value being less than a preset threshold, the number of training iterations reaching a preset number, etc.
[0044] Specifically, in each training round, if the loss value is less than a preset threshold, or if the number of training iterations reaches a preset number, training is stopped, and the quality physicochemical index prediction model that has completed training is determined as the target quality physicochemical index prediction model.
[0045] Alternatively, in step S106, if it is determined that the stop training condition is not met, proceed to the next training round corresponding to the current training round until the stop training condition is determined to be met in the target training round, then stop training and determine the quality physicochemical index prediction model corresponding to the target training round as the target quality physicochemical index prediction model.
[0046] Among them, the target quality physicochemical index prediction model is used for image recognition of quality physicochemical indexes based on Sunshine Rose grapes.
[0047] Specifically, if the loss value is greater than or equal to a preset threshold, or if the number of training iterations has not reached a preset number, the next round of training can continue until, in a subsequent round (i.e., the target training round), the loss value is less than the preset threshold, or the number of training iterations has reached a preset number, at which point training stops, and the quality physicochemical index prediction model after the last round of training is determined as the target quality physicochemical index prediction model.
[0048] Finally, during use, the captured images can be input into the target quality physicochemical index prediction model, which will directly provide the quality physicochemical index based on the captured images.
[0049] The training method for the quality physicochemical index prediction model provided in this embodiment first obtains a training dataset of Shine Muscat grapes. Then, features are extracted from multiple sample images in the training dataset to obtain feature vectors corresponding to each sample image. During training, the feature vectors corresponding to each sample image are input into the quality physicochemical index prediction model to be trained, resulting in the final target quality physicochemical index prediction model. In use, this solution only requires taking images of Shine Muscat grapes and inputting them into the target quality physicochemical index prediction model, which then identifies the target quality physicochemical indexes based on the information in the images. This eliminates the need for destructive testing of Shine Muscat grapes in each detection process. Furthermore, image acquisition is convenient, and the recognition speed of the target quality physicochemical index prediction model is fast. It can efficiently complete the detection of a large number of Shine Muscat grapes, making it suitable for batch, online, and low-cost detection needs. In addition, this solution only requires capturing simple images and does not require the deployment of hyperspectral and near-infrared technologies. In other words, this solution can reduce equipment costs and system complexity while meeting the requirements of automated detection, and facilitates model migration and field deployment.
[0050] In some optional implementations, the sample images can be original images of Shine Muscat grape samples that have undergone image preprocessing and / or image enhancement operations. Accordingly, in step S101 above, obtaining the training dataset of Shine Muscat grapes may include the following specific steps: Step 1: Obtain multiple raw images.
[0051] Step 2: Perform a preset first image preprocessing operation on each of the multiple original images to obtain sample images corresponding to the multiple original images.
[0052] Specifically, technicians can pre-collect various Shine Muscat grape samples under different scenarios, including varying maturity levels, harvest batches, shelf lives, and post-harvest handling conditions (e.g., temperature), and assign a unique sample number to each sample. Simultaneously, the maturity level, harvest batch, shelf life, and post-harvest handling conditions for each sample number can be recorded. Furthermore, for each sample, during collection, the light source brightness, shooting background, camera parameters, shooting distance, and shooting angle can be fixed to capture an image of the sample. During the shooting process, for individual Shine Muscat grapes, multi-angle shooting can be used to obtain images of the fruit surface from different perspectives. After completing the shooting operation, the collected original images and sample numbers can be stored accordingly.
[0053] After acquiring the images, technicians can first perform quality screening on the original images, removing those that are blurry, overexposed, underexposed, or have incomplete fruit areas, thus obtaining a variety of filtered original images.
[0054] After acquiring multiple original images, the electronic device can perform a first image preprocessing operation on each original image to obtain sample images corresponding to the multiple original images. The first image preprocessing operation can include at least one operation type. For example, the first image preprocessing operation can include one or more of the following operation types: background segmentation, morphological processing, region of interest determination, size unification operation, pixel normalization operation, etc.
[0055] Thus, this approach, by performing a first image preprocessing operation on the original images, ensures that the original images conform to a unified standard, thereby making the trained model more accurate. Furthermore, this approach does not collect images of samples from a single harvesting stage or a single indicator, but rather collects images of Shine Muscat grape samples under different conditions, fully considering the impact of harvest maturity, shelf life, and external batch differences on model stability.
[0056] In some optional implementations, the above sample images are all in a primary format. The sample images may include pixel information from multiple channels within the primary format. For example, the primary format may be Red Green Blue (RGB) format, and the multiple channels may include multiple channels from the three channels: red, green, and blue. Accordingly, in step S101 above, the electronic device may perform feature extraction on the multiple sample images separately using the following specific steps to obtain feature vectors corresponding to each of the multiple sample images: Step 1: Using a preset sub-format, perform a format conversion operation on the first sample image to obtain the second sample image.
[0057] Step 2: Based on the pixel information of multiple channels in the main format of the first sample image and the pixel information of multiple channels in the sub-format of the second sample image, determine the target feature vector corresponding to the first sample image.
[0058] The secondary format can include one or more formats, such as Hue Saturation Value (HSV) format, CIE L*a*b* (Lab) format, etc. The first sample image can be any sample image from any sample image. The second sample image can include pixel information from multiple channels under the secondary format.
[0059] Specifically, for any sub-format, the electronic device can perform a format conversion operation on the first sample image based on the pixel conversion relationship between the sub-format and the primary format to obtain a second sample image in that sub-format. After the format conversion, the pixel information in the image will change, allowing subsequent model training to refer to richer image information for predicting quality physicochemical indicators. Furthermore, the electronic device can perform statistical operations on the pixel information of multiple channels in the primary format of the first sample image and the pixel information of multiple channels in the sub-format of the second sample image to obtain statistical parameters, and construct a target feature vector based on the statistical parameters.
[0060] In this way, by combining image information in multiple formats, the model can learn richer information during training, thus providing more accurate prediction results for the physical and chemical indicators of quality in subsequent predictions.
[0061] In some optional implementations, pixel information includes pixel values of multiple pixels; in step two above, determining the target feature vector corresponding to the first sample image based on pixel information of multiple channels in the main format of the first sample image and pixel information of multiple channels in the sub-format of the second sample image may include: Step 1: Based on the pixel values of multiple pixels included in the pixel information of the first channel, determine the mean and standard deviation of the pixel values of the first channel respectively.
[0062] Step 2: Calculate the color ratio between the first channel and the second channel.
[0063] Step 3: Based on the pixel values of multiple pixels included in the pixel information of the third channel, determine the mean and standard deviation of the pixel values of the third channel respectively.
[0064] Step 4: Calculate the color ratio between the third and fourth channels.
[0065] Step 5: Concatenate the mean and standard deviation of pixel values in the first channel, the color ratio between the first and second channels, the mean and standard deviation of pixel values in the third channel, and the color ratio between the third and fourth channels to form the target feature vector.
[0066] The first channel is one of several channels in the primary format. The second channel is one of several channels in the primary format other than the first channel. The third channel is one of several channels in the secondary format other than the third channel.
[0067] Specifically, in step 1, the electronic device can perform statistical operations on the pixel information of one or more channels under the main format. Taking the first channel as an example, the electronic device can calculate the mean and standard deviation of the pixel values of multiple pixels under this channel, which are the statistical parameters mentioned above.
[0068] In step 2, the electronic device can determine the color ratio between the first channel and the second channel based on the ratio between the average pixel value of the first channel and the average pixel value of the second channel. Alternatively, the color ratio between the pixel value of the first channel and the pixel value of the second channel can be calculated separately for each pixel.
[0069] Similarly, in step 3, the electronic device can perform statistical operations on the pixel information of one or more channels in the sub-format. Taking the third channel as an example, the electronic device can calculate the mean and standard deviation of the pixel values of multiple pixels in that channel, which are the statistical parameters mentioned above.
[0070] In step 4, the electronic device can determine the color ratio between the third and fourth channels as the ratio between the average pixel value of the third channel and the average pixel value of the fourth channel. Alternatively, the color ratio between the pixel value of the third channel and the pixel value of the fourth channel can be calculated separately for each pixel.
[0071] In step 5, the electronic device can sequentially concatenate the calculated statistical parameters and color ratios to obtain the target feature vector.
[0072] Since the quality physicochemical indicators are usually related to the color information of Sunshine Rose grapes, from the perspective of channels, the mean can represent the overall color level and the standard deviation can represent the dispersion of color distribution. Therefore, this solution uses the information of each channel itself, as well as the color correlation information between different channels, as feature vectors, which can more accurately identify the quality physicochemical indicators under different color characteristics.
[0073] For example, in RGB format, the mean and standard deviation of pixel values in the R and G channels can be calculated separately, as well as the color ratio of the R and G channels, expressed as (GR) / (G+R). The color ratio of the R and B channels can be expressed as (GB) / (G+B), where G is the mean pixel value of the G channel, R is the mean pixel value of the R channel, and B is the mean pixel value of the B channel. Sub-formats include HSV and Lab formats. For HSV format, the mean and standard deviation of pixel values in the H and S channels can be calculated separately, as well as the color ratio of the H and S channels. For Lab format, the mean and standard deviation of pixel values in the a and b channels can be calculated, as well as the color ratio of the a and b channels. In addition, for the HSV format, the hue information of the H channel can be calculated separately and added to the target feature vector. The hue information of the H channel can be represented as cos(2πH) and sin(2πH), where H can be the mean of the pixel values of the H channel. Alternatively, the hue information of the H channel of each pixel can be calculated separately, where H can be the pixel value of the corresponding pixel in the H channel.
[0074] In the context of measuring Shine Muscat grapes, since the color of Shine Muscat grapes tends to be a combination of green and yellow, the quality physicochemical indicators are usually related to the color information of Shine Muscat grapes. Therefore, this scheme selects the pixel information of the channel that is more related to green and yellow to construct the feature vector, which enables the model to capture the color information that is more related to the quality physicochemical indicators, thereby obtaining a more accurate model. Furthermore, in the prediction process, more accurate quality physicochemical indicators can be predicted.
[0075] In some alternative implementations, the electronic device may also determine the target feature vector of the first sample image in the following specific manner: This scheme allows you to pre-specify the number of elliptical rings to be divided and specify the area of each elliptical ring as a percentage of the entire ellipse. For example, from the inside to the outside, the percentages can be 0% to 35%, 35% to 70%, 70% to 90%, and 90% to 100%.
[0076] The electronic device can first identify the ellipse corresponding to the fruit region in the first sample image. Then, it can identify the major and minor axes of the ellipse and calculate the area of the ellipse based on these axes. According to the proportion of each elliptical ring's area in the total ellipse area, the ellipse is divided into multiple elliptical rings. For each elliptical ring, a sub-feature vector can be extracted (for each pixel in the elliptical ring, the mean, standard deviation, color ratio, etc., of the pixel values in the elliptical ring can be calculated in the aforementioned manner, and after concatenation, the sub-feature vector of the elliptical ring can be obtained). The sub-feature vectors of each elliptical ring are concatenated to obtain a total feature vector, which is directly used as the target feature vector of the first sample image. Alternatively, the total feature vector can be added to the aforementioned target feature vector.
[0077] In this way, this scheme can fully capture the gradient information of the fruit from the inside out related to the quality physicochemical indicators, which fits the shape of Shine Muscat grapes, improves the accuracy of the model, and thus can more accurately predict the quality physicochemical indicators of Shine Muscat grapes. This scheme is more suitable for the application scenarios of Shine Muscat grape detection.
[0078] In some optional implementations, after the training operation is completed, in order to ensure the accuracy of the target quality physicochemical index prediction model, the target quality physicochemical index prediction model can be evaluated. Only when the evaluation result indicates that the target quality physicochemical index prediction model is qualified will the target quality physicochemical index prediction model be used to predict the quality physicochemical index. Accordingly, after the above step S105, the electronic device can also perform the following specific operations: Step 1: Obtain the test dataset.
[0079] The test dataset is similar to the training dataset and may include multiple sample images and their corresponding real-world quality physicochemical indicators. The sample images may include one or more individual images, and the method of obtaining these images can be similar to that used in the training dataset; details will not be elaborated here.
[0080] Step two: Use the test dataset to test the prediction model of the target quality physicochemical indicators and obtain the evaluation results corresponding to the prediction model of the target quality physicochemical indicators.
[0081] Specifically, the electronic device may input a plurality of sample images in the test dataset into the target quality physical and chemical index prediction model respectively, and after the prediction operation is executed by the target quality physical and chemical index prediction model, obtain the predicted quality physical and chemical indicators corresponding to the plurality of sample images respectively. Furthermore, an evaluation result can be calculated according to the predicted quality physical and chemical indicators and the real quality physical and chemical indicators corresponding to the plurality of sample images respectively. For example, the evaluation result can include one or more indicators among coefficient of determination R², correlation coefficient Rp, Root Mean Square Error (RMSE), and Mean Absolute Error (MAE).
[0082] In a case where the evaluation result includes only one indicator, it can be determined whether the indicator is within a preset indicator range; if yes, pass can be determined as the evaluation result, and at this time, the target quality physical and chemical index prediction model can be put into use; if not, fail can be determined as the evaluation result. In a case where the evaluation result includes a plurality of indicators, it can be determined respectively whether the plurality of indicators are within corresponding indicator ranges; when it is determined that all the indicators are within the corresponding indicator ranges, pass can be determined as the evaluation result; when it is determined that any indicator is not within the corresponding indicator range, fail can be determined as the evaluation result.
[0083] Step 3: in a case where it is determined that the evaluation result indicates that the target quality physical and chemical index prediction model is unqualified, perform a second image preprocessing operation on a plurality of original images respectively, to obtain updated sample images corresponding to the plurality of original images respectively.
[0084] Wherein, the second image preprocessing operation may include multiple of the following operation types: background segmentation, morphological processing, determining a region of interest, size unification operation, pixel normalization operation, etc. The number of operation types included in the second image preprocessing operation is greater than the number of operation types included in the first image preprocessing operation. The updated sample images respectively corresponding to the plurality of original images are used to re-perform a training operation on the to-be-trained quality physical and chemical index prediction model, so as to obtain the latest quality physical and chemical index prediction model.
[0085] Specifically, in a case where it is determined that the evaluation result is pass, the target quality physical and chemical index prediction model can be put into use; in a case where it is determined that the evaluation result is fail, the quality physical and chemical index prediction model can be retrained.
[0086] In order to improve the accuracy of the prediction result, before training, a stricter second image preprocessing operation can be performed on the collected original images first, to obtain a plurality of updated sample images corresponding to the original images respectively.
[0087] Thus, since the model obtained from the first training iteration is not accurate enough, the second image preprocessing operation can include more types of operations in subsequent training processes to improve model accuracy. Furthermore, performing the second image preprocessing operation on multiple original images separately ensures the accuracy of the sample images and improves the model's accuracy. Moreover, if a simpler image preprocessing operation can yield an accurate model during the initial training, resources can be saved. However, when the model is inadequate, choosing a more rigorous image preprocessing method can guarantee the model's accuracy.
[0088] In some optional implementations, in step three above, the electronic device may perform a second image preprocessing operation on each of the multiple original images using the following specific steps to obtain updated sample images corresponding to each of the multiple original images: Step 1: Identify the initial foreground region in the original target image.
[0089] The target original image is any one of multiple original images.
[0090] Step 2: Perform morphological processing on the initial foreground regions to obtain at least one candidate foreground region.
[0091] Step 3: Identify at least one connected sub-region in the candidate foreground region.
[0092] Step 4: Obtain the spatial distribution features of at least one connected sub-region in the original target image.
[0093] Step 5: Select the target connected sub-region from the at least one connected sub-region based on the spatial distribution characteristics of the at least one connected sub-region in the original target image.
[0094] Step 6: Perform background segmentation on the target connected sub-region to obtain the region of interest.
[0095] Step 7: Crop the first sub-image corresponding to the region of interest from the original target image.
[0096] Step 8: Crop and / or supplement the first sub-image according to the preset image size to obtain the second sub-image.
[0097] Step nine: Normalize the pixel values of multiple pixels in the second sub-image to obtain the third sample image.
[0098] Specifically, in step one, the electronic device can employ a preset first background segmentation algorithm to perform background segmentation on each type of original image. For example, the first background segmentation algorithm can be any of the following: color thresholding, background subtraction, adaptive thresholding, edge detection, or image segmentation models. Taking the target original image as an example, after performing background segmentation on the target original image using the first background segmentation algorithm, a background segmentation result corresponding to the target original image can be obtained. The background segmentation result includes the semantic segmentation result of each pixel, which indicates whether the pixel is a background pixel or a fruit pixel. In this way, the background segmentation algorithm can separate the Sunshine Rose grape fruit region from the background based on the differences in color, brightness, or texture between the fruit region and the background region, thereby removing the interference of background pixels on the model, allowing the model to focus on the main fruit, improving the accuracy of color features, and providing a foundation for subsequent mask extraction and region of interest cropping.
[0099] Furthermore, the electronic device can set the pixel value of the fruit pixel to a first value (which can be 1) and the pixel value of the background pixel to a second value (which can be 0) based on the semantic segmentation results of each pixel, thus obtaining a binary mask of the fruit region, which determines the initial foreground region. The region indicated by the first value is the initial foreground region. In this way, the effective area of the fruit can be clearly defined, preventing the background from participating in color statistics, facilitating subsequent morphological processing, providing a basis for fruit stem removal, maximum connected component extraction, and region of interest clipping, and improving the consistency of the model's input region.
[0100] In step two, the electronic device can perform morphological processing on the initial foreground region to obtain candidate foreground regions. For example, opening operations can be used to remove background noise points, closing operations can be used to fill holes in the fruit region, and dilation or hole-filling operations can be combined to process the fruit region, making its boundaries more continuous and complete. In this way, scattered noise generated during segmentation can be removed, voids inside the fruit region can be repaired, the continuity of the fruit boundary can be improved, irrelevant small regions can be avoided from being mistaken for fruits, and the accuracy of subsequent maximum connected component extraction can be improved.
[0101] In steps three to five, the electronic device can first identify each connected sub-region included in the candidate foreground region, and then identify the spatial distribution characteristics of each connected sub-region. Based on the spatial distribution characteristics of each connected sub-region, a target connected sub-region is selected from at least one connected sub-region.
[0102] For example, the spatial distribution feature can be area. Accordingly, the electronic device can count the number of pixels in each connected sub-region and determine the connected sub-region containing the most pixels as the target connected sub-region. As another example, the spatial distribution feature can be the coordinate range of pixels. Accordingly, the electronic device can determine the degree of overlap between the coordinate range of pixels in each connected sub-region and a preset coordinate range, that is, the number of pixels containing the same value, and determine the connected sub-region with the highest degree of overlap as the target connected sub-region.
[0103] This removes residual background areas, preserves the main fruit target, improves the accuracy of region of interest extraction, avoids noisy areas from participating in model input, and ensures consistency of input objects across different sample images.
[0104] In step six, the electronic device can employ a second background segmentation algorithm to further segment the target connected sub-region to obtain the region of interest. For example, the second background segmentation algorithm can be any of the following: color thresholding, elongated morphological structure detection, edge detection, or an image segmentation model. This allows for the further identification of non-fruit regions within the target connected sub-region. For instance, since the fruit stalk region is elongated, elongated morphological structure detection facilitates its detection. Furthermore, removing the fruit stalk region reduces the interference of fruit stalk color on maturity and sugar-acid prediction, preventing the model from learning fruit stalk features unrelated to internal quality and enhancing the model's predictive stability for soluble solids content and titratable acid content.
[0105] In step seven, the electronic device can crop out a first sub-image from the original target image based on the pixel coordinates indicated by the region of interest.
[0106] In step eight, the electronic device can identify the pixel coordinate range of the first sub-image, and then compare the pixel coordinate range with a preset image size to determine the missing pixels and / or redundant pixels of the first sub-image. For missing pixels, the pixel value of the missing pixels can be set to a fixed value, for example, the fixed value can be 0. For redundant pixels, they can be directly cropped. After cropping and / or supplementing operations, the second sub-image is obtained.
[0107] In step nine, the electronic device can normalize the pixel values of multiple pixels in the second sub-image to obtain the third sample image. For example, the pixel values can be scaled from 0 to 255 to 0 to 1. This avoids the impact of different pixel scales on model training, accelerates model convergence, improves numerical computation stability, facilitates batch input of different images, and promotes stable model training.
[0108] After completing step nine, subsequent feature vector extraction operations are performed. For example, the image preprocessing workflow can be as follows: Figure 2As shown. For example, when performing the first image preprocessing operation, only the most basic background segmentation and region of interest determination can be performed. When performing the second image preprocessing operation, all operations such as background segmentation, morphological processing, region of interest determination, size unification, and pixel normalization can be performed, referring to the image preprocessing operations in steps one to nine above.
[0109] In some optional implementations, after completing step nine above, the electronic device can further perform image enhancement operations on the third sample image to obtain more sample images. Accordingly, the following specific steps can also be performed: Perform a geometric transformation on the third sample image to obtain at least one sample image.
[0110] Geometric transformation operations can include operations such as rotation and flipping.
[0111] Specifically, the electronic device can rotate the third sample image multiple times based on preset angles to obtain sample images from multiple angles. Alternatively, it can flip the third sample image to obtain a flipped sample image. This allows for the acquisition of more sample images. The sample images obtained by performing geometric transformations on the third sample image share a common real-world quality physicochemical index with the third sample image. Thus, even with a limited number of sample images, sufficient sample images can be obtained for model training.
[0112] In some alternative implementations, the operation types in the first image preprocessing operation and the second image preprocessing operation can be the same, but the operation parameters can be different for each operation type. For example, in the background segmentation operation, the color threshold can be different.
[0113] In some optional embodiments, after performing a preset first image preprocessing operation on each of the multiple original images to obtain sample images corresponding to the multiple original images, a first geometric transformation operation can also be performed on each sample image. The number of rotation angles in the first geometric transformation operation can be less than the number of rotation angles in the aforementioned geometric transformation operation.
[0114] In some alternative implementations, the model parameters of the quality physicochemical index model to be trained can be adjusted. For example, when the model is a random forest model, the number of random forests can be increased, such as from dozens to 100, 200, 500, etc., or the number of minimum leaf nodes can be increased.
[0115] In some optional implementations, during the use of the target quality physicochemical index model, after obtaining the target image of the Sunshine Rose grape sample to be tested, the target image can be subjected to the first image preprocessing operation or the second image preprocessing operation described above, and then the feature vector extraction operation can be performed. The extracted target feature vector is then input into the target quality physicochemical index model to obtain the target quality physicochemical index output by the target quality physicochemical index model.
[0116] The following example illustrates the training, testing, and application processes of the aforementioned quality physicochemical index model for Sunshine Rose grapes.
[0117] like Figure 3 The diagram illustrates the underlying principle of this solution. During the ripening and post-harvest shelf life of Shine Muscat grapes, the soluble solids content and titratable acid content change, while the color, brightness, and local phenotypic characteristics of the fruit surface also change accordingly. By acquiring RGB images of Shine Muscat grapes and performing image standardization and feature extraction, image information reflecting the fruit's phenotypic state can be obtained. Furthermore, a machine learning model can be used to establish a mapping relationship between image information and internal quality indicators, thereby predicting the soluble solids content and titratable acid content of Shine Muscat grapes without damaging the sample. Additionally, to improve prediction accuracy, image augmentation can be used to simulate fruit posture and morphological perturbations, thereby covering a wider range of fruit phenotypic distributions and enhancing the model's training effect.
[0118] like Figure 4 As shown, firstly, Shine Muscat grape samples with different shelf lives (0 / 2 / 4 / 6 days) were acquired, and standard RGB image processing and determination of soluble solids content and titratable acid content were performed simultaneously. During RGB image processing, after acquiring the RGB images, preprocessing and data augmentation were performed to improve data quality. These images were then combined with the physicochemical indicators to construct a paired database of RGB images and internal indicators (quality physicochemical indicators) (i.e., the aforementioned training dataset and / or test dataset). Based on this database, an internal quality prediction model (i.e., a quality physicochemical indicator prediction model) was trained. Ultimately, this allows for the automatic prediction and output of soluble solids content and titratable acid content simply by inputting an image of Shine Muscat grapes, thus forming a complete quality evaluation result.
[0119] like Figure 5The diagram shows the training and prediction timeline of the quality physicochemical index prediction model. During the training phase, RGB images of the training samples are first acquired, and their soluble solids content and titratable acid content are simultaneously measured. Subsequently, the original RGB images are preprocessed and data augmented, and the generated image features and physicochemical indices are input into the model module to train the prediction model for quality physicochemical indices such as soluble solids content and titratable acid content. The model is then validated through testing to determine the optimal parameters. During the prediction phase, images of the samples to be tested are acquired and processed to obtain standardized images. These standardized images are then input into the model module, which outputs predicted values, ultimately converting them into internal quality indices to complete the result output.
[0120] Figures 6 to 9 This section presents the evaluation results of the quality physicochemical index prediction model under different scenarios. The first column represents time, the second column represents the prediction target, the third column represents the model type, and the fourth to seventh columns represent the four evaluation indicators. The "Global" indicator indicates that all sample images from days 0, 2, 4, and 6 were used during the testing process.
[0121] Figure 6 The evaluation results are based on the prediction of soluble solids content using RGB images. Figure 7 The evaluation results are based on the prediction of titratable acid content using RGB images. Figure 8 The evaluation results are based on the prediction of soluble solids content from image-enhanced RGB images. Figure 9 This is an evaluation result of the prediction of titratable acid content based on the enhanced RGB image. Figure 6 and Figure 8 The comparison shows that the model's predictions are more accurate after image enhancement. Figure 7 and Figure 9 The comparison shows that the model's predictions are more accurate after image enhancement.
[0122] For example, taking the random forest model as an example of the quality physicochemical index prediction model, in Figure 6 In the sample with time 0, the R² predicted by TSS is approximately 0.877. Figure 7 In the sample at time 0, the R² predicted by TA is approximately 0.827, indicating that the RGB image contains phenotypic information that can be used for internal quality prediction. After image enhancement, in Figure 8 In the sample with time 0, the TSS predictive R² improved to 0.954, and the RMSE improved from 0.571 (reference). Figure 6 The value dropped to 0.354. Figure 9In the sample at time 0, the TA prediction R² improved to 0.967. This demonstrates that image augmentation can significantly improve the model's prediction accuracy and robustness.
[0123] Furthermore, taking a one-dimensional convolutional neural network model as an example, for the sample at time 6, the TSS prediction R² is 0.803 (reference). Figure 6 Increased to 0.919 (reference) Figure 8 Therefore, image enhancement operations can help improve the robustness of the model under complex changes in the later stages of shelf life.
[0124] Based on the data provided in the above evaluation results, the samples used in the testing process were from external batches, i.e., new data not used during model training. Under these circumstances, the accuracy of the model's predictions can still be guaranteed. Furthermore, in practical applications, a small number of new batches of samples can be used to retrain the latest quality physicochemical index prediction model for specific scenarios, thereby calibrating the model and further ensuring its accuracy. In other words, this solution can improve the generalization ability in practical applications.
[0125] This embodiment also provides a training device for a quality physicochemical index prediction model. This device is used to implement the above embodiments and preferred embodiments, and will not be repeated for details already described. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0126] This embodiment provides a training device for a predictive model of the quality physicochemical indicators of Sunshine Rose grapes, such as... Figure 10 As shown, it includes: The acquisition module 1010 is used to acquire the training dataset of Sunshine Rose grapes. The training dataset includes multiple sample images and the real quality physicochemical indicators corresponding to the multiple sample images. The extraction module 1020 is used to extract features from multiple sample images respectively, and obtain feature vectors corresponding to the multiple sample images respectively; The training module 1030 is used to input the feature vectors corresponding to multiple sample images into the quality physicochemical index prediction model to be trained in the current training round, so as to obtain the predicted quality physicochemical indexes corresponding to the multiple sample images output by the quality physicochemical index prediction model to be trained; according to the real quality physicochemical indexes and predicted quality physicochemical indexes corresponding to the multiple sample images, the quality physicochemical index prediction model to be trained is updated to obtain the quality physicochemical index prediction model corresponding to the current training round; when it is determined that the training stop condition is met, the quality physicochemical index prediction model corresponding to the current training round is determined as the target quality physicochemical index prediction model; or, when it is determined that the training stop condition is not met, the next training round corresponding to the current training round is entered until the training stop condition is determined to be met in the target training round, then training is stopped, and the quality physicochemical index prediction model corresponding to the target training round is determined as the target quality physicochemical index prediction model, wherein the target quality physicochemical index prediction model is used for image recognition of quality physicochemical indexes based on Sunshine Rose grapes.
[0127] In some optional implementations, the sample images are all in the master format, and the sample images include pixel information from multiple channels under the master format; the extraction module 1020 is specifically used for: The first sample image is converted using a preset sub-format to obtain the second sample image. The first sample image is any one of multiple sample images, and the second sample image includes pixel information from multiple channels under the sub-format. Based on the pixel information of multiple channels in the primary format of the first sample image and the pixel information of multiple channels in the secondary format of the second sample image, the target feature vector corresponding to the first sample image is determined.
[0128] In some optional implementations, the pixel information includes the pixel values of multiple pixels; the extraction module 1020 is specifically used for: Based on the pixel values of multiple pixels included in the pixel information of the first channel, the mean and standard deviation of the pixel values of the first channel are determined respectively, wherein the first channel is one of the multiple channels under the main format; Calculate the color ratio between the first channel and the second channel, where the second channel is one of the other channels in the main format besides the first channel; Based on the pixel values of multiple pixels included in the pixel information of the third channel, the mean and standard deviation of the pixel values of the third channel are determined respectively, where the third channel is one of the multiple channels under the sub-format; Calculate the color ratio between the third and fourth channels, where the fourth channel is one of the channels other than the third channel in the sub-format; The mean and standard deviation of pixel values in the first channel, the color ratio between the first and second channels, the mean and standard deviation of pixel values in the third channel, and the color ratio between the third and fourth channels are concatenated to form the target feature vector.
[0129] In some optional implementations, the acquisition module 1010 is specifically used for: Acquire multiple raw images; Perform a preset first image preprocessing operation on multiple original images to obtain sample images corresponding to the multiple original images.
[0130] In some alternative embodiments, the device further includes an image processing module for: Obtain the test dataset; Using a test dataset, the prediction model for the target quality physicochemical indicators was tested, and the evaluation results corresponding to the prediction model for the target quality physicochemical indicators were obtained. If the evaluation result indicates that the prediction model for the target quality physicochemical indicators is unqualified, a second image preprocessing operation is performed on multiple original images to obtain updated sample images corresponding to the original images. The number of operation types included in the second image preprocessing operation is greater than the number of operation types in the first image preprocessing operation. The updated sample images corresponding to the multiple original images are used to retrain the prediction model for the quality physicochemical indicators to be trained in order to obtain the latest prediction model for the quality physicochemical indicators.
[0131] In some alternative implementations, the image processing module is specifically used for: Perform background segmentation on the target original image to obtain the initial foreground region in the target original image, where the target original image is any one of multiple original images; Morphological processing is performed on the initial foreground regions to obtain candidate foreground regions; Identify at least one connected sub-region within the candidate foreground region; Obtain the spatial distribution features of at least one connected sub-region in the original target image; Based on the spatial distribution characteristics of at least one connected sub-region in the original target image, select the target connected sub-region from at least one connected sub-region; Perform background segmentation on the target connected sub-region to obtain the region of interest; Cropping the first sub-image corresponding to the region of interest from the original target image; The first sub-image is cropped and / or supplemented according to the preset image size to obtain the second sub-image; Normalize the pixel values of multiple pixels in the second sub-image to obtain the third sample image, which is any sample image in the training dataset.
[0132] In some alternative implementations, the image processing module is further configured to: Perform a geometric transformation on the third sample image to obtain at least one sample image.
[0133] The training device for the quality physicochemical index prediction model provided in this embodiment of the invention can execute the training method for the quality physicochemical index prediction model provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the above modules and units are the same as in the corresponding embodiments described above, and will not be repeated here.
[0134] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0135] The following is a detailed reference. Figure 11 The diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present invention. The electronic device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 1101, which can perform various appropriate actions and processes according to a program stored in ROM 1102 or a program loaded from memory 1108 into RAM 1103. RAM 1103 also stores various programs and data required for the operation of the electronic device. The processor 1101, ROM 1102, and RAM 1103 are interconnected via bus 1104. An input / output (I / O) interface 1105 is also connected to bus 1104; wherein ROM is a read-only memory and RAM is a random access memory.
[0136] Typically, the following devices can be connected to I / O interface 1105: input devices 1106 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 1107 including, for example, liquid crystal displays, speakers, vibrators, etc.; memory devices 1108 including, for example, magnetic tape, hard disks, etc.; and communication devices 1109. Communication device 1109 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although... Figure 11 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0137] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 1109, or installed from a memory 1108, or installed from a ROM 1102. When the computer program is executed by the processor 1101, it performs the functions defined in the training method of the quality physicochemical index prediction model of the embodiments of the present invention.
[0138] Figure 11 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0139] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the training method for the quality physicochemical index prediction model shown in the above embodiments is implemented.
[0140] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0141] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A training method for a predictive model of the quality physicochemical indicators of Shine Muscat grapes, characterized in that, The method includes: Obtain a training dataset for Shine Muscat grapes, wherein the training dataset includes multiple sample images and multiple real quality physicochemical indicators corresponding to the sample images respectively; Feature extraction is performed on each of the sample images to obtain feature vectors corresponding to each of the sample images; In the current training round, the feature vectors corresponding to the multiple sample images are input into the quality physicochemical index prediction model to be trained, and the predicted quality physicochemical indexes corresponding to the multiple sample images output by the quality physicochemical index prediction model to be trained are obtained. Based on the actual and predicted quality physicochemical indicators corresponding to the multiple sample images, the quality physicochemical indicator prediction model to be trained is updated to obtain the quality physicochemical indicator prediction model corresponding to the current training round. When it is determined that the conditions for stopping training are met, the quality physicochemical index prediction model corresponding to the current training round is determined as the target quality physicochemical index prediction model. Alternatively, if the training stop condition is not met, the system proceeds to the next training round corresponding to the current training round until the training stop condition is met in the target training round. In this case, the training stops, and the quality physicochemical index prediction model corresponding to the target training round is determined as the target quality physicochemical index prediction model. The target quality physicochemical index prediction model is used for image recognition of quality physicochemical indexes based on Sunshine Rose grapes.
2. The method according to claim 1, characterized in that, The sample images are all in the main format, and the sample images include pixel information of multiple channels under the main format; The step of extracting features from multiple sample images to obtain feature vectors corresponding to each sample image includes: A preset sub-format is used to perform a format conversion operation on the first sample image to obtain a second sample image, wherein the first sample image is any one of the multiple sample images, and the second sample image includes pixel information of multiple channels under the sub-format; Based on the pixel information of multiple channels in the primary format of the first sample image and the pixel information of multiple channels in the secondary format of the second sample image, a target feature vector corresponding to the first sample image is determined.
3. The method according to claim 2, characterized in that, The pixel information includes pixel values of multiple pixels; determining the target feature vector corresponding to the first sample image based on the pixel information of multiple channels under the main format in the first sample image and the pixel information of multiple channels under the sub-format in the second sample image includes: Based on the pixel values of multiple pixels included in the pixel information of the first channel, the mean and standard deviation of the pixel values of the first channel are determined respectively, wherein the first channel is one of the multiple channels under the main format; Calculate the color ratio between the first channel and the second channel, wherein the second channel is one of the channels other than the first channel among the multiple channels under the main format; Based on the pixel values of multiple pixels included in the pixel information of the third channel, the mean and standard deviation of the pixel values of the third channel are determined respectively, wherein the third channel is one of the multiple channels under the sub-format; Calculate the color ratio between the third channel and the fourth channel, wherein the fourth channel is one of the channels other than the third channel among the multiple channels in the sub-format; The mean and standard deviation of pixel values in the first channel, the color ratio between the first and second channels, the mean and standard deviation of pixel values in the third channel, and the color ratio between the third and fourth channels are concatenated to form the target feature vector.
4. The method according to any one of claims 1 to 3, characterized in that, The training dataset for obtaining Shine Muscat grapes includes: Acquire multiple raw images; A preset first image preprocessing operation is performed on each of the original images to obtain sample images corresponding to each of the original images.
5. The method according to claim 4, characterized in that, The method further includes: Obtain the test dataset; Using the test dataset, the target quality physicochemical index prediction model is tested to obtain the evaluation results corresponding to the target quality physicochemical index prediction model. If the evaluation result indicates that the target quality physicochemical index prediction model is unqualified, a second image preprocessing operation is performed on each of the original images to obtain updated sample images corresponding to each of the original images. The number of operation types included in the second image preprocessing operation is greater than the number of operation types in the first image preprocessing operation. The updated sample images corresponding to the original images are used to retrain the quality physicochemical index prediction model to be trained in order to obtain the latest quality physicochemical index prediction model.
6. The method according to claim 5, characterized in that, When the evaluation result indicates that the prediction model for the target quality physicochemical indicators is unqualified, a second image preprocessing operation is performed on each of the multiple original images to obtain updated sample images corresponding to each of the multiple original images, including: A background segmentation operation is performed on the target original image to obtain the initial foreground region in the target original image, wherein the target original image is any one of multiple original images; Morphological processing is performed on the initial foreground regions to obtain candidate foreground regions; Identify at least one connected sub-region within the candidate foreground region; Obtain the spatial distribution features of at least one of the connected sub-regions in the original target image; Based on the spatial distribution characteristics of at least one of the connected sub-regions in the original target image, a target connected sub-region is selected from at least one of the connected sub-regions; Perform background segmentation on the target connected sub-region to obtain the region of interest; A first sub-image corresponding to the region of interest is cropped from the original target image; According to the preset image size, the first sub-image is cropped and / or supplemented to obtain the second sub-image; The pixel values of multiple pixels in the second sub-image are normalized to obtain a third sample image, which is any sample image in the training dataset.
7. The method according to claim 6, characterized in that, After normalizing the pixel values of multiple pixels in the second sub-image to obtain the third sample image, the method further includes: Perform a geometric transformation operation on the third sample image to obtain at least one sample image.
8. A training device for a predictive model of the quality physicochemical indicators of Shine Muscat grapes, characterized in that, The device includes: The acquisition module is used to acquire the training dataset of Sunshine Rose grapes, wherein the training dataset includes multiple sample images and multiple real quality physicochemical indicators corresponding to the sample images respectively; The extraction module is used to extract features from multiple sample images to obtain feature vectors corresponding to each of the sample images. The training module is used to input the feature vectors corresponding to multiple sample images into the quality physicochemical index prediction model to be trained in the current training round, so as to obtain the predicted quality physicochemical indexes corresponding to the multiple sample images output by the quality physicochemical index prediction model to be trained; update the quality physicochemical index prediction model to be trained according to the real quality physicochemical indexes and predicted quality physicochemical indexes corresponding to the multiple sample images, so as to obtain the quality physicochemical index prediction model corresponding to the current training round; when it is determined that the training stop condition is met, the quality physicochemical index prediction model corresponding to the current training round is determined as the target quality physicochemical index prediction model; or, when it is determined that the training stop condition is not met, the module enters the next training round corresponding to the current training round until the training stop condition is determined to be met in the target training round, at which point the training stops, and the quality physicochemical index prediction model corresponding to the target training round is determined as the target quality physicochemical index prediction model, wherein the target quality physicochemical index prediction model is used for image recognition of quality physicochemical indexes based on Sunshine Rose grapes.
9. An electronic device, characterized in that, include: The system includes a memory and a processor, which are interconnected. The memory stores computer instructions, and the processor executes the computer instructions to perform the training method for the prediction model of the quality physicochemical indicators of Sunshine Rose grapes as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the training method of the quality physicochemical index prediction model of Sunshine Rose grapes according to any one of claims 1 to 7.