Model training method, remaining shelf life prediction method, device, equipment and medium

By establishing a freshness prediction model based on the Hidden Markov model, the problem of inaccurate evaluation of fruit remaining shelf life in the prior art is solved, and more accurate prediction and more efficient transportation and retail processes are achieved.

CN119250690BActive Publication Date: 2025-03-21BEIJING TECH & BUSINESS UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411233735.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2025-03-21
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

The existing technology is difficult to accurately assess the remaining shelf life of fruits, resulting in problems in transportation and retail.

Method used

A model training method is adopted, by obtaining the target training set of multiple training samples, using the feature extraction model to extract fresh feature data and corrupt feature data, construct freshness index, and train based on the hidden Markov model to establish a freshness prediction model to determine the remaining shelf life of the fruit.

Benefits of technology

A more accurate prediction of the remaining shelf life of fruits is achieved, and the efficiency and accuracy of the transportation and retail links are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119250690B_ABST
    Figure CN119250690B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of food testing, and in particular to a model training method, a remaining shelf life prediction method, a device, an equipment and a medium. The model training method includes obtaining a target training set including multiple training samples, each training sample includes multiple groups of detection data of the same target fruit distributed along a time series, and each group of detection data corresponds to a freshness score; multiple training samples are input into a feature extraction model to obtain multiple groups of feature data, multiple groups of freshness indicators are constructed based on the multiple groups of feature data and an observation set is constructed, and a hidden Markov model is established based on the observation set for training, and the model obtained after training is used as a freshness prediction model; the freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness indicator sequence of the target fruit, and the freshness score is used to determine the remaining shelf life of the target fruit. The use of this method can more accurately determine the remaining shelf life of the fruit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of food testing, and in particular to a model training method, a remaining shelf life prediction method, a device, a equipment and a medium. Background Art

[0002] Generally, most fruits have a short lifespan after being picked. For example, strawberries, bananas, and lychees. In the sales and transportation process, merchants need to classify fruits based on the length of their remaining shelf life. For example, fruits in a relatively fresh state are first-level fruits, which have a longer remaining shelf life; fruits in the best edible state are second-level fruits, which have a shorter remaining shelf life; fruits in the decaying stage are third-level fruits, which have a lower edible value. Accurately assessing the remaining shelf life of fruits is of great significance to the transportation process and retail links.

[0003] However, in reality, people often rely on their senses and experience to assess the remaining shelf life of fruits, which is less accurate. Therefore, how to more accurately determine the remaining shelf life of fruits is an urgent problem to be solved. Summary of the invention

[0004] Based on this, it is necessary to provide a model training method, a remaining shelf life prediction method, a device, equipment and a medium that can more accurately determine the remaining shelf life of fruits in response to the above technical problems.

[0005] In a first aspect, the present application provides a model training method, comprising:

[0006] Acquire a target training set including a plurality of training samples, each of the training samples including a plurality of groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponding to a freshness score, and the detection data including component composition and sensory characteristics;

[0007] Inputting the plurality of training samples into a feature extraction model to obtain a plurality of sets of feature data, wherein the feature data includes fresh feature data and corruption feature data;

[0008] Constructing multiple groups of freshness indicators based on the multiple groups of feature data;

[0009] The multiple groups of freshness indicators are used to construct an observation set, and a hidden Markov model is established based on the observation set for training, and the model obtained after training is used as a freshness prediction model;

[0010] The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit, and the target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

[0011] In one embodiment, the feature extraction model is a DBN model, and the plurality of training samples are input into the feature extraction model to obtain a plurality of sets of feature data, including:

[0012] For each of the training samples, the training sample is divided in a time series according to a preset ratio to obtain subdivided samples corresponding to the training sample, wherein the subdivided samples include fresh samples and corrupt samples;

[0013] The subdivided samples corresponding to each of the multiple training samples are input into the DBN model for feature extraction to obtain multiple groups of feature data.

[0014] In one embodiment, constructing multiple groups of freshness indicators based on the multiple groups of feature data includes:

[0015] For each set of the characteristic data, the degree of deviation between the fresh characteristic data and the corruption characteristic data is determined, and the degree of deviation is used as the freshness index of the target fruit.

[0016] In one embodiment, the method further comprises:

[0017] Acquire multiple initial samples, each of which includes multiple groups of test data of the same target fruit distributed along a time series, each group of test data corresponds to a freshness score, and the test data includes component composition and sensory characteristics;

[0018] Processing the multiple initial samples based on the target GAN network to generate multiple expanded samples;

[0019] A target training set is constructed based on the multiple expanded samples and the multiple initial samples.

[0020] In one embodiment, the initial GAN ​​network includes a generator and a discriminator, and the training process of the target GAN network includes:

[0021] Determining a first loss based on the expectation and a authenticity score between the initial sample and the initial sample sampling determined by the discriminator;

[0022] Determine a second loss based on the expectation and the authenticity score between the generated data and the initial sample determined by the discriminator, wherein the generated data is data generated by the generator from the initial sample;

[0023] Constructing a first loss function based on the first loss and the second loss, using the second loss as the second loss function, using the first loss function as the loss function of the discriminator, and using the second loss function as the loss function of the generator;

[0024] Based on the first loss function and the second loss function, the initial GAN ​​network is trained to obtain a target GAN network.

[0025] In a second aspect, the present application also provides a method for predicting remaining shelf life, comprising:

[0026] Acquiring detection information of the target fruit, wherein the detection information includes at least one of component composition and sensory characteristics;

[0027] Processing the detection information using a freshness prediction model to obtain a freshness score for the target fruit;

[0028] Determining a remaining shelf life of the target fruit based on the freshness score;

[0029] The freshness prediction model is obtained by training a hidden Markov model based on an observation set;

[0030] Among them, the observation set is constructed based on multiple groups of freshness indicators, and the multiple groups of freshness indicators are constructed based on multiple groups of feature data, and the feature data include fresh feature data and corruption feature data. The multiple groups of feature data are extracted from multiple training samples based on a feature extraction model, and each of the training samples includes multiple groups of detection data distributed along a time series for the same target fruit, and each group of detection data corresponds to a freshness score, and the detection data includes component composition and sensory characteristics.

[0031] In a third aspect, the present application also provides a model training device, including a training sample acquisition module, a feature extraction module, a freshness index construction module and a training module, wherein:

[0032] A training sample acquisition module is used to acquire a target training set including a plurality of training samples, each of which includes a plurality of groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponds to a freshness score, and the detection data includes component composition and sensory characteristics;

[0033] A feature extraction module, used for inputting the plurality of training samples into a feature extraction model to obtain a plurality of sets of feature data, wherein the feature data includes fresh feature data and corruption feature data;

[0034] A freshness index construction module, used to construct multiple groups of freshness indexes based on the multiple groups of feature data;

