Dish making process anomaly identification method and device, electronic equipment and storage medium
Through an abnormal recognition model based on the attention mechanism and convolution kernels of various spatial window lengths, abnormal operations in the dish production process are automatically identified, which solves the problem of relying on manual monitoring in the existing technology and improves monitoring efficiency and accuracy.
Patent Information
- Application Number
- CN202311351560.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-18
- Publication Date
- 2024-10-18
AI Technical Summary
The existing technology lacks the means to automatically identify abnormal operations during the dish production process, relies heavily on manual monitoring, and has poor timeliness.
Using a description model based on the attention mechanism and an abnormality identification model with convolution kernels of various spatial window lengths, the characteristics of the dish production process are extracted from video data to achieve automatic identification of abnormal operations.
It realizes automatic identification of abnormal operations during the dish production process, improves monitoring efficiency and accuracy, and reduces manual intervention.
Smart Images

Figure CN118799773A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and specifically to a method, device, electronic device and storage medium for identifying abnormalities in a dish preparation process. Background Art
[0002] With the accelerated pace of life, takeout has become more and more a lifestyle choice for the people. In some areas, about 70% of the population directly or indirectly uses takeout as the main or supplementary way of dining consumption. Online dining is related to the healthy growth of a generation. In order to further strengthen the food safety supervision of online catering units and facilitate consumers and other social parties to participate in the supervision and management of food safety, it is necessary to accelerate the construction of online catering monitoring.
[0003] The existing methods of monitoring the cooking process of kitchen dishes are mostly to monitor the chef's cooking process, and the inspectors randomly select monitoring videos to manually determine whether the cooking process is compliant. This method is heavily dependent on manual labor and has poor timeliness.
[0004] There is currently no effective means in the prior art to realize automatic identification of abnormal operations in the food preparation process within the kitchen monitoring range. Summary of the invention
[0005] The embodiments of the present application provide a method, device, electronic device and storage medium for identifying abnormalities in a dish preparation process, so as to solve the technical problem of automatically identifying abnormal operations in a dish preparation process.
[0006] In a first aspect, an embodiment of the present application provides a method for identifying abnormalities in a dish preparation process, comprising:
[0007] Obtain video data of the dish preparation process;
[0008] Inputting the video data into a description model of a dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of a context vector of the video data based on an attention mechanism, and focuses on the context vector based on the weight to generate the description data;
[0009] The description data is input into an abnormality recognition model of a dish preparation process to obtain an abnormal result of the dish preparation process output by the abnormality recognition model; wherein the abnormality recognition model extracts features of the description data based on convolution kernels of a variety of spatial window lengths to obtain the abnormal result.
[0010] In one embodiment, the anomaly recognition model includes a plurality of convolution channels connected in parallel, each of the convolution channels includes a convolution layer, a dropout layer, a maximum pooling layer and a flattening layer;
[0011] The convolution layer extracts the features of the description data based on the convolution kernel and generates multiple feature values; wherein one of the convolution layers includes a convolution kernel of a spatial window length, and the convolution kernels in the convolution layer of each convolution channel have different spatial window lengths;
[0012] The discard layer is used to randomly disconnect neurons that input the feature value;
[0013] The maximum pooling layer is used to select the maximum eigenvalue;
[0014] The flattening layer is used to compress the dimension of the largest eigenvalue.
[0015] In one embodiment, the anomaly recognition model further includes a merging layer, a fully connected layer, and an output layer;
[0016] The merging layer is connected to the flattening layer and is used to concatenate the compressed maximum eigenvalues to generate a eigenvector;
[0017] The fully connected layer is used to integrate and transform the feature vector to obtain an initial prediction result;
[0018] The output layer is used to classify the initial prediction results and output the abnormal results.
[0019] In one embodiment, the description model includes an encoder and a long short-term memory (LSTM) decoder;
[0020] The encoder is connected to the image feature extractor and is used to encode the image data output by the image feature extractor into at least one context vector of fixed length;
[0021] The LSTM decoder is used to determine the weight of each of the context vectors, and multiply the context vector by its weight to obtain a context vector associated with the description data, and generate the description data based on the associated context vector.
[0022] In one embodiment, the description model further includes an image feature extractor;
[0023] The image feature extractor is used to extract multiple frames of image data from the video data, standardize the size and pixels of the image data, and input the standardized image data into an encoder.
[0024] In one embodiment, the description model is obtained based on the following steps:
[0025] Generate sample image data based on sample video data of the dish making process;
[0026] Performing text cleaning and text serialization on the image description set corresponding to the sample image data to obtain a sample text sequence, and marking the description data of the dish preparation process in the sample text sequence;
[0027] According to a preset ratio, the labeled sample text sequence is divided into a first training set and a first test set;
[0028] Setting the number of training rounds and the data batch processing amount of the first preset model, and training the first preset model to obtain an initial description model based on the first training set, the number of training rounds and the data batch processing amount of the first preset model;
[0029] Based on the first test set, the initial description model is tested to obtain a description model.
[0030] In one embodiment, the anomaly recognition model is obtained based on the following steps:
[0031] Marking abnormal results of the dish preparation process in the sample description data output by the description model;
[0032] Performing text cleaning and text serialization on the labeled sample description data;
[0033] According to a preset ratio, the serialized sample description number is divided into a second training set and a second test set;
[0034] Setting the number of training rounds and the data batch processing amount of the second preset model, and training the second preset model based on the second training set, the number of training rounds and the data batch processing amount of the second preset model to obtain an initial anomaly recognition model;
[0035] Based on the second test set, the initial anomaly recognition model is tested to obtain an anomaly recognition model.
[0036] In a second aspect, an embodiment of the present application provides a device for identifying abnormalities in a dish preparation process, comprising:
[0037] An acquisition module is used to acquire video data of the dish making process;
[0038] A description module, used for inputting the video data into a description model of a dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of the context vector of the video data based on an attention mechanism, and focuses on the context vector based on the weight to generate the description data;
[0039] The recognition module is used to input the description data into an abnormal recognition model of the dish preparation process to obtain an abnormal result of the dish preparation process output by the abnormal recognition model; wherein the abnormal recognition model extracts the features of the description data based on convolution kernels of multiple spatial window lengths to obtain the abnormal result.
[0040] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, wherein when the processor executes the program, the steps of the method for identifying abnormalities in the dish preparation process described in the first aspect are implemented.
[0041] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for identifying abnormalities in the dish preparation process described in the first aspect.
[0042] The dish preparation process anomaly recognition method, device, electronic device and storage medium provided in the embodiment of the present application are as follows: acquiring video data of the dish preparation process; inputting the video data into the description model of the dish preparation process to obtain the description data of the dish preparation process output by the description model; wherein the description model determines the weight of the context vector of the video data based on the attention mechanism, and focuses the context vector based on the weight to generate the description data; inputting the description data into the anomaly recognition model of the dish preparation process to obtain the abnormal result of the dish preparation process output by the anomaly recognition model; wherein the anomaly recognition model extracts the features of the description data based on convolution kernels with multiple spatial window lengths to obtain the abnormal result. The embodiment of the present application generates description data by focusing the context vector according to the weight; extracting features of the description data to different degrees by convolution kernels with different spatial window lengths to obtain abnormal results, thereby realizing automatic recognition of abnormal results in the dish preparation process. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 It is a flowchart of a method for identifying abnormalities in a dish preparation process provided by an embodiment of the present application;
[0045] Figure 2 It is a flowchart of weight allocation of the LSTM decoder provided in an embodiment of the present application;
[0046] Figure 3 is a schematic diagram of the structure of the description model provided in the embodiment of the present application;
[0047] Figure 4 It is a structural diagram of an abnormality recognition model provided in an embodiment of the present application;
[0048] Figure 5 It is a structural schematic diagram of a device for identifying abnormalities in a dish preparation process provided by an embodiment of the present application;
[0049] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] Figure 1 Schematic diagram of the process of identifying abnormalities in the dish preparation process provided by the embodiment of the present application. Figure 1 The present application embodiment provides a method for identifying abnormalities in a dish preparation process, comprising:
[0052] S100, obtaining video data of a dish making process;
[0053] The video data is the video data of the kitchen of the merchant to be tested. The video data records the process of making dishes, including the process of making dishes, the operator's clothing, the operator's status, etc. According to the functional layout and area size of the kitchen of the merchant to be tested, a corresponding number of standard definition or above (including standard definition) video surveillance equipment is installed. The monitoring scope covers areas such as food rough processing, cooking, special rooms, and tableware washing and disinfection. The monitoring focus is on the sanitation conditions, item placement, cleaning and disinfection, etc. of the above areas, as well as whether the employees' clothing and processing and production behaviors comply with food safety regulations. According to the video surveillance equipment installed in the kitchen, video data of the dish making process is obtained.
[0054] S200, inputting the video data into a description model of the dish preparation process, and obtaining description data of the dish preparation process output by the description model; wherein the description model determines the weight of the context vector of the video data based on the attention mechanism, and focuses on the context vector based on the weight to generate the description data;
[0055] The description data includes multiple output steps, which characterize the operation process at different time steps (i) during the dish preparation process.
[0056] Before inputting the video data into the description model, the video data needs to be preprocessed to obtain image data.
[0057] The description model introduces an encoder and a decoder. The encoder generates context vectors and passes all context vectors to the decoder. Figure 2 As shown in the figure, in order to focus on the part of the context vector that is most relevant to the output step, the decoder assigns a weight to each context vector, multiplies each context vector by the weight after activation by its activation function (softmax), increases the importance of context vectors with higher weights, and reduces the importance of context vectors with lower weights. The weight allocation based on the attention mechanism is performed during the output process of each output step of the decoder. The weight allocation based on the attention mechanism allows the description model to focus on the context vector related to the output step as needed. The encoder assigns a weight to each context vector. If the context vector is more relevant to the current output step, the weight is closer to 1; if the context vector is less relevant to the current output step, the weight is closer to 0. The weight is recalculated during the generation of each output step. The weight calculation formula is:
[0058] attention i =softmax(Dense(x,y i-1 ));
[0059] Among them, attention i is the weight, softmax is the activation function of the encoder, x is the context vector, y i-1 is the output step of the i-1th time step.
[0060] The calculation formula of the context vector with weights is:
[0061]
[0062] Among them, c i is a context vector with weights, attention i is the weight, x i is the context vector of the i-th time step.
[0063] The obtained context vector with weights is input into the long short-term memory neural layer of the decoder to obtain the output step of the i-th time step. The calculation formula of the output step is:
[0064] y i =LSTM(c i );
[0065] Among them, y i is the output step of the ith time step, c i is the context vector with weights.
[0066] All context vectors are input into the decoder to obtain the output steps corresponding to different time steps, and then the description data of the dish preparation process is obtained.
[0067] S300, inputting the description data into an anomaly recognition model of the dish preparation process, and obtaining an abnormal result of the dish preparation process output by the anomaly recognition model; wherein the anomaly recognition model extracts features of the description data based on convolution kernels of various spatial window lengths to obtain an abnormal result.
[0068] The spatial window length refers to the size of the area covered by the convolution kernel when it slides over the description data. The spatial window length is also called the size of the convolution kernel or the width and height of the convolution kernel.
[0069] The description data output by the description model are respectively input into several parallel convolution channels of the multi-channel convolutional neural network, for example, three parallel convolution channels, and the convolution kernels with different spatial window lengths in each convolution channel are used to convolve the continuous words of different lengths in the description data to extract the continuous words of different lengths. Based on the extracted continuous words of different lengths, the dish production process is analyzed in real time to see whether it meets the specifications, and the abnormal results are output.
[0070] The method for identifying abnormalities in a dish preparation process provided in an embodiment of the present application is by acquiring video data of the dish preparation process; inputting the video data into a description model of the dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of the context vector of the video data based on an attention mechanism, and focuses the context vector based on the weight to generate description data; inputting the description data into an abnormality recognition model of the dish preparation process to obtain abnormal results of the dish preparation process output by the abnormality recognition model; wherein the abnormality recognition model extracts features of the description data based on convolution kernels of multiple spatial window lengths to obtain abnormal results. The embodiment of the present application generates description data based on weighted focus on the context vector; performs feature extraction of the description data to different degrees through convolution kernels with different spatial window lengths to obtain abnormal results, thereby realizing automatic identification of abnormal results in the dish preparation process.
[0071] Based on the above embodiment, the anomaly recognition model includes a plurality of convolution channels connected in parallel, each convolution channel includes a convolution layer, a discard layer, a maximum pooling layer and a flattening layer;
[0072] The convolution layer extracts features describing the data based on the convolution kernel and generates multiple feature values. A convolution layer includes a convolution kernel with a spatial window length, and the convolution kernel in the convolution layer of each convolution channel has a different spatial window length.
[0073] The dropout layer is used to randomly disconnect neurons with input feature values;
[0074] The maximum pooling layer is used to select the largest feature value;
[0075] The flatten layer is used to compress the dimensionality of the largest eigenvalues.
[0076] The anomaly recognition model has multiple input neurons, and the input neurons input the description data into multiple convolution channels respectively. The embodiment of the present application is described by taking three convolution channels as an example.
[0077] like Figure 4 As shown, the first convolution channel includes an input layer, a word embedding layer, a convolution layer, a discard layer, a maximum pooling layer, and a flattening layer from the input end to the output end.
[0078] The input layer defines the length L of the description data of the input dish preparation process, and takes the length of the longest description data in the total data set as L. Before inputting the model, the length of all dish preparation process descriptions must be padded to L;
[0079] The input of the word embedding layer is set to the size N of the dictionary of description texts of the dish making process, and the output is set to the size dimension of the vector space to which the words need to be converted, for example, 100 dimensions. The function of this layer is to perform vector mapping on the description data, converting the integer sequence of each word in the description data text into a vector of fixed shape dimension.
[0080] The convolution layer extracts features from the description data based on the convolution kernel of its specific spatial window length. For example, in a convolution layer, the number of convolution kernels is 48 (that is, the output dimension is 48), the spatial window length of the convolution kernel is set to 2 (that is, the convolution kernel reads 2 words continuously each time), and the activation function of the convolution layer is set to "relu". The convolution layer is used to extract text features, and multiple feature values are generated based on the extracted features.
[0081] The dropout probability is set in the dropout layer. During the test, each time the parameters are updated, the input neurons are randomly disconnected according to the dropout probability. The dropout layer is used to prevent the anomaly recognition model from overfitting.
[0082] The maximum pooling layer retains the maximum value of the feature value extracted by the convolution kernel by setting pooling windows of different sizes, and discards all other feature values. For example, the pooling window size is set to 2.
[0083] The flattening layer is used to reduce the dimension of the largest eigenvalue, which facilitates the transition of the largest eigenvalue from the convolutional layer to the fully connected layer. For example, the flattening layer converts the largest eigenvalue of three dimensions into two dimensions.
[0084] The parameters of the second and third convolution channels are the same as those of the first convolution channel, except that the spatial window length of the convolution kernel in the convolution layer is different from that of the first convolution channel. For example, the spatial window length of the convolution kernel in the second convolution channel is 4, and the spatial window length of the convolution kernel in the third convolution channel is 6.
[0085] The embodiment of the present application uses different convolution channels to perform different degrees of feature extraction on the description data, which is conducive to accurately analyzing whether the dish preparation process complies with the specifications, and then accurately identifying abnormal results in the dish preparation process.
[0086] Based on the above embodiment, the anomaly recognition model further includes a merging layer, a fully connected layer and an output layer;
[0087] The merging layer is connected to the flattening layer and is used to concatenate the largest eigenvalues after compression to generate a eigenvector;
[0088] The fully connected layer is used to integrate and transform the feature vector to obtain the initial prediction result;
[0089] The output layer is used to classify the initial prediction results and output abnormal results.
[0090] The merging layer merges and concatenates the eigenvalues output by the final flattening layer of multiple convolutional channels to generate a new feature vector.
[0091] The fully connected layer includes multiple neurons, each of which is connected to all neurons in the merged layer. The fully connected layer integrates and transforms the feature vector output by the merged layer to obtain the initial prediction result. For example, the number of neurons in the fully connected layer is 16, and the activation function of the fully connected layer is relu.
[0092] The output layer is used to classify the initial prediction results and output the abnormal results of the dish preparation process. The output layer contains a neuron, which outputs the result of whether the dish preparation process of the merchant to be tested is compliant within the set time period, for example, 1 is not compliant and 0 is compliant. The activation function of the output layer is set to sigmoid.
[0093] Furthermore, the error between the predicted abnormal result and the actual abnormal result is calculated. The loss function is a binary pair loss function. The calculation formula of the loss function is:
[0094]
[0095] Among them, y i For true abnormal results, The predicted abnormal results.
[0096] The embodiment of the present application analyzes and determines whether the dish preparation process complies with the specifications by setting a merging layer, a fully connected layer and an output layer in the abnormality recognition model, thereby realizing automatic recognition of abnormal results in the dish preparation process.
[0097] Based on the above embodiment, the description model includes an encoder and a long short-term memory LSTM decoder;
[0098] The encoder is connected to the image feature extractor and is used to encode the image data output by the image feature extractor into at least one context vector;
[0099] The LSTM decoder is used to determine the weight of each context vector, and multiply the context vector by its weight to obtain a context vector associated with the description data; and generate the description data based on the associated context vector.
[0100] The attention mechanism encoder-decoder neural network is built through a deep learning framework, where the encoder is used to encode the real-time video data of the kitchen into a context vector of fixed length, and the decoder is used to generate the corresponding description data of the dish preparation process from the encoded context vector. The description model uses the attention mechanism to focus on the relevant parts of the input context vector as needed to autonomously learn to describe the dish preparation process in the video data. Figure 3 As shown, the description model includes an encoder and a long short-term memory LSTM decoder.
[0101] The encoder includes multiple layers of convolutional neural networks (CNNs), such as a first CNN fully connected layer and a second CNN fully connected layer. The encoder is responsible for converting the vector output by the image feature extractor into a context vector of fixed length. For example, the encoder includes 512 CNN neurons, the activation function of the encoder is relu, and the shape of the encoder output data is (None, 64, 512).
[0102] The Long Short-Term Memory (LSTM) decoder is responsible for generating the corresponding image description sequence based on the encoded context vector. Through attention mechanism learning, attention is placed on the context vector associated with the description data, and the associated context vector is focused. The LSTM decoder includes multiple LSTM layers, each of which includes multiple LSTM neurons. For example, the LSTM decoder includes two LSTM layers with 512 attention mechanism LSTM neurons. The activation function of the LSTM decoder is set to relu, and the shape of the encoder output data is (None, 64, 512).
[0103] Furthermore, the LSTM decoder includes a fully connected layer. The fully connected layer includes multiple neurons (for example, the number of neurons is N), and the activation function is sofmax. The sofmax output result is fed into the multi-accumulated cross entropy loss function, and the output description data is in the shape of (None, N).
[0104] The embodiment of the present application sets different weights for context vectors through an LSTM decoder, and focuses on associated context vectors based on the weights, thereby improving the accuracy of the generated description data.
[0105] Based on the above embodiment, the description model further includes an image feature extractor;
[0106] The image feature extractor is used to extract multiple frames of image data from the video data, standardize the size and pixels of the image data, and input the standardized image data into the encoder.
[0107] The image feature extractor extracts multiple frames of image data from the video data, and converts the images in the image data into a fixed size of input data that the description model can receive, such as 299*299. At the same time, in order to ensure that the image data are all in the same range, the image data needs to be standardized, and each pixel value of each frame or each image is proportionally compressed to the range of 0 to 1. The image feature extractor of the embodiment of the present application includes a deep convolutional neural network (inceptionV3) model. The inceptionV3 model preprocesses the image data, extracts the feature representation of the image, encodes the image data into a vector of fixed length, and uses the last convolution layer of the inceptionV3 model as the output, outputs a vector with a shape of (8, 8, 2048), and compresses it into a shape of (64, 2048).
[0108] The embodiment of the present application acquires image data based on an image feature extractor and performs standardization processing on the image data, which is conducive to the description model to quickly generate description data based on the image data.
[0109] Based on the above embodiment, the description model is obtained based on the following steps:
[0110] S210, generating sample image data based on sample video data of a dish making process;
[0111] S220, performing text cleaning and text serialization on the image description set corresponding to the sample image data to obtain a sample text sequence, and marking the description data of the dish preparation process in the sample text sequence;
[0112] S230, dividing the labeled sample text sequence into a first training set and a first test set according to a preset ratio;
[0113] S240, setting the number of training rounds and the data batch processing amount of the first preset model, and training the first preset model based on the first training set, the number of training rounds and the data batch processing amount of the first preset model to obtain an initial description model;
[0114] S250: Based on the first test set, the initial description model is tested to obtain a description model.
[0115] Sample video data is extracted from the video surveillance equipment in the kitchen. Multiple frames of sample image data are extracted from the sample video data, and the sample image data is converted into a size of input data that can be received by the first preset model, such as 299*299.
[0116] Furthermore, in order to ensure that the sample image data are all within the same range, the sample image data needs to be standardized, and each pixel value of each frame or each image is proportionally compressed to the range of 0 to 1, and then the pixel values are respectively subtracted from the pixel values of the global mean image to achieve normalization, where the pixel value of the global mean image is obtained by calculating the mean of the pixel values of each position of each frame or each image in the sample image data. The pixel values of the processed sample image data will be normalized to a mean of 0 and a variance of 1.
[0117] The image description set corresponding to the sample image data in the dataset is cleaned and the text is serialized. All punctuation marks in the image description set are removed. If the text is in Chinese, the text is segmented. If the text is in English, the letters are unified into lowercase. At the same time, each word is indexed so that each piece of text is converted into a segment of index numbers, and the sequence that does not reach the maximum text length is padded with zeros to obtain a sample text sequence. The longest length (cooking_length) of the image description set is taken as its index sequence length, and the dictionary size corresponding to the longest length is the cooking vocabulary (cooking_vocab_size). The dish preparation process corresponding to the sample text sequence is marked to obtain a marked sample text sequence.
[0118] According to a preset ratio, the labeled sample text sequence is divided into a first training set and a first test set. For example, 90% of the labeled sample text sequence is divided into the first training set, and 10% of the labeled sample text sequence is divided into the first test set. The first training set is used to train the model, and the first test set is used to test the model.
[0119] The number of training rounds and the data batch processing volume of the first preset model are set. Based on the first training set, the number of training rounds and the data batch processing volume, the first preset model is trained to obtain an initial description model. For example, the number of training rounds of the first preset model is set to 1000 (epochs = 1000), the batch processing volume is set to 100 (batch_size = 100), and the multi-class cross entropy (categorical crossentropy) is selected as the loss function, i.e., the objective function (loss = 'categorical_crossentropy'). The gradient descent optimization algorithm selects the adaptive matrix calculation (Adaptive Moment Estimation, adam) optimizer to improve the learning speed of the traditional gradient descent (optimizer = 'adam'). Through gradient descent, the neural network can find the optimal weight value that minimizes the objective function, and the neural network will autonomously learn the weight value through training. The weight of the model is derived after the model converges. Based on the first test set, the initial description model is tested to obtain a description model. For example, the initial description model is tested based on the first test set, and the loss value output by the loss function is calculated. When the loss value is less than or equal to the set threshold, it indicates that the initial description model has converged.
[0120] The embodiment of the present application trains and tests a first preset model based on a sample text sequence marked with a dish preparation process to obtain a description model, thereby improving the accuracy of determining the description model and facilitating the automatic identification of abnormal results in the dish preparation process.
[0121] Based on the above embodiment, the abnormality recognition model is obtained based on the following steps:
[0122] S310, marking abnormal results of the dish preparation process in the sample description data output by the description model;
[0123] S320, performing text cleaning and text serialization on the labeled sample description data;
[0124] S330, dividing the serialized sample description number into a second training set and a second test set according to a preset ratio;
[0125] S340, setting the number of training rounds and the data batch processing amount of the second preset model, and training the second preset model based on the second training set, the number of training rounds and the data batch processing amount of the second preset model to obtain an initial anomaly recognition model;
[0126] S350: Based on the second test set, the initial anomaly recognition model is tested to obtain an anomaly recognition model.
[0127] Collect the description data of the description model samples to form a description data set, save it in txt format, and then manually mark the abnormal results of the dish preparation process in the description data. Then, clean the text of the description data and serialize the text. Filter out all punctuation marks in the description data text, unify the letter case, convert uppercase letters to lowercase letters, index each word in the text, and convert each word into an integer sequence.
[0128] According to a preset ratio, the serialized sample description data is divided into a second training set and a second test set. For example, 90% of the serialized sample description data is divided into the second training set, and 10% of the serialized sample description data is divided into the second test set. The second training set is used to train the model, and the second test set is used to test the model.
[0129] The number of training rounds and the data batch processing volume of the second preset model are set. Based on the second training set, the number of training rounds and the data batch processing volume of the second preset model, the second preset model is trained to obtain an initial anomaly recognition model. For example, the number of training rounds of the second preset model is set to 1000 (epochs = 1000), and the gradient descent optimization algorithm selects the adam optimizer to improve the learning speed of the traditional gradient descent (optimizer = 'adam'). The neural network can find the optimal weight value that minimizes the objective function through gradient descent, and the neural network will autonomously learn the weight value through training. Use the second training set for training so that the smaller the objective function, the better.
[0130] Based on the second test set, the initial anomaly recognition model is tested to obtain an anomaly recognition model. After each round of training, the second test set is used to evaluate and verify the initial anomaly recognition model. After the initial anomaly recognition model converges, the weight of the model is derived.
[0131] The embodiment of the present application trains and tests the second preset model based on the descriptive data marked with abnormal results of the dish preparation process to obtain an abnormal recognition model, thereby improving the accuracy of determining the abnormal recognition model and facilitating the automatic recognition of abnormal results in the dish preparation process.
[0132] The following is a description of the dish preparation process abnormality identification device provided by the embodiment of the present application. The dish preparation process abnormality identification device described below and the dish preparation process abnormality identification method described above can be referred to each other. Figure 5 , Figure 5 1 is a schematic diagram of a device for identifying abnormalities in a dish preparation process provided in an embodiment of the present application. A device for identifying abnormalities in a dish preparation process comprises:
[0133] An acquisition module 501 is used to acquire video data of a dish making process;
[0134] A description module 502 is used to input the video data into a description model of the dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of the context vector of the video data based on the attention mechanism, and focuses on the context vector based on the weight to generate the description data;
[0135] The recognition module 503 is used to input the description data into the abnormal recognition model of the dish preparation process to obtain the abnormal result of the dish preparation process output by the abnormal recognition model; wherein the abnormal recognition model is based on convolution kernels with multiple spatial window lengths to extract the features of the description data and obtain the abnormal result.
[0136] The dish preparation process anomaly recognition device provided in the embodiment of the present application obtains video data of the dish preparation process; inputs the video data into the description model of the dish preparation process to obtain the description data of the dish preparation process output by the description model; wherein the description model determines the weight of the context vector of the video data based on the attention mechanism, and focuses the context vector based on the weight to generate description data; inputs the description data into the anomaly recognition model of the dish preparation process to obtain the abnormal result of the dish preparation process output by the anomaly recognition model; wherein the anomaly recognition model extracts the features of the description data based on convolution kernels with multiple spatial window lengths to obtain the abnormal result. The embodiment of the present application generates description data according to the weighted focus on the context vector; performs different degrees of feature extraction on the description data through convolution kernels with different spatial window lengths to obtain the abnormal result, thereby realizing the automatic recognition of abnormal results in the dish preparation process.
[0137] In one embodiment, the anomaly recognition model includes multiple convolution channels connected in parallel, each convolution channel includes a convolution layer, a discard layer, a maximum pooling layer and a flattening layer; the convolution layer extracts features describing the data based on the convolution kernel and generates multiple eigenvalues; wherein a convolution layer includes a convolution kernel with a spatial window length, and the spatial window length of the convolution kernel in the convolution layer of each convolution channel is different; the discard layer is used to randomly disconnect neurons of input eigenvalues; the maximum pooling layer is used to select the largest eigenvalue; and the flattening layer is used to compress the dimension of the largest eigenvalue.
[0138] In one embodiment, the anomaly recognition model also includes a merging layer, a fully connected layer and an output layer; the merging layer is connected to the flattening layer, and is used to splice the compressed maximum eigenvalues to generate a feature vector; the fully connected layer is used to integrate and transform the feature vector to obtain an initial prediction result; the output layer is used to classify the initial prediction result and output the abnormal result.
[0139] In one embodiment, the description model includes an encoder and a long short-term memory (LSTM) decoder; the encoder is connected to the image feature extractor and is used to encode the image data output by the image feature extractor into at least one context vector; the LSTM decoder is used to determine the weight of each context vector, and multiply the context vector by its weight to obtain a context vector associated with the description data, and generate the description data based on the associated context vector.
[0140] In one embodiment, the description model further includes an image feature extractor; the image feature extractor is used to extract multiple frames of image data from the video data, and to standardize the size and pixels of the image data, and to input the standardized image data into the encoder.
[0141] In one embodiment, the description model is obtained based on the following steps: based on sample video data of a dish preparation process, sample image data is generated; text cleaning and text serialization are performed on an image description set corresponding to the sample image data to obtain a sample text sequence, and the description data of the dish preparation process of the sample text sequence is marked; according to a preset ratio, the marked sample text sequence is divided into a first training set and a first test set; the number of training rounds and the data batch processing amount of the first preset model are set, and based on the first training set, the number of training rounds and the data batch processing amount of the first preset model, the first preset model is trained to obtain an initial description model; based on the first test set, the initial description model is tested to obtain a description model.
[0142] In one embodiment, the anomaly recognition model is obtained based on the following steps: marking the abnormal results of the dish preparation process in the sample description data output by the description model; performing text cleaning and text serialization on the marked sample description data; dividing the serialized sample description data into a second training set and a second test set according to a preset ratio; setting the number of training rounds and the data batch processing amount of the second preset model, and based on the second training set, the number of training rounds and the data batch processing amount of the second preset model, training the second preset model to obtain an initial anomaly recognition model; based on the second test set, testing the initial anomaly recognition model to obtain an anomaly recognition model.
[0143] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call a computer program in the memory 630 to execute the steps of the method for identifying abnormalities in the dish preparation process, for example, including:
[0144] Acquire video data of a dish preparation process; input the video data into a description model of the dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of a context vector of the video data based on an attention mechanism, and focuses the context vector based on the weight to generate description data; input the description data into an anomaly recognition model of the dish preparation process to obtain an abnormal result of the dish preparation process output by the anomaly recognition model; wherein the anomaly recognition model extracts features of the description data based on convolution kernels of a variety of spatial window lengths to obtain abnormal results.
[0145] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0146] On the other hand, an embodiment of the present application further provides a computer program product, the computer program product including a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer can perform the steps of the method for identifying abnormalities in the dish preparation process provided in the above embodiments, for example, including:
[0147] Acquire video data of a dish preparation process; input the video data into a description model of the dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of a context vector of the video data based on an attention mechanism, and focuses the context vector based on the weight to generate description data; input the description data into an anomaly recognition model of the dish preparation process to obtain an abnormal result of the dish preparation process output by the anomaly recognition model; wherein the anomaly recognition model extracts features of the description data based on convolution kernels of a variety of spatial window lengths to obtain abnormal results.
[0148] On the other hand, an embodiment of the present application further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores a computer program, wherein the computer program is used to enable a processor to execute the steps of the method for identifying abnormalities in a dish preparation process provided in the above embodiments, for example, including:
[0149] Acquire video data of a dish preparation process; input the video data into a description model of the dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of a context vector of the video data based on an attention mechanism, and focuses the context vector based on the weight to generate description data; input the description data into an anomaly recognition model of the dish preparation process to obtain an abnormal result of the dish preparation process output by the anomaly recognition model; wherein the anomaly recognition model extracts features of the description data based on convolution kernels of a variety of spatial window lengths to obtain abnormal results.
[0150] The non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.
[0151] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0152] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for identifying abnormalities in a dish preparation process, characterized in that: include: Obtain video data of the dish preparation process; Inputting the video data into a description model of a dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of a context vector of the video data based on an attention mechanism, and focuses on the context vector based on the weight to generate the description data; The description data is input into an abnormality recognition model of a dish preparation process to obtain an abnormal result of the dish preparation process output by the abnormality recognition model; wherein the abnormality recognition model extracts features of the description data based on convolution kernels of a variety of spatial window lengths to obtain the abnormal result.
2. The method for identifying abnormalities in a dish preparation process according to claim 1, characterized in that: The anomaly recognition model includes a plurality of convolution channels connected in parallel, each of which includes a convolution layer, a discard layer, a maximum pooling layer and a flattening layer; The convolution layer extracts the features of the description data based on the convolution kernel and generates multiple feature values; wherein one of the convolution layers includes a convolution kernel of a spatial window length, and the convolution kernels in the convolution layer of each convolution channel have different spatial window lengths; The discard layer is used to randomly disconnect neurons that input the feature value; The maximum pooling layer is used to select the maximum eigenvalue; The flattening layer is used to compress the dimension of the largest eigenvalue.
3. The method for identifying abnormalities in a dish preparation process according to claim 2, characterized in that: The anomaly recognition model also includes a merging layer, a fully connected layer and an output layer; The merging layer is connected to the flattening layer and is used to concatenate the compressed maximum eigenvalues to generate a eigenvector; The fully connected layer is used to integrate and transform the feature vector to obtain an initial prediction result; The output layer is used to classify the initial prediction results and output the abnormal results.
4. The method for identifying abnormalities in a dish preparation process according to claim 1, characterized in that: The description model includes an encoder and a long short-term memory (LSTM) decoder; The encoder is connected to the image feature extractor and is used to encode the image data output by the image feature extractor into at least one context vector; The LSTM decoder is used to determine the weight of each of the context vectors, and multiply the context vector by its weight to obtain a context vector associated with the description data, and generate the description data based on the associated context vector.
5. The method for identifying abnormalities in a dish preparation process according to claim 1, characterized in that: The description model also includes an image feature extractor; The image feature extractor is used to extract multiple frames of image data from the video data, standardize the size and pixels of the image data, and input the standardized image data into an encoder.
6. The method for identifying abnormalities in a dish preparation process according to claim 1, characterized in that: The description model is obtained based on the following steps: Generate sample image data based on sample video data of the dish making process; Performing text cleaning and text serialization on the image description set corresponding to the sample image data to obtain a sample text sequence, and marking the description data of the dish preparation process in the sample text sequence; According to a preset ratio, the labeled sample text sequence is divided into a first training set and a first test set; Setting the number of training rounds and the data batch processing amount of the first preset model, and training the first preset model to obtain an initial description model based on the first training set, the number of training rounds and the data batch processing amount of the first preset model; Based on the first test set, the initial description model is tested to obtain a description model.
7. The method for identifying abnormalities in a dish preparation process according to claim 1, characterized in that: The anomaly recognition model is obtained based on the following steps: Marking abnormal results of the dish preparation process in the sample description data output by the description model; Performing text cleaning and text serialization on the labeled sample description data; According to a preset ratio, the serialized sample description number is divided into a second training set and a second test set; Setting the number of training rounds and the data batch processing amount of the second preset model, and training the second preset model based on the second training set, the number of training rounds and the data batch processing amount of the second preset model to obtain an initial anomaly recognition model; Based on the second test set, the initial anomaly recognition model is tested to obtain an anomaly recognition model.
8. A device for identifying abnormalities in a dish preparation process, characterized in that: include: An acquisition module is used to acquire video data of the dish making process; A description module, used for inputting the video data into a description model of a dish preparation process to obtain description data of the dish preparation process output by the description model; wherein the description model determines the weight of the context vector of the video data based on an attention mechanism, and focuses on the context vector based on the weight to generate the description data; The recognition module is used to input the description data into an abnormal recognition model of the dish preparation process to obtain an abnormal result of the dish preparation process output by the abnormal recognition model; wherein the abnormal recognition model extracts the features of the description data based on convolution kernels of multiple spatial window lengths to obtain the abnormal result.
9. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the steps of the method for identifying abnormalities in the dish preparation process described in any one of claims 1 to 7 are implemented.
10. A non-transitory 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 for identifying abnormalities in a dish preparation process according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Video description method and device based on convolutional neural network
CN111325068A
Abnormal event detection method generated based on image description and detection system thereof
CN112732965A
Extreme behavior recognition method and device based on deep learning model, equipment and medium
CN113111175A
Video description generation model based on attention mechanism
CN114268846A
Detection method and device of meal product making process and storage medium
CN114612846A