[0035] A training module, used to construct an observation set from the multiple groups of freshness indicators, and establish a hidden Markov model based on the observation set for training, and use the model obtained after training as a freshness prediction model;

[0036] The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit, and the target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

[0037] In a fourth aspect, the present application further provides a remaining shelf life prediction device, the device comprising a target detection information acquisition module, an extraction module, a freshness score determination module and a remaining shelf life prediction module, wherein:

[0038] A target detection information acquisition module, used to acquire target detection information of a target fruit, wherein the detection information includes at least one of component composition and sensory characteristics;

[0039] An extraction module, used for extracting the target detection information using a feature extraction model to obtain a target freshness feature sequence;

[0040] A freshness score determination module, used to process the target freshness feature sequence using a freshness prediction model to obtain a freshness score for the target fruit;

[0041] A remaining shelf life prediction module, used for determining the remaining shelf life of the target fruit based on the freshness score;

[0042] The freshness prediction model is obtained by training a hidden Markov model based on an observation set;

[0043] Among them, the observation set is constructed based on multiple groups of freshness indicators, and the multiple groups of freshness indicators are constructed based on multiple groups of feature data, and the feature data include fresh feature data and corruption feature data. The multiple groups of feature data are extracted from multiple training samples based on a feature extraction model, and each of the training samples includes multiple groups of detection data distributed along a time series for the same target fruit, and each group of detection data corresponds to a freshness score, and the detection data includes component composition and sensory characteristics.

[0044] In a fifth aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0045] Acquire a target training set including a plurality of training samples, each of the training samples including a plurality of groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponding to a freshness score, and the detection data including component composition and sensory characteristics;

[0046] Inputting the plurality of training samples into a feature extraction model to obtain a plurality of sets of feature data, wherein the feature data includes fresh feature data and corruption feature data;

[0047] Constructing multiple groups of freshness indicators based on the multiple groups of feature data;

[0048] The multiple groups of freshness indicators are used to construct an observation set, and a hidden Markov model is established based on the observation set for training, and the model obtained after training is used as a freshness prediction model;

[0049] The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit, and the target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

[0050] In a sixth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0051] Obtaining a target training set including a plurality of training samples, each of the training samples including a plurality of groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponding to a freshness score, and the detection data including component composition and sensory characteristics;

[0052] Inputting the plurality of training samples into a feature extraction model to obtain a plurality of sets of feature data, wherein the feature data includes fresh feature data and corruption feature data;

[0053] Constructing multiple groups of freshness indicators based on the multiple groups of feature data;

[0054] The multiple groups of freshness indicators are used to construct an observation set, and a hidden Markov model is established based on the observation set for training, and the model obtained after training is used as a freshness prediction model;

[0055] The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit, and the target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

[0056] The above-mentioned model training method, remaining shelf life prediction method, device, equipment and medium, in the embodiment of the present application, obtains multiple training samples of the target fruit, then extracts features from the multiple training samples through a feature extraction model to obtain multiple groups of feature data, and then constructs multiple freshness indicators based on the multiple groups of feature data. Since each freshness indicator represents the relationship between the detection data of a target fruit individual and the freshness, the multiple freshness indicators are further constructed as an observation set to train the hidden Markov model, so that the hidden Markov model can learn the change law of the detection data of multiple target fruits as the freshness changes, and then The trained model is the freshness prediction model; the freshness prediction model can predict the freshness score of the target fruit based on the target fruit detection data input by the user, and then determine the remaining shelf life of the target fruit based on the freshness score; compared with the related art in which the remaining shelf life of the target fruit is determined only by experience, the embodiment of the present application uses a hidden Markov model to learn the law of changes in the component composition and sensory characteristics of the target fruit with the freshness, to obtain the freshness prediction model, and then the freshness prediction model can more accurately predict the freshness score of the target fruit, and then based on the freshness score, the remaining shelf life of the target fruit can be more accurately determined. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0058] Figure 1 A diagram of an application environment for a model training method and remaining shelf life prediction in one embodiment;

[0059] Figure 2 A schematic diagram of a flow chart of a model training method in one embodiment;

[0060] Figure 3 A schematic diagram of a process of initial GAN ​​network training steps in one embodiment;

[0061] Figure 4 A schematic diagram of the principle logic of initial GAN ​​network training in one embodiment;

[0062] Figure 5 A schematic diagram showing a comparison of the content of a certain component in an expanded sample and an initial sample in one embodiment;

[0063] Figure 6 A flowchart of the steps of feature extraction in one embodiment;

[0064] Figure 7 is a schematic diagram of the structure of a feature extraction model in an embodiment;

[0065] Figure 8 A schematic diagram of a step path for extracting a freshness index in an embodiment;

[0066] Fig. 9 A schematic diagram showing comparison of freshness indicators corresponding to a plurality of strawberries in one embodiment;

[0067] Fig.10 A logical schematic diagram of training a hidden Markov model in one embodiment;

[0068] Fig.11 A schematic diagram of a freshness state transition process of individual strawberries in one embodiment;

[0069] Fig.12 A flowchart of the steps of a method for predicting remaining shelf life in another embodiment;

[0070] Fig.13 is a structural block diagram of a model training device in one embodiment;

[0071] Fig.14 is a structural block diagram of a remaining shelf life prediction device in another embodiment;

[0072] Fig.15 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0074] The model training method and remaining shelf life prediction method provided in the embodiments of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The user can input the training sample through the terminal 102, and the terminal 102 uploads the training sample to the server 104 for processing and constructs the freshness index, and then the server 104 constructs an observation set based on the freshness index to train the hidden Markov model to obtain a freshness prediction model. At the same time, the user can also input the detection data of the target fruit through the terminal 102, and the terminal 102 sends the detection data input by the user to the server 104, and uses the freshness prediction model configured in the server 104 to process the detection data, predict the freshness score of the target fruit, and determine the remaining shelf life of the target fruit based on the freshness score. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable device may be a smart watch, a smart bracelet, a head-mounted device, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0075] In an exemplary embodiment, Figure 2 As shown, a model training method is provided, which is applied to Figure 1 The server 104 in the example is used as an example to illustrate, including steps 10 to 40, wherein:

[0076] Step 10: Acquire multiple training samples, each training sample includes multiple groups of test data of the same target fruit distributed along a time series, each group of test data corresponds to a freshness score, and the test data includes component composition and sensory characteristics.

[0077] The type of target fruit is not specifically limited in the embodiment of the present application. For the embodiment of the present application, the time series of the training sample includes multiple moments; wherein the time series of any two training samples may be the same or different, and this is not specifically limited in the embodiment of the present application. Furthermore, one training sample corresponds to an individual of the target fruit, wherein the individuals of the target fruit may be of the same variety or may not be of the same variety. In the embodiment of the present application, the data of all training samples are measured using the same variety of target fruit.

[0078] The component composition in the detection data includes the content of various nutrients in the target fruit, but the type of specific nutrients corresponding to each fruit is not specifically limited in the embodiments of the present application. In an exemplary embodiment, taking strawberry as the target fruit, the component composition may include the content of strawberry enzymes, total polyphenols, and flavonoids.

[0079] The sensory features include at least texture features and color features; specifically, the sensory features can be obtained by extracting the image of the target fruit through a preset image feature extraction model. An example of the process of obtaining a training sample: select multiple moments in the future to construct a time series; for the same target fruit individual, at any moment, collect the tissue of the target fruit individual for measurement, obtain the component composition at any moment, and obtain the real-time image of the target fruit at the same time, and extract the sensory features through the image feature extraction model; use the component composition and sensory features obtained at any moment as the detection data at any moment; and at each moment, determine the freshness score of a target fruit, which can be obtained by obtaining the freshness scores of multiple people for the target fruit and then arithmetically averaging them. Obtain the detection data of each moment in sequence according to the time series, and determine the freshness score corresponding to each moment to obtain a training sample of the target fruit.

[0080] Step 20: Input multiple training samples into a feature extraction model to obtain multiple groups of feature data, where the feature data includes fresh feature data and corruption feature data.

[0081] For the embodiment of the present application, a training sample is processed by the feature extraction model to obtain a set of feature data, and the set of feature data includes a set of fresh feature data and a set of corruption feature data. The fresh feature data is the change law of the component composition and the change law of the sensory characteristics corresponding to the target fruit in the relatively fresh stage; the corruption feature data is the change law of the component composition and the change law of the sensory characteristics corresponding to the target fruit in the corruption stage. The detection data in the training sample corresponds to the time series. As time changes, the target fruit will gradually change from fresh to corrupt. In this process, the sensory characteristics and component composition of the target fruit will change accordingly. For example, taking the target fruit as strawberry as an example, as time changes, the content of polyphenols and flavonoids in strawberries gradually decreases, which is the change law of the component composition of strawberries; similarly, as time changes, the color of strawberries changes from brighter colors to darker colors, accompanied by an increase in spots, which is the change law of the sensory characteristics of strawberries.

[0082] Step 30: construct multiple groups of freshness indicators based on the multiple groups of feature data.

[0083] For each training sample, a set of fresh feature data and corruption feature data corresponding to the training sample is used to construct a freshness index that describes the relationship between the detection data of the target fruit and the freshness. The freshness index is constructed based on the fresh feature data and corruption feature data of a training sample, and only the freshness of the target fruit individual corresponding to the training sample is described; for example, the detection data of individual A of the target fruit is measured at multiple times, and a training sample A is constructed for individual A. Training sample A is passed through a feature extraction model to obtain feature data, and then a freshness index is constructed based on the fresh feature data and corruption feature data in the feature data. The freshness index describes the relationship between the component composition and sensory characteristics of individual A of the target fruit and the freshness, wherein the freshness corresponds to the freshness score in the training sample.

[0084] Step 40: construct an observation set from multiple groups of freshness indicators, establish a hidden Markov model based on the observation set for training, and use the model obtained after training as a freshness prediction model;

[0085] The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit. The target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

[0086] For the embodiment of the present application, since a group of freshness indicators constructed based on the feature data of a training sample can only express the individual freshness indicators of the target fruit corresponding to the training sample, it is not representative. Therefore, in the embodiment of the present application, multiple groups of freshness indicators corresponding to multiple training samples are constructed into an observation set, and the hidden Markov model is trained through the observation set, so that the hidden Markov model is learned under the freshness indicators corresponding to multiple target fruit individuals, and then a freshness prediction model that can be used to predict the freshness of the target fruit is obtained. The user processes the target detection information of a target fruit individual through a feature extraction model to obtain a target freshness feature sequence of the target fruit, and then inputs the target freshness feature sequence into the freshness prediction model, and the freshness score predicted for the target fruit individual output by the freshness model can be obtained, wherein the freshness score represents the freshness; the relationship between the freshness score and the remaining shelf life can be pre-set, and after the freshness score is determined, the remaining shelf life of the target fruit can be determined based on the freshness score.

[0087] As time changes, the component composition and sensory characteristics of the target fruit will also change accordingly; in the embodiment of the present application, by obtaining multiple training samples of the target fruit, and then extracting features from the multiple training samples through a feature extraction model to obtain multiple groups of feature data, and then constructing multiple freshness indicators based on the multiple groups of feature data, since each freshness indicator represents the relationship between the detection data of an individual target fruit and the freshness, the multiple freshness indicators are further constructed as an observation set to train the hidden Markov model, so that the hidden Markov model can learn the change law of the detection data of multiple individual target fruits with the freshness, and then the trained model is the freshness prediction model; the freshness prediction model can predict the freshness score of the target fruit based on the target fruit detection data input by the user, and then determine the remaining shelf life of the target fruit based on the freshness score; compared with the related art that only determines the remaining shelf life of the target fruit through experience, in the embodiment of the present application, the component composition and sensory characteristics of the target fruit change with the freshness are learned through the hidden Markov model to obtain the freshness prediction model, and then the freshness prediction model can more accurately predict the freshness score of the target fruit, and then the remaining shelf life of the target fruit can be more accurately determined based on the freshness score.

[0088] Furthermore, for an individual target fruit, the detection data corresponding to the individual at multiple moments is collected to construct a training sample; and since the characteristic data obtained through the training sample is used to construct a freshness index that characterizes the change law of the detection data of the target fruit individual with the freshness, the longer the time series corresponding to the training sample, that is, the more moments it contains, the more the constructed freshness index conforms to the actual change of the target fruit individual, and thus the trained freshness prediction model is more accurate. For this reason, more data collection work is required in the stage of obtaining training samples, and the cycle will also be longer.

[0089] In order to reduce the difficulty of obtaining training samples, the target GAN (Generative Adversarial Networks) network is introduced in this application to expand the training samples, so that the number of training samples finally obtained can meet the training requirements. Specifically, in step 10, a target training set including multiple training samples is obtained, which can specifically include obtaining multiple initial samples, training the initial GAN ​​network using the multiple initial samples to obtain the target GAN network; then processing the multiple initial samples based on the target GAN network to generate multiple expanded samples; and constructing a target training set based on the multiple expanded samples and the multiple initial samples.

[0090] Among them, refer to Figure 3, using multiple initial samples to train the initial GAN ​​network to obtain the target GAN network, which may specifically include steps 11 to 14, wherein:

[0091] Step 11, determining a first loss based on the expectation and the authenticity score between the initial sample and the initial sample sampling determined by the discriminator;

[0092] Step 12: Determine a second loss based on the expectation and the authenticity score between the generated data and the initial sample determined by the discriminator, where the generated data is the data generated by the generator from the initial sample;

[0093] Step 13: construct a first loss function based on the first loss and the second loss, use the second loss as the second loss function, use the first loss function as the loss function of the discriminator, and use the second loss function as the loss function of the generator;

[0094] Step 14: Based on the first loss function and the second loss function, the initial GAN ​​network is trained to obtain a target GAN network.

[0095] Specifically, the obtained initial samples are used as training samples of the initial GAN ​​network, and the initial GAN ​​network includes a generator and a discriminator; wherein the training samples are input into the generator as real data, and the generator generates corresponding generated data based on the real data, and the discriminator is used to judge the generated data generated by the generator to determine whether the generated data is close to the real data. In the embodiment of the present application, since the training samples are detection data with time series, in order to better learn and generate time series data, the LSTM (Long Short-Term Memory) network is used as the generator in the embodiment of the present application.

[0096] The training logic for the initial GAN ​​network is: Assume that the random noise generated by the generator is distributed as , in the multi-layer network of the generator, this noise distribution is mapped into a new distribution ; The real data (training samples) The new distribution mapped by the generator Substitute into the discriminator and convert the real data (training samples) The label of is set to 0, and the label of the data generated by the generator is 1. Input the discriminator, the discriminator will input the data and real data (training samples) Make a judgment and output a authenticity score, which is a percentage, indicating the data input to the generator is the real data (training sample) probability.

[0097] Reference Figure 4 As shown in the figure, the training logic of the initial GAN ​​network is as follows: first, a training sample is used as real data, and the training sample is input into the discriminator as fake data. The discriminator determines the authenticity score of the fake data relative to the real data. Since both the real data and the fake data are training samples at this time, the authenticity score output by the discriminator should indicate that the fake data and the real data are the same; the discriminator is trained with multiple training samples to improve the recognition accuracy of the discriminator for real data; the discriminator is trained with each training sample in turn, so that the recognition accuracy of the discriminator for real data reaches the set value.

[0098] Furthermore, each training sample is input into the generator in turn, and the generator adds noise to the training sample to obtain each generated data; each generated data is input into the discriminator in turn, and the discriminator outputs the authenticity score of each generated data, which is equivalent to the corresponding real data (training sample). The generator adjusts the parameters that need to be adjusted according to the discriminator and regenerates the data (noise distribution), and the cycle continues until the discriminator cannot identify whether the input data is a real sample or generated data generated by the generator. The initial GAN ​​model training can be considered completed.

[0099] The above content is the logical steps for training the initial GAN ​​network.

[0100] Specifically, the first loss is: ; The second loss is:

[0101] .

[0102] Loss function of the discriminator for:

[0103] .

[0104] The loss function of the generator for:

[0105] .

[0106] in, yes In real data distribution Medium sampling, It is noise In real data The sampling in a differentiable function representing a generator, represents the differentiable function of the discriminator, is the expected value of the objective function; For real data, Based on real samples Generated data, The authenticity score of the data generated by the generator after passing through the discriminator. The authenticity score represents the generated data With real data the degree of proximity; To make real data The real data obtained by inputting the discriminator With real data The score of authenticity between , represents the discriminator's ability to identify real data. Specifically, the expectation is set between 0.5-0.51, based on the loss function and The initial GAN ​​network is configured, and the initial samples are used as training samples of the initial GAN ​​network. Combined with the above training process of the initial GAN ​​network, training is performed to obtain the target GAN network.

[0107] In the embodiment of the present application, strawberry is used as an example of target fruit, and the training sample is obtained by detecting strawberry. In the composition of strawberry, the content of each component changes with the change of time series. The content of each component changes with the change of time series in a two-dimensional coordinate system, and the image of the content of each component of strawberry changes with time series is obtained. Figure 5 As shown, it is a comparison chart of the change of PPO (Polyphenoloxidase) content along the time series in an initial sample of strawberry and an expanded sample obtained through the target GAN network; it can be determined that the deviation between the expanded sample and the initial sample is small, that is, the expanded sample can be used as real data to determine the freshness index of strawberries.

[0108] Further, refer to Figure 6 In step 20, multiple training samples are input into a feature extraction model to obtain multiple sets of feature data, the feature data including fresh feature data and corruption feature data, which may specifically include steps 21 and 22, wherein:

[0109] Step 21: for each training sample, divide the training sample in the time series according to a preset ratio to obtain subdivided samples corresponding to the training sample, where the subdivided samples include fresh samples and corrupt samples;

[0110] Step 22: Input the subdivided samples corresponding to the multiple training samples into the DBN model for feature extraction to obtain multiple groups of feature data.

[0111] Specifically, there are multiple samples in the target training set, including initial samples and expanded samples; wherein each group of samples is input into the feature extraction model to obtain a group of feature data, that is, the feature data is one-to-one corresponding to the training samples. Specifically, a group of sequential training samples is subdivided to obtain corrupt samples and fresh samples; wherein there are two ways of subdividing. The first way is to divide according to the time series. Since the corruption process of the target fruit gradually changes from a fresh state to a corrupt state, each training sample is divided according to the time series, and the first N percent of the data in the time series is used as a fresh sample of a training sample, and the last N percent of the data in the time series is used as a corrupt sample. Among them, N can be set by the user, and in the embodiment of the present application, N can be set to 75. For different types of fruits, the value of N is also different. In practice, a specific selection can be made based on the corruption rate of the target fruit, and this is not specifically limited in the embodiment of the present application.

[0112] In the training sample, each moment in the time series corresponds to a set of detection data, and each set of detection data corresponds to a freshness score, which characterizes the freshness of the target fruit. Therefore, the second method is to divide based on the freshness score, that is, to determine a target freshness score as the dividing line between freshness and corruption. The numerical detection data greater than the target freshness score is used as a fresh sample, and the detection data less than or equal to the target freshness score is used as a corruption sample. The specific numerical value of the target freshness score is not specifically limited in the embodiments of the present application.

[0113] Specifically, in the embodiment of the present application, the feature extraction model used is a DBN (Deep Belief Networks) network. In the embodiment of the present application, Figure 7 As shown, the feature extraction model includes two cascaded RBM (Restricted Boltzmann Machine) network layers, namely, RBM1 network layer and RBM2 network layer, and an AE (Auto Encode) network layer. By subdividing each training sample, a subdivided sample corresponding to each training sample is obtained, and then the DBN model is trained based on the subdivided sample of each training sample to obtain a feature extraction model. Then, the feature extraction model is used to extract features from the subdivided sample of each training sample to obtain feature data.

[0114] Specifically, in the embodiment of the present application, the structure of the BDN network is first described and then the training process is described: the RMB1 network layer of the DBN model is used to receive input data; wherein, the extracted data of the RBM1 network layer is the input data of the RBM2 network layer, and the input original data is feature extracted and converted step by step in the RBM1 network layer and the RBM2 network layer; in this way, the DBN model can gradually learn the deep features of the input data. In the embodiment of the present application, unsupervised training is performed on the DBN model, and thus the AE network layer is selected to implement unsupervised feature extraction, so as to adjust the weights of the entire network. In the embodiment of the present application, the RBM1 network layer has 30 nodes and the RBM2 network layer has 8 nodes.

[0115] The AE network layer consists of two parts: an encoder and a decoder. The encoder receives the output data of the RBM2 network layer and compresses it into a low-dimensional feature vector. This process is to extract features from the output data of the RBM2 network layer. The hidden layer of the encoder compresses the output data of the RBM2 network layer, which contains important features in the output data of the RBM2 network layer. Through training, the encoder can learn the potential representation of the output data of the RBM2 network layer. The decoder decompresses the low-dimensional feature vector obtained by the encoder into the same dimension as the output data of the RBM2 network layer, thereby reconstructing the data. The goal of the decoder is to restore the output data of the RBM2 network layer as much as possible, so as to minimize the difference between the reconstructed data and the output data of the RBM2 network layer. Through training, the decoder can learn how to restore the original information of the data from the low-dimensional feature vector.

[0116] The training of DBN model includes two processes, pre-training stage and reverse fine-tuning stage. The pre-training stage is forward greedy learning. Each node processes and calculates the input samples to determine whether to continue inputting data. The initial coefficient multiplied by the input data is randomly generated. Each node in the visible layer needs to process one of the low-level data features in the input sample. In the hidden layer, the output of the visible layer is multiplied by the weight and the bias is added. The result is input to the activation function to obtain the output of the node. The reverse fine-tuning stage is also the reconstruction stage. The activation value of the first hidden layer is used as the input in the reverse transfer and is also multiplied by the weight. The sum of these products is then added to the bias of each visible layer. Through the above process, RBM realizes the conversion of input data to the hidden layer and extracts features layer by layer. During the training process, the model parameters such as the weight and bias of RBM are adjusted to gradually obtain the optimal parameters, so that the probability distribution of RBM under the optimal parameters is as consistent as possible with the distribution of the input data. Finding the optimal parameters of the model is achieved by maximizing the likelihood function, which is expressed as: ,in: is the weight parameter of the RBM network layer; visible layer neurons , hidden layer neurons , is the visible layer bias, is the hidden layer bias, is the connection weight between the visible layer and the hidden layer.

[0117] For ease of calculation, the maximum likelihood function is Can be maximized The expression is: , is the number of neurons in the visible layer, , Characterization Visible neurons.

[0118] Furthermore, the activation probability of a neuron is:

[0119] ; . Further, in an embodiment of the present application, the RBM network layer is trained by a contrastive divergence algorithm (CD), also known as the CD-K algorithm. The contrastive divergence algorithm is a sampling-based approximation method that estimates the gradient of the likelihood function by performing only a limited number of Gibbs sampling steps, and uses the difference between the data distribution and the model distribution to update the model parameters, thereby reducing the amount of calculation and speeding up the training process.

[0120] Specifically, during the training of the DBN model, each training sample is preprocessed, and then each preprocessed training sample is segmented to obtain the segmented samples of each training sample, and then the segmented samples of each training sample are input into the DBN model for unsupervised training. The segmented samples of each training sample are input into the RBM1 network layer, and the network weights are initialized by training the RBM1 network layer and the RBM2 network layer layer by layer. Each layer of RBM is trained by the CD-K algorithm so that the hidden layer can capture the effective features of the visible layer data. After completing the layer-by-layer training, the entire network (including RBM and the top AE) is fine-tuned by the back propagation algorithm to further optimize the network parameters. The trained DBN model can map the input data to the hidden layer and extract the deep features of the data. These features are abstract representations of the segmented samples of each training sample and can reflect the inherent structure and laws of the data.

[0121] After the DBN model is trained, a feature extraction model is obtained. The feature extraction model is used to process the segmented samples of each training sample to obtain feature data: fresh samples in the segmented samples of each training sample are input into the feature extraction model to obtain fresh feature data; corrupt samples in the segmented samples of each training sample are input into the feature extraction model to obtain corrupt feature data.

[0122] Further, in step 30, multiple groups of freshness indicators are constructed based on multiple groups of feature data, which may specifically include: for each group of feature data, determining the degree of deviation between the fresh feature data and the corruption feature data, and using the degree of deviation as the freshness indicator of the target fruit.

[0123] Specifically, the deviation between the fresh data feature and the corrupt data feature is calculated, that is, the Euclidean distance between the two is calculated to characterize the deviation. The specific calculation formula is: ;in, It is the fresh data feature; Characterizes corruption data; for Sequence length.

[0124] In summary, in step 20 and step 30, the process of obtaining a sample freshness index is as follows: Figure 8 shown in Figure 8 In the example, the target fruit is strawberry. The components in the training samples include PPO (Polyphenol Oxidase), APX (Ascorbate Peroxidase), SOD (Superoxide Dismutase), POD (Peroxidase), CAD (Cinnamyl Alcohol Dehydrogenase), polyphenols and flavonoids. After preprocessing operations such as deduplication, noise reduction, and normalization, the training samples are input into the DBN model for feature extraction to obtain fresh feature data and corruption feature data, and the freshness index is constructed based on the fresh feature data and corruption feature data.

[0125] Furthermore, taking strawberry as the target fruit example, the freshness index constructed is as follows: Fig. 9 As shown, Fig. 9Each line in represents a freshness index constructed based on the feature data corresponding to a training sample. Among them, 1 represents the initial freshness state of the strawberry, at which time the strawberry is the freshest, and 0 represents the loss of freshness of the strawberry fruit, that is, corruption and loss of edible value. The descent process from curve 1 to 0 represents the process of the decrease in the freshness of the strawberry. For strawberry samples picked at the same time, with the same freshness, and stored at room temperature, the corruption trends are roughly synchronized. As the storage time increases, the freshness gradually decreases. It can be seen from the figure that the samples reached the corruption node at the same time, which is consistent with the ideal state.

[0126] Furthermore, in order to verify the reliability of the freshness index constructed in the embodiment of the version application, the freshness index of strawberries constructed by the multiple linear regression model was used as a comparison, and the monotonicity and robustness were used to evaluate the advantages and disadvantages of the freshness index of strawberries constructed in this application and the freshness index of strawberries constructed by the multiple linear regression model. The comparison of the two evaluation indicators is shown in Table 1:

[0127] Table 1

[0128]

[0129] From the comparison of the results in Table 1, it can be seen that the monotonicity of the strawberry "freshness" index constructed based on the DBN model in the traditional multiple linear regression and this application is relatively small, but the robustness of the strawberry "freshness" index based on the multiple linear regression is far worse than that of the DBN model. On the whole, the strawberry freshness index constructed based on the DBN model in this application is smooth and has strong anti-disturbance, which can better describe the change process of strawberries from fresh to corrupt during the shelf life.

[0130] Further, in step 40, multiple groups of freshness indexes are constructed into observation sets, and a hidden Markov model (HMM model) is established based on the observation sets for training, and the model obtained after training is used as a freshness prediction model. Since the corruption process of the target fruit is a continuous process, if the continuous state is discretized, a lot of process information will be lost. Therefore, in the embodiment of the application, a Gaussian mixture distribution is used as the emission probability matrix, and the required probability density curve is approximated by a weighted combination of multivariate Gaussian components. At this time, the hidden Markov model becomes a hidden Markov model of a mixed Gaussian distribution. Modeling the continuous corruption process of the target fruit using the hidden Markov model of the mixed Gaussian distribution is closer to the actual state of the target fruit corruption, and the maximum information of the established freshness index of the target fruit is retained.

[0131] The process of constructing a hidden Markov model includes: defining the state space and observation space, defining the initial state distribution, defining the state transition probability, and defining the observation probability matrix; where:

[0132] Construct observation vector sequence: observation vector sequence is a observation vectors, each observation vector is a multidimensional vector. In the embodiment of the application, the observation vector is the freshness index of the target fruit, obtained by step 30. The observation sequence is . Set in time series The state space value set is , is the number of hidden states set. When , the observation space value set is , is the number of possible observed sequences.

[0133] Hidden state sequence It is a sequence that cannot be observed directly and can be inferred by observing the vector sequence. Indicated in The real state of the target fruit at a certain time point is related to the freshness of the target fruit. is the number of states that the target fruit will go through during its corruption process. The state space is the set of hidden states.

[0134] In the embodiment of the present application, the continuous spoilage process of the target fruit in the time series is divided into three stages, namely, shelf life level I, shelf life level II, and shelf life level III. Among them: shelf life level I represents that the target fruit is in the freshest state, and the freshness score is greater than or equal to 80 points. The freshness score of shelf life level II is greater than or equal to 60 points and less than 80 points; the freshness score of shelf life level III is less than 60 points. Shelf life level I, shelf life level II, and shelf life level III are the three hidden states of the hidden Markov model, represented by 0, 1, and 2 respectively.

[0135] The Gaussian mixture hidden Markov model contains the initial probability distribution matrix , state transition probability matrix , the mixture weight matrix of the mixed Gaussian distribution , the mean matrix of the Gaussian mixture , the covariance matrix of the Gaussian mixture The hidden Markov model of mixed Gaussian distribution can be expressed mathematically as follows: The state of the target fruit corresponding to the detection data at the first moment in the time series of each training sample is set to the freshest state, so the initial state distribution matrix is ​​set to .

[0136] Furthermore, the state transition probability matrix is:

[0137] ;

[0138] ; Characterization of target fruit The state of the moment, Characterization of target fruit The state of the moment, where It is a built-in function.

[0139] The mixing weight matrix of the mixed Gaussian distribution is:

[0140] ;in:

[0141] , Can be a set value. The mean matrix of mixed Gaussian is:

[0142] ;

[0143] The covariance matrix of the Gaussian mixture is:

[0144] .

[0145] In hidden state The observation vector under The observation probability matrix is ​​given by the probability density function The mathematical expression is:

[0146] ;

[0147] in, is the observation vector The probability density function of ; the constraints are: .

[0148] Furthermore, the remaining shelf life calculation formula is used to calculate the remaining shelf life of the target fruit. The remaining shelf life calculation formula is: ;in, is the remaining shelf life, It is in The expectation of staying for a while, It is The self-transition probability of a state, is the state probability of recognition, is the number of hidden states of the hidden Markov model. In the embodiment of the present application, It can be set to 3. For different target fruits, the number of hidden states and the corresponding divisions may be different, which is not specifically limited in the embodiments of the present application.

[0149] Assume that all target fruits are initially in the shelf life of grade I and gradually decay to the shelf life of grade III over time. The freshness index determined in step 30 is introduced into the constructed hidden Markov model, the model is trained, and finally a freshness prediction model is obtained.

[0150] Further, in step 40, the process of establishing a hidden Markov model for training is as follows: Fig.10 As shown, where:

[0151] The freshness index of each training sample determined in step 30 is used to construct an observation set, that is, to construct an observation vector sequence, and then three shelf life states are defined as the change process from fresh to corrupted of the target fruit, and the Gaussian distribution is used to construct the mixed weight matrix of the mixed Gaussian distribution, the mean matrix of the mixed Gaussian and the covariance matrix of the mixed Gaussian, and then a hidden Markov model (HMM model) is constructed. The HMM model is trained, and the parameters in the HMM training process are iterated by the Baum-Welch algorithm. Further, the likelihood function of the HMM in the training process is solved by the Viterbi algorithm; when the hidden sequence of the current training stage is determined to be the optimal solution, the HMM model training is determined to be completed, and the trained HMM model is the freshness prediction model.

[0152] Furthermore, in the embodiment of the present application, strawberry is used as an example of a target fruit, and a freshness prediction model for strawberries is obtained by training the detection data of strawberries. The freshness index sequence of the same strawberry in different states is input into the strawberry freshness prediction model, and the obtained results are as follows: Fig.11 As shown, the stage transition process of strawberries from the fresh state to the corrupt state can be intuitively reflected.

[0153] In an exemplary embodiment, Fig.12 As shown, a remaining shelf life prediction method is provided, which is applied to Figure 1 The server 104 in the example is used as an example to illustrate, including steps 100 to 400, wherein:

[0154] Step 100: Obtain target detection information of the target fruit, where the detection information includes at least one of component composition and sensory characteristics.

[0155] For the embodiment of the present application, for different target fruits, the corresponding detection information is different, which is not specifically limited in the embodiment of the present application. Taking strawberry as an example, the component information in the target detection information of strawberry at least includes the content of components such as strawberry enzymes, total polyphenols and flavonoids.

[0156] Step 200: extract target detection information using a feature extraction model to obtain a target freshness feature sequence.

[0157] For the embodiment of the present application, the feature extraction model is the feature extraction model trained in step 20 in the above-mentioned model training method embodiment. For the specific linearity of the feature extraction model, reference may be made to step 20 in the above-mentioned model training method embodiment.

[0158] Step 300: Process the target freshness feature sequence using the freshness prediction model to obtain the freshness score of the target fruit;

[0159] Step 400, determining the remaining shelf life of the target fruit based on the freshness score; the freshness prediction model is obtained by training the hidden Markov model based on the observation set; wherein the observation set is constructed based on multiple groups of freshness indicators, the multiple groups of freshness indicators are constructed based on multiple groups of feature data, the feature data include fresh feature data and corruption feature data, the multiple groups of feature data are extracted from multiple training samples based on the feature extraction model, each training sample includes multiple groups of detection data of the same target fruit distributed along the time series, each group of detection data corresponds to a freshness score, and the detection data includes component composition and sensory characteristics.

[0160] In the embodiment of the present application, the target detection data of the target fruit is feature extracted by the feature model to obtain a set of freshness indicators, and the freshness indicators are input into the freshness prediction to obtain the freshness score of the target fruit, wherein the freshness score represents the freshness of the target fruit. Further, the freshness score is based on the preset formula to obtain the current remaining shelf life of the target fruit based on the freshness score. Among them, the specific definition of the freshness prediction model can refer to the training content of the freshness prediction model in step 40 in the above-mentioned model training method embodiment.

[0161] In an embodiment of the present application, multiple training samples of the target fruit are obtained, and then feature extraction is performed on the multiple training samples through a feature extraction model to obtain multiple groups of feature data, and then multiple freshness indicators are constructed based on the multiple groups of feature data. Since each freshness indicator represents the relationship between the detection data of an individual target fruit and the freshness, the multiple freshness indicators are further constructed as an observation set to train the hidden Markov model, so that the hidden Markov model can learn the change law of the detection data of multiple individual target fruits with the freshness, and then the trained model is the freshness prediction model; the freshness prediction model can predict the freshness score of the target fruit based on the target fruit detection data input by the user, and then determine the remaining shelf life of the target fruit based on the freshness score; compared with the related art that determines the remaining shelf life of the target fruit only by experience, in the embodiment of the present application, the component composition and sensory characteristics of the target fruit are learned by the hidden Markov model to change with the freshness, and the freshness prediction model can be used to more accurately predict the freshness score of the target fruit, and then the remaining shelf life of the target fruit can be more accurately determined based on the freshness score.

[0162] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0163] Based on the same inventive concept, the embodiment of the present application also provides a model training device for implementing the model training method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more model training device embodiments provided below can refer to the limitations on the model training method above, and will not be repeated here.

[0164] In an exemplary embodiment, Fig.13 As shown, a model training device is provided, including a training sample acquisition module 1301, a feature extraction module 1302, a freshness index construction module 1303 and a training module 1304, wherein:

[0165] The training sample acquisition module 1301 is used to acquire a target training set including multiple training samples, each training sample including multiple groups of test data distributed along a time series for the same target fruit, each group of test data corresponding to a freshness score, and the test data including component composition and sensory characteristics;

[0166] A feature extraction module 1302 is used to input a plurality of training samples into a feature extraction model to obtain a plurality of sets of feature data, wherein the feature data includes fresh feature data and corruption feature data;

[0167] A freshness index construction module 1303 is used to construct multiple groups of freshness indexes based on multiple groups of feature data;

[0168] A training module 1304 is used to construct an observation set from multiple groups of freshness indicators, and to establish a hidden Markov model based on the observation set for training, and to use the model obtained after training as a freshness prediction model;

[0169] The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit. The target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

[0170] In an embodiment of the present application, multiple training samples of the target fruit are obtained, and then feature extraction is performed on the multiple training samples through a feature extraction model to obtain multiple groups of feature data, and then multiple freshness indicators are constructed based on the multiple groups of feature data. Since each freshness indicator represents the relationship between the detection data of an individual target fruit and the freshness, the multiple freshness indicators are further constructed as an observation set to train the hidden Markov model, so that the hidden Markov model can learn the change law of the detection data of multiple individual target fruits with the freshness, and then the trained model is the freshness prediction model; the freshness prediction model can predict the freshness score of the target fruit based on the target fruit detection data input by the user, and then determine the remaining shelf life of the target fruit based on the freshness score; compared with the related art that determines the remaining shelf life of the target fruit only by experience, in the embodiment of the present application, the component composition and sensory characteristics of the target fruit are learned by the hidden Markov model to change with the freshness, and the freshness prediction model can be used to more accurately predict the freshness score of the target fruit, and then the remaining shelf life of the target fruit can be more accurately determined based on the freshness score.

[0171] In one embodiment, the feature extraction module 1302 is specifically used to:

[0172] For each training sample, the training sample is divided in the time series according to a preset ratio to obtain the subdivided samples corresponding to the training sample, and the subdivided samples include fresh samples and corrupt samples;

[0173] The segmented samples corresponding to the multiple training samples are input into the DBN model for feature extraction to obtain multiple groups of feature data.

[0174] In one embodiment, the freshness index construction module 1303 is specifically used to:

[0175] For each set of characteristic data, the degree of deviation between the fresh characteristic data and the corruption characteristic data is determined, and the degree of deviation is used as the freshness index of the target fruit.

[0176] In one embodiment, the training sample acquisition module 1301 is further used to:

[0177] Acquire multiple initial samples, each of which includes multiple groups of test data of the same target fruit distributed along a time series, each group of test data corresponds to a freshness score, and the test data includes component composition and sensory characteristics;

[0178] Process multiple initial samples based on the target GAN network to generate multiple expanded samples;

[0179] A target training set is constructed based on multiple augmented samples and multiple initial samples.

[0180] In one embodiment, the training sample acquisition module 1301 is further used to:

[0181] Determining a first loss based on the expectation and the authenticity score between the initial sample and the initial sample sampling determined by the discriminator;

[0182] Determine a second loss based on the expectation and the authenticity score between the generated data and the initial sample determined by the discriminator, where the generated data is data generated by the generator from the initial sample;

[0183] Construct a first loss function based on the first loss and the second loss, use the second loss as the second loss function, use the first loss function as the loss function of the discriminator, and use the second loss function as the loss function of the generator;

[0184] Based on the first loss function and the second loss function, the initial GAN ​​network is trained to obtain the target GAN network.

[0185] In an exemplary embodiment, Fig.14As shown, a remaining shelf life prediction device is provided, which includes a target detection information acquisition module 1401, an extraction module 1402, a freshness score determination module 1403 and a remaining shelf life prediction module 1404, wherein:

[0186] The target detection information acquisition module 1401 is used to obtain target detection information of the target fruit, where the detection information includes at least one of component composition and sensory characteristics;

[0187] Extraction module 1402, used to extract target detection information using a feature extraction model to obtain a target freshness feature sequence;

[0188] Freshness score determination module 1403, used to process the target freshness feature sequence using the freshness prediction model to obtain the freshness score of the target fruit;

[0189] The remaining shelf life prediction module 1404 is used to determine the remaining shelf life of the target fruit based on the freshness score;

[0190] The freshness prediction model is obtained by training the hidden Markov model based on the observation set;

[0191] Among them, the observation set is constructed based on multiple groups of freshness indicators, and the multiple groups of freshness indicators are constructed based on multiple groups of feature data. The feature data include fresh feature data and corruption feature data. The multiple groups of feature data are extracted from multiple training samples based on the feature extraction model. Each training sample includes multiple groups of detection data distributed along the time series of the same target fruit. Each group of detection data corresponds to a freshness score. The detection data includes component composition and sensory characteristics.

[0192] Each module in the above-mentioned model training device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0193] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig.15As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device.

[0194] The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a model training method or a remaining shelf life prediction method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0195] Those skilled in the art will understand that Fig.15 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0196] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps in the above-mentioned model training method embodiment or the above-mentioned remaining shelf life prediction method embodiment are implemented.

[0197] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned model training method embodiment or the above-mentioned remaining shelf life prediction method embodiment are implemented.

[0198] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the steps in the above-mentioned model training method embodiment or the above-mentioned remaining shelf life prediction method embodiment.

[0199] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0200] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0201] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0202] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A model training method, characterized in that: The method comprises: Obtaining a target training set including a plurality of training samples, each of the training samples including a plurality of groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponding to a freshness score, and the detection data including component composition and sensory characteristics; Input the plurality of training samples into a feature extraction model to obtain a plurality of sets of feature data, wherein the feature data include fresh feature data and spoilage feature data; the fresh feature data are the change rules of component composition and sensory characteristics corresponding to the target fruit in the fresh stage; the spoilage feature data are the change rules of component composition and sensory characteristics corresponding to the target fruit in the spoilage stage; For each set of the characteristic data, determining the degree of deviation between the fresh characteristic data and the corruption characteristic data, and using the degree of deviation as a freshness index of the target fruit; Constructing an observation set from multiple groups of freshness indicators, and establishing a hidden Markov model based on the observation set for training, and using the model obtained after training as a freshness prediction model; The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit, and the target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

2. The method according to claim 1, characterized in that: The feature extraction model is a DBN model, and the plurality of training samples are input into the feature extraction model to obtain a plurality of sets of feature data, including: For each of the training samples, the training sample is divided in a time series according to a preset ratio to obtain subdivided samples corresponding to the training sample, wherein the subdivided samples include fresh samples and corrupt samples; The subdivided samples corresponding to each of the multiple training samples are input into the DBN model for feature extraction to obtain multiple groups of feature data.

3. The method according to claim 1, characterized in that The degree of deviation is the Euclidean distance between the fresh feature data and the corruption feature data.

4. The method according to any one of claims 1 or 2, characterized in that: The method further comprises: Acquire multiple initial samples, each of which includes multiple groups of test data of the same target fruit distributed along a time series, each group of test data corresponds to a freshness score, and the test data includes component composition and sensory characteristics; Processing the multiple initial samples based on the target GAN network to generate multiple expanded samples; A target training set is constructed based on the multiple expanded samples and the multiple initial samples.

5. The method according to claim 4, characterized in that The initial GAN ​​network includes a generator and a discriminator. The training process of the target GAN network includes: Determine a first loss based on the expectation and a first score, where the first score is determined by a discriminator, and the first score is a authenticity score between the initial sample and the initial sample; Determine a second loss based on the expectation and a second score, where the second score is determined by the discriminator, the second score is a authenticity score between the generated data and the initial sample, and the generated data is data generated by the generator from the initial sample; Constructing a first loss function based on the first loss and the second loss, using the second loss as the second loss function, using the first loss function as the loss function of the discriminator, and using the second loss function as the loss function of the generator; Based on the first loss function and the second loss function, the initial GAN ​​network is trained to obtain a target GAN network.

6. A method for predicting remaining shelf life, characterized in that: The method comprises: Acquiring target detection information of target fruit, wherein the detection information includes component composition and sensory characteristics; Extracting the target detection information using a feature extraction model to obtain a target freshness feature sequence; Processing the target freshness feature sequence using a freshness prediction model to obtain a freshness score for the target fruit; Determining a remaining shelf life of the target fruit based on the freshness score; The freshness prediction model is obtained by training a hidden Markov model based on an observation set; The observation set is constructed based on multiple groups of freshness indicators, which are constructed based on multiple groups of feature data, including fresh feature data and corruption feature data, which are extracted from multiple training samples based on a feature extraction model, and each training sample includes multiple groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponds to a freshness score, and the detection data includes component composition and sensory characteristics; Among them, for each group of the characteristic data, the degree of deviation between the fresh characteristic data and the corruption characteristic data is used as the freshness index of the target fruit; the fresh characteristic data is the changing law of the component composition and the changing law of the sensory characteristics corresponding to the target fruit in the fresh stage; the corruption characteristic data is the changing law of the component composition and the changing law of the sensory characteristics corresponding to the target fruit in the corruption stage.

7. A model training device, characterized in that: The device comprises a training sample acquisition module, a feature extraction module, a freshness index construction module and a training module, wherein: A training sample acquisition module is used to acquire a target training set including a plurality of training samples, each of which includes a plurality of groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponds to a freshness score, and the detection data includes component composition and sensory characteristics; A feature extraction module is used to input the plurality of training samples into a feature extraction model to obtain a plurality of sets of feature data, wherein the feature data include fresh feature data and corruption feature data; the fresh feature data are the change rules of component composition and sensory characteristics corresponding to the target fruit in the fresh stage; the corruption feature data are the change rules of component composition and sensory characteristics corresponding to the target fruit in the corruption stage; A freshness index building module, used for determining the degree of deviation between the freshness characteristic data and the corruption characteristic data for each set of the characteristic data, and using the degree of deviation as the freshness index of the target fruit; A training module, used to construct an observation set from multiple groups of freshness indicators, and to establish a hidden Markov model based on the observation set for training, and to use the model obtained after training as a freshness prediction model; The freshness prediction model is used to predict the freshness score of the target fruit based on the input target freshness index sequence of the target fruit, and the target freshness index sequence is obtained by processing the target detection data through the feature extraction model; the freshness score is used to determine the remaining shelf life of the target fruit.

8. A remaining shelf life prediction device, characterized in that: The device comprises a target detection information acquisition module, an extraction module, a freshness score determination module and a remaining shelf life prediction module, wherein: A target detection information acquisition module, used to acquire target detection information of target fruits, wherein the detection information includes component composition and sensory characteristics; An extraction module, used for extracting the target detection information using a feature extraction model to obtain a target freshness feature sequence; A freshness score determination module, used to process the target freshness feature sequence using a freshness prediction model to obtain a freshness score for the target fruit; A remaining shelf life prediction module, used for determining the remaining shelf life of the target fruit based on the freshness score; The freshness prediction model is obtained by training a hidden Markov model based on an observation set; The observation set is constructed based on multiple groups of freshness indicators, which are constructed based on multiple groups of feature data, including fresh feature data and corruption feature data, which are extracted from multiple training samples based on a feature extraction model, and each training sample includes multiple groups of detection data distributed along a time series for the same target fruit, each group of detection data corresponds to a freshness score, and the detection data includes component composition and sensory characteristics; Among them, for each group of the characteristic data, the degree of deviation between the fresh characteristic data and the corruption characteristic data is used as the freshness index of the target fruit; the fresh characteristic data is the changing law of the component composition and the changing law of the sensory characteristics corresponding to the target fruit in the fresh stage; the corruption characteristic data is the changing law of the component composition and the changing law of the sensory characteristics corresponding to the target fruit in the corruption stage.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Shelf life apple quality dynamic prediction system and prediction method

    CN110263969A

  • Crayfish freshness detection method based on gas phase electronic nose and machine learning

    CN113984946A