Dish identification method and device, terminal equipment and storage medium

By optimizing the convolutional neural network model and building a retrieval library, the problem of low dish recognition accuracy and large model parameter volume is solved, and efficient and accurate dish recognition is achieved.

CN118658155APending Publication Date: 2024-09-17CHINA MERCHANTS BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410747952.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Existing dish recognition methods have low accuracy and large model parameters, resulting in slow recognition speed.

Method used

The convolutional neural network model is combined with the cross-entropy loss function and the triplet loss function for optimization. The PP-LCNetV2 model is used to extract features of the target dish image, and the Faiss library and IndexFlatIP index algorithm are used to build a retrieval library to improve the accuracy of the dish feature vectors. Retrieval efficiency.

Benefits of technology

It improves the accuracy and efficiency of dish recognition, reduces equipment load, and expands the application scope of dish recognition technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118658155A
    Figure CN118658155A
Patent Text Reader

Abstract

The invention discloses a dish identification method and device, terminal equipment and a storage medium, and relates to the field of intelligent identification, and the method comprises the steps: obtaining a target dish image; performing feature extraction on the target dish image based on a convolutional neural network model to obtain a dish feature vector, the convolutional neural network model being obtained by optimizing a cross entropy loss function and a triple loss function; and retrieving the dish feature vector through a preset retrieval library to obtain a dish category. According to the invention, the accuracy of identifying dishes can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of intelligent identification, and in particular to a dish identification method, device, terminal device and storage medium. Background Art

[0002] With the continuous evolution of deep learning technology and the increasing perfection of intelligent algorithms, dish recognition has been widely used in the fields of smart catering, health management and social media. For example, in the field of smart catering, dish recognition technology can help restaurants realize intelligent ordering systems, improve the convenience and efficiency of ordering, and also recommend dishes according to the guests' taste preferences. In the field of health management, dish recognition technology can be used to record personal diet, analyze nutritional intake, and provide users with healthy diet suggestions. In the field of social media, dish recognition technology can help users share information about the dishes they eat, communicate with others about food experiences, and promote the spread of food culture. Therefore, dish recognition technology brings more convenience and fun to people's lives and work.

[0003] At present, the commonly used dish recognition methods mainly improve the recognition accuracy through multimodal input or larger neural network structures. Multimodal input refers to inputting different types of data into the model, such as images, text descriptions, recipe information, etc., to provide more comprehensive information for recognition. The use of a larger neural network structure can increase the complexity and learning ability of the model, which helps to better extract and understand the characteristic information of the dish. However, the above-mentioned method of dish recognition still has the problems of low dish recognition accuracy, slow speed and large model parameter volume. Summary of the invention

[0004] The main purpose of this application is to provide a dish recognition method, device, terminal device and storage medium, aiming to improve the accuracy of dish recognition.

[0005] To achieve the above objectives, the present application provides a dish identification method, the method comprising:

[0006] Obtain the target dish image;

[0007] Extracting features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function;

[0008] The dish feature vector is searched through the preset search library to obtain the dish category

[0009] In one embodiment, the step of acquiring the target dish image includes:

[0010] Get the initial dish image;

[0011] Determining a dish position of at least one dish in the initial dish image based on a preset dish detection module, wherein the dish detection module is composed of a PP-PicoDet model;

[0012] The initial dish image is cropped according to the dish position to obtain at least one target dish image.

[0013] In one embodiment, the step of extracting features from the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function, comprises:

[0014] Based on the preset cross entropy loss function and the preset triplet loss function, the preset PP-LCNetV2 model is optimized to obtain the optimized convolutional neural network model.

[0015] In one embodiment, the step of obtaining the target dish image includes:

[0016] Get standard dish images;

[0017] Based on the optimized convolutional neural network model, feature extraction is performed on the standard dish image to obtain a feature vector of the standard dish image;

[0018] A retrieval library is constructed according to the standard dish image feature vector.

[0019] In one embodiment, the step of constructing a search library according to the standard dish image feature vector comprises:

[0020] The standard dish image feature vectors are stored and a retrieval library is constructed by using the preset Faiss library tool and IndexFlatIP indexing algorithm.

[0021] In one embodiment, the step of searching the dish feature vector through a preset search library to obtain the dish category includes:

[0022] Using a preset search algorithm, searching the search library according to the dish feature vector to obtain a target feature vector;

[0023] The dish category is determined according to the label data of the target feature vector.

[0024] In one embodiment, the step of searching the dish feature vector through a preset search library to obtain the dish category includes:

[0025] By using a preset search algorithm and screening conditions, the search library is searched according to the dish feature vector to obtain a feature vector similarity list, wherein the feature vector similarity list includes at least one target feature vector;

[0026] According to the label data of the target feature vector in the feature vector similarity list, at least one dish category corresponding to the label data is obtained.

[0027] In addition, to achieve the above-mentioned purpose, the present application also proposes a dish identification device, which includes:

[0028] A target dish image acquisition module, used to acquire a target dish image;

[0029] A dish feature vector extraction module, used to extract features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function;

[0030] The vector retrieval module is used to retrieve the dish feature vector through a preset retrieval library to obtain the dish category.

[0031] In addition, to achieve the above-mentioned purpose, the present application also proposes a dish identification device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the dish identification method described above.

[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the dish identification method described above are implemented.

[0033] The dish recognition method, apparatus, terminal device and storage medium proposed in the embodiments of the present application obtain a target dish image; extract features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, and the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function; retrieve the dish feature vector through a preset retrieval library to obtain a dish category. After obtaining the target dish image, the present application can extract the feature vector of the target dish image through a convolutional neural network model to obtain a dish feature vector that can be used for subsequent retrieval in the retrieval library, thereby determining the dish category corresponding to the target dish image. Since the convolutional neural network model for extracting the feature vector of the target dish image is optimized by a cross entropy loss function and a triplet loss function, the present application has a higher efficiency in extracting the vector features of the target dish image, so that the error between the final dish category and the actual dish category of the target dish image is smaller and the accuracy is higher. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0036] Figure 1 A flowchart of the first embodiment of the method for identifying dishes of the present application is provided;

[0037] Figure 2 A flow chart of the second embodiment of the method for identifying dishes of the present application;

[0038] Figure 3 This is a schematic diagram of the network structure of the PP-PicoDet model for the dish recognition method of this application;

[0039] Figure 4 This is a schematic diagram of the structure of the compression excitation module of the PP-PicoDet model of the dish recognition method of this application;

[0040] Figure 5 A flowchart of the third embodiment of the method for identifying dishes of the present application is provided;

[0041] Figure 6 This is a schematic diagram of the network structure of the PP-LCNetV2 model for the dish recognition method in this application;

[0042] Figure 7This is a schematic diagram of the re-parameterization strategy of the PP-LCNetV2 model for the dish recognition method in this application;

[0043] Figure 8 This is a schematic diagram of the deep separable convolutional structure of the PP-LCNetV2 model for the dish recognition method in this application;

[0044] Fig. 9 A flowchart of the fourth embodiment of the method for identifying dishes of the present application is provided;

[0045] Fig.10 A flowchart of the fifth embodiment of the method for identifying dishes of the present application is provided;

[0046] Fig.11 A flowchart of the sixth embodiment of the method for identifying dishes of the present application is provided;

[0047] Fig.12 A flow chart of the seventh embodiment of the method for identifying dishes of the present application;

[0048] Fig.13 This is a schematic diagram of the overall process of the dish identification method of this application;

[0049] Fig.14 This is a schematic diagram of the module structure of the dish identification device according to an embodiment of the present application;

[0050] Fig.15 This is a schematic diagram of the device structure of the hardware operating environment involved in the dish identification method in the embodiment of the present application.

[0051] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0052] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0053] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0054] The main solution of the present application is: obtaining a target dish image; performing feature extraction on the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function; searching the dish feature vector through a preset retrieval library to obtain a dish category. After obtaining the target dish image, the present application can extract the feature vector of the target dish image through a convolutional neural network model to obtain a dish feature vector that can be used for subsequent retrieval in the retrieval library, thereby determining the dish category corresponding to the target dish image. Since the convolutional neural network model for extracting the feature vector of the target dish image is optimized by a cross entropy loss function and a triplet loss function, the present application has a higher efficiency in extracting the vector features of the target dish image, so that the error between the final dish category and the actual dish category of the target dish image is smaller and the accuracy is higher.

[0055] This embodiment takes into account that with the continuous evolution of deep learning technology and the increasing perfection of intelligent algorithms, dish recognition has been widely used in the fields of smart catering, health management, and social media. However, the currently commonly used dish recognition methods mainly improve the recognition accuracy through multimodal input or a larger neural network structure, but the above-mentioned method of dish recognition still has the problems of low dish recognition accuracy and large model parameter volume.

[0056] Based on this, an embodiment of the present application proposes a solution. After obtaining the target dish image, the feature vector of the target dish image is extracted through a convolutional neural network model to obtain a dish feature vector that can be used for subsequent retrieval in a retrieval library, thereby determining the dish category corresponding to the target dish image. Since the convolutional neural network model for extracting feature vectors of the target dish image has been optimized, the present application has a higher efficiency in extracting vector features of the target dish image, so that the error between the final dish category and the actual dish category of the target dish image is smaller, and the accuracy is higher.

[0057] Based on this, the present application proposes a dish identification method of the first embodiment, please refer to Figure 1 , the dish recognition method includes steps S20, S40 and S50:

[0058] Step S20, obtaining a target dish image;

[0059] The target dish image refers to image data with dish information, wherein the dish information may include visual information, structural information, contextual information and lighting information. Specifically, visual information may include the color, shape, texture and size of the dish, which are important visual clues for identifying and distinguishing different dishes. Structural information may include the geometric layout, ingredient distribution and placement order of the dish. For example, a plate of salad may contain several different vegetables and condiments, and their distribution and position are also important factors for identification. Contextual information may include the environment and background color of the dish, while lighting information refers to information such as the brightness and shadow of the image.

[0060] Specifically, the target dish image can be obtained by processing the initial dish image, wherein the initial dish image refers to an unprocessed original image, and the unprocessed original image can be obtained by directly shooting at least one dish through a camera or other shooting device. The initial dish image may include several dishes, that is, there may be one or more independent dishes in a single initial dish image. As an implementation method, after obtaining the initial dish image, the initial dish image is processed by a preset dish detection module to obtain a target dish image that can be used for feature extraction by the optimized convolutional neural network model.

[0061] Specifically, the preset dish detection module can use a lightweight target detection model to process the target dish image. The target detection model can be used to process a single initial dish image with one or more independent dishes to obtain one or more target dish images. That is, the target detection model used in the dish detection module can generate a corresponding number of target dish images according to the number of dishes present in the initial dish image. For example, if there are three independent dishes in the initial dish image, then the target dish images obtained after the initial dish image is processed by the dish detection module are three, representing the three independent dishes in the initial dish image. It should be noted that an independent dish refers to a single dish that is clearly identifiable and physically separated in the image. Each independent dish is visually independent of other objects. Specifically, the dishes are placed on different plates or have obvious spatial separations on the table, which facilitates the target detection model to spatially divide several dishes.

[0062] Step S40, extracting features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function;

[0063] After the dish detection module completes the processing of the initial dish image and obtains the target dish image, the feature vector of the target dish image is extracted by the preset feature extraction module to obtain the dish feature vector corresponding to the target dish image. Specifically, a convolutional neural network model can be used in the feature extraction module, and the convolutional neural network model can be an optimized PP-LCNetV2 model. Specifically, the feature extraction of the target dish image can be performed by the PP-LCNetV2 model optimized by the cross entropy loss function and the triplet loss function.

[0064] Among them, the PP-LCNetV2 model is a lightweight deep learning model suitable for resource-constrained environments such as mobile devices or edge computing devices. The PP-LCNetV2 model mainly uses a heavy parameterization strategy to combine deep convolutions of different sizes of convolution kernels, and optimizes point convolutions and loss functions, so that the PP-LCNetV2 model can have a single-frame image inference speed of less than 5 milliseconds with very few parameters. Therefore, by using the PP-LCNetV2 model to extract features of the target dish image, the feature extraction of the target dish image can be completed efficiently and accurately while reducing the device load, expanding the application scope of dish recognition technology.

[0065] Step S50, searching the dish feature vector through a preset search library to obtain the dish category;

[0066] After the feature extraction module completes the feature vector extraction of the target dish image and obtains the dish feature vector corresponding to the target dish image, the dish feature vector is searched through a preset retrieval library. After obtaining the feature vector with the highest similarity to the dish feature vector, the label data of the feature vector is returned to obtain the dish category of the target dish image.

[0067] Among them, the label data can be the "name" or "category" corresponding to the feature vector. Specifically, the similarity measurement method such as Euclidean distance or cosine similarity can be used to search and find the feature vector in the library that is most similar to the input dish feature vector. Furthermore, after finding the feature vector that is most similar to the input dish feature vector, the number of labels associated with it is extracted. The label data represents one or more most likely dish names or categories. The specific number of label data returned can be set according to actual conditions. If the number of returned label data is set to 2, the dish feature vector is searched through the retrieval library and the label data corresponding to the first two feature vectors with the highest similarity values ​​and the similarity values ​​corresponding to each label data are returned at the same time, so as to improve the recognition accuracy of the dish category.

[0068] The dish recognition method proposed in the embodiment of the present application obtains a target dish image; extracts features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, and the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function; and retrieves the dish feature vector through a preset retrieval library to obtain a dish category. After obtaining the target dish image, the present application can extract the feature vector of the target dish image through a convolutional neural network model to obtain a dish feature vector that can be used for subsequent retrieval in the retrieval library, thereby determining the dish category corresponding to the target dish image. Since the convolutional neural network model for extracting the feature vector of the target dish image is optimized by a cross entropy loss function and a triplet loss function, the present application has a higher efficiency in extracting the vector features of the target dish image, so that the error between the final dish category and the actual dish category of the target dish image is smaller and the accuracy is higher.

[0069] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 , in step S20 of the dish recognition method, the target dish image is obtained and refined, wherein the refinement steps include S21 to S23:

[0070] Step S21, obtaining an initial dish image;

[0071] Step S22, determining the dish position of at least one dish in the initial dish image based on a preset dish detection module, wherein the dish detection module is composed of a PP-PicoDet model;

[0072] A camera or other image acquisition device is used to directly capture at least one dish to obtain an original image, i.e., an initial dish image. The initial dish image has not been processed in any way and can reflect the physical scene at the time of capturing, including elements such as the color, shape, size, and possible background environment of the dish. The initial dish image can include one or more dishes, such as multiple dishes on a large table. Each dish can be regarded as an independent dish.

[0073] Subsequently, in order to effectively identify and analyze the initial dish image, after obtaining the initial dish image, the dish position of at least one dish in the initial dish image is determined by a preset dish detection module, and the initial dish image is processed according to the dish position to obtain at least one target dish image.

[0074] Specifically, the dish detection module uses the PP-PicoDet model to confirm the position of independent dishes in the initial dish image. The PP-PicoDet model is a lightweight target detection model. Since the PP-PicoDet model pays special attention to the efficiency and size of the model in the field of target detection, the PP-PicoDet model is suitable for running on resource-constrained devices or devices, such as mobile phones or embedded systems. It can be understood that the input of the PP-PicoDet model is the initial dish image captured by the camera, and the output is the position of each dish in the initial dish image.

[0075] Reference Figure 3 , Figure 3 This is a schematic diagram of the network structure of the PP-PicoDet model for the dish recognition method in this application.

[0076] Specifically, the network structure of the PP-PicoDet model is as follows: Figure 3 As shown in Figure 2, the PP-PicoDet model introduces the SE (Squeeze-and-Excitation Module) module in each block. Specifically, the network structure of the SE module is as follows: Figure 4 As shown, when the step size is equal to 1, the SE module also introduces a Ghost block, which can generate more feature maps with fewer parameters, thereby improving the network learning ability. When the step size is equal to 2, the SE module introduces DW (Depth-Wise, depth direction) convolution and PW (Point-Wise, point-by-point) convolution to combine information from different channels, thereby reducing the information loss of feature fusion. In this application, the PP-PicoDet model also optimizes the CSP-PAN (Cross Stage Partial Path Aggregation Network) structure. In the original CSP-PAN, the number of channels of each output feature map is consistent with the input feature of the backbone network, but for mobile devices, the large channel structure will bring expensive computing costs. In order to save computing costs and not reduce the detection accuracy of the dish category, the PP-PicoDet model in this application uses 1X1 convolution to unify the number of channels of feature maps of different sizes to 96, and uses CSP (Cross Stage Partial, cross-stage partial) structure realizes top-down and bottom-up feature fusion. In addition, the PP-PicoDet model also adds a feature scale branch on the top of the original CSP-PAN to detect more objects. In order to further improve the detection accuracy with a small number of parameters, the optimized CSP-PAN uses DW convolution to expand the receptive field except 1X1 convolution.

[0077] Specifically, the PP-PicoDet mode uses the SimOTA (Similar Object Tracking Algorithm) dynamic label assignment strategy to optimize the training process. SimOTA first calculates the IoU (Intersection over Union) for each true target box and anchor candidate box, selects the n largest IoU values ​​and sums them to obtain the parameter K, then calculates the cost matrix based on the positioning loss and classification loss, and finally selects K anchors with the smallest cost as positive samples for each true target box. The calculation formula of the cost matrix is:

[0078] cost=loss vfl +6loss giou

[0079] Among them, loss vfl VariFocalLoss (zoom loss), loss giou is GIoULoss (generalized intersection-over-union loss). Finally, the calculation formula of the dish detection loss function is:

[0080] loss=loss vfl +2loss giou +0.25loss dfl |

[0081] Among them, loss vfl VariFocalLoss (zoom loss), loss giou is GIoULoss (generalized intersection-over-union loss), loss dfl It is DistributionFocalLoss (distribution focal loss).

[0082] Step S23, cropping the initial dish image according to the dish position to obtain at least one target dish image;

[0083] After the dish detection module determines the dish position of at least one dish in the initial dish image, the detection module will identify the area of ​​at least one dish in the image, that is, the dish position, and crop the initial dish image according to the dish position to obtain at least one target dish image, that is, the initial dish image is cropped according to the detected dish position information, that is, only the area containing a single independent dish is retained, and other irrelevant areas are removed to obtain the target dish image. It can be understood that each target dish image represents an independent dish. Through this method, each independent dish can be extracted and cropped out from the initial dish image to obtain at least one target dish image, which is convenient for subsequent feature extraction and feature vector retrieval of each target dish image to determine the dish category of each target dish image.

[0084] The dish recognition method proposed in the embodiment of the present application obtains an initial dish image; determines the dish position of at least one dish in the initial dish image based on a preset dish detection module, wherein the dish detection module is composed of a PP-PicoDet model; and crops the initial dish image according to the dish position to obtain at least one target dish image. The present application can reduce the cost and load of the equipment running model while ensuring the quality of acquiring the target dish image.

[0085] Based on the second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above-mentioned second embodiment can refer to the above introduction, and will not be repeated in the following. Figure 5 In step S40, the target dish image is feature extracted based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function. The dish recognition method further includes step S30:

[0086] Step S30, optimizing the preset PP-LCNetV2 model based on the preset cross entropy loss function and the preset triplet loss function to obtain an optimized convolutional neural network model;

[0087] Among them, the convolutional neural network model used in the present application for feature extraction of the target dish image is the PP-LCNetV2 model. Specifically, the PP-LCNetV2 model in this embodiment uses a re-parameterization strategy to combine deep convolutions of convolution kernels of different sizes. Specifically, the network structure of the PP-LCNetV2 model is as follows: Figure 6 As shown, the schematic diagram of the PP-LCNetV2 model reparameterization strategy is as follows Figure 7 shown.

[0088] like Figure 7As shown, the PP-LCNetV2 model used in the convolutional neural network model in this application uses a combination of three DW convolution kernels of different sizes in the 4th and 5th stages, namely, a 5X5 DW convolution kernel, a 3X3 DW convolution kernel, and a 1X1 DW convolution kernel. At the same time, in order to improve the model reasoning efficiency, PP-LCNetV2 uses the Rep strategy to fuse the DW convolution of this layer. Therefore, the PP-LCNetV2 model can improve the perception ability of the neural network and have receptive fields of different scales by combining multi-scale convolution kernels.

[0089] Furthermore, the PP-LCNetV2 model also optimizes the depth-separable convolution structure. Specifically, the PP-LCNetV2 model uses one layer of DW convolution and two layers of PW convolution. The first PW convolution compresses the feature map in the channel dimension, and the second PW convolution restores the compressed feature map channel. For details, please refer to Figure 8 Schematic diagram of the depth-wise separable convolution structure shown.

[0090] Among them, the loss function of the PP-LCNetV2 model consists of two parts: cross entropy loss (CrossEntropyLoss) and triplet loss (TripletLoss). Cross entropy loss can speed up the convergence of the network. Triplet loss can learn richer semantic information by comparing the similarities between samples, which helps to improve the generalization ability of the model. Therefore, using CrossEntropyLoss and TripletLoss to jointly optimize the dish feature extraction network can not only speed up the convergence of the network, but also improve the generalization ability of the model. Specifically, the loss function formula of the PP-LCNetV2 model is as follows:

[0091] Loss=CrossEntropyLoss+TripletLoss

[0092] Among them, the expression of CrossEntropyLoss is as follows:

[0093]

[0094] Among them, N is the total number of samples, C is the number of categories, and x i represents the i-th sample input, f(x i ) represents the model output probability distribution corresponding to sample i, y i,j Indicates the true label (0 or 1) of the jth category corresponding to sample i, f(x i ) j Represents the predicted probability of the jth category corresponding to sample i.

[0095] The expression of TripletLoss is as follows:

[0096]

[0097] Where N is the total number of samples, x i represents the i-th sample input, emb() represents the embedding function, Indicates the distance x i The most recent positive sample, Indicates the distance x i The nearest negative sample, α is a hyperparameter representing the boundary interval.

[0098] The dish recognition method proposed in the embodiment of the present application optimizes the PP-LCNetV2 model through the cross entropy loss function and the preset triplet loss function to obtain an optimized convolutional neural network model, so that the target dish image can be subsequently extracted based on the optimized PP-LCNetV2 model to obtain the dish feature vector. The PP-LCNetV2 model in the present application is optimized by combining the loss function composed of the cross entropy loss function and the triplet loss function, which effectively improves the recognition accuracy of the dish.

[0099] Based on the third embodiment of the present application, in the fourth embodiment of the present application, the same or similar contents as those in the third embodiment can be referred to the above introduction, and will not be described in detail later. Fig. 9 In step S20, before acquiring the target dish image, the dish recognition method further includes steps S10 to S12:

[0100] Step S10, obtaining a standard dish image;

[0101] Step S11, based on the optimized convolutional neural network model, feature extraction is performed on the standard dish image to obtain a feature vector of the standard dish image;

[0102] Step S12, constructing a retrieval library according to the standard dish image feature vector;

[0103] Among them, the standard dish image refers to a cropped dish image with standard specifications, which is used to extract feature vectors through a convolutional neural network model for subsequent retrieval of the dish feature vector. Specifically, the standard dish image has the same or similar scale, color coding and resolution, which is convenient for extracting feature vectors from it using the convolutional neural network model of the PP-LCNetV2 model. After the PP-LCNetV2 model extracts the feature vector of the standard dish image and obtains the standard dish image feature vector, a retrieval library is constructed based on the standard dish image feature vector for subsequent feature vector similarity retrieval.

[0104] Specifically, after the PP-LCNetV2 model obtains the standard dish image feature vector, the standard dish image feature vector can be added to Faiss (Facebook AI Similarity Search) and stored through a preset indexing algorithm, thereby constructing a retrieval library with standard dish image feature vectors to facilitate subsequent retrieval, wherein the preset indexing algorithm can be the IndexFlatIP indexing method.

[0105] The dish recognition method proposed in the embodiment of the present application obtains a standard dish image; based on the optimized convolutional neural network model, features are extracted from the standard dish image to obtain a standard dish image feature vector; and a retrieval library is constructed according to the standard dish image feature vector. The present application can perform feature extraction on the standard dish image through the optimized convolutional neural network model before extracting features from the target dish image, thereby obtaining a standard dish image feature vector for constructing a retrieval library, providing reference data for subsequent retrieval of the dish feature vector, and improving the accuracy of dish recognition.

[0106] Based on the fourth embodiment of the present application, in the fifth embodiment of the present application, the same or similar contents as those in the fourth embodiment can be referred to the above introduction, and will not be repeated in the following. Fig.10 , in step S12 of the dish recognition method, a retrieval library is constructed according to the standard dish image feature vector for refinement, wherein the refinement step includes S121:

[0107] Step S121, storing the standard dish image feature vectors and constructing a retrieval library through the preset Faiss library tool and IndexFlatIP indexing algorithm;

[0108] Among them, Faiss is a tool developed by the Facebook AI team for large-scale similarity retrieval problems. Faiss can support both CPU (Central Processing Unit) and GPU (Graphics Processing Unit) to speed up the retrieval process.

[0109] Specifically, Faiss also provides a variety of indexing methods, among which the IndexFlatIP indexing method has high accuracy, supports adding data one by one and does not require training, and has high efficiency in building indexes. Therefore, the present application can use the IndexFlatIP indexing method to store the feature vectors of standard dish images and build a retrieval library.

[0110] Specifically, the process of building a search library may include:

[0111] Initialize the FAISS index: Use FAISS to create an IndexFlatIP index object and set the index dimension to the dimension of the feature vector.

[0112] Storing feature vectors: The feature vectors extracted from each standard dish image are stored in a list or matrix in order and the data type of the feature vectors is suitable for FAISS indexing.

[0113] Add feature vectors to the index: Add the feature vectors of all standard dish images to the FAISS index object, that is, store the feature vectors in the index structure for subsequent fast retrieval.

[0114] The dish identification method proposed in the embodiment of the present application stores the standard dish image feature vectors and constructs a retrieval library through the preset Faiss library tool and IndexFlatIP indexing algorithm. The present application can directly store the obtained standard dish image feature vectors without any compression or dimensionality reduction operations, which not only reduces the complexity of constructing the retrieval library, but also reduces the update cost caused by the subsequent multiple additions of new standard dish image feature vectors.

[0115] Based on the fifth embodiment of the present application, in the sixth embodiment of the present application, the same or similar contents as those in the fifth embodiment can be referred to the above description, and will not be described in detail later. Fig.11 , in step S50 of the dish recognition method, the dish feature vector is searched through a preset search library to obtain a dish category for refinement, wherein the refinement steps include S51-S52:

[0116] Step S51, searching the search library according to the dish feature vector using a preset search algorithm to obtain a target feature vector;

[0117] Step S52, determining the dish category according to the label data of the target feature vector;

[0118] The retrieval process uses the constructed retrieval library to find the feature vector that is most similar to the query dish feature vector. The FAISS index can be used to search for the most similar feature vector in the retrieval library, that is, a quick search is performed based on the similarity between the feature vector in the retrieval library and the dish feature vector (methods such as inner product or Euclidean distance can be used), and the feature vector that is most similar to the dish feature vector and its corresponding distance are returned. Subsequently, according to the index of the retrieved most similar feature vector, its corresponding label is obtained to determine the dish category of the target dish image.

[0119] Specifically, a mapping table from index to label data can be established in advance, in which the correspondence between label data and feature vectors is recorded, and the index of each feature vector is matched with the actual dish label. Subsequently, after completing the search of the retrieval library, the label data corresponding to the index is searched according to the index returned by FAISS, thereby determining the dish category of the target dish image.

[0120] The dish identification method proposed in the embodiment of the present application searches the search library according to the dish feature vector through a preset search algorithm to obtain a target feature vector; and determines the dish category according to the label data of the target feature vector. The present application can improve the efficiency of retrieval.

[0121] Based on the fifth embodiment of the present application, in the seventh embodiment of the present application, the same or similar contents as those in the fifth embodiment can be referred to the above description, and will not be described in detail later. Fig.12 , in step S50 of the dish recognition method, the dish feature vector is searched through a preset search library to obtain a dish category for refinement, wherein the refinement steps include S501 to S502:

[0122] Step S501, searching the search library according to the dish feature vector using a preset search algorithm and screening conditions to obtain a feature vector similarity list, wherein the feature vector similarity list includes at least one target feature vector;

[0123] Step S502, obtaining at least one dish category corresponding to the label data according to the label data of the target feature vector in the feature vector similarity list;

[0124] After the target dish image is feature extracted by the optimized PP-LCNetV2 model to obtain the dish feature vector, at least one standard dish image feature vector with the highest similarity to the dish feature vector can be retrieved from the retrieval library according to the preset retrieval algorithm. Specifically, the number of retrieved standard dish image feature vectors can be determined by pre-set screening conditions.

[0125] The feature vector similarity list records at least one target feature vector that meets the screening condition, and the target feature vector is the retrieved standard dish image feature vector.

[0126] For example, if the filtering condition sets the retrieval quantity to three, after obtaining the dish feature vector, the preset retrieval algorithm returns the top three standard dish image feature vectors in the retrieval library with the highest similarity to the dish feature vector. If the filtering condition sets the retrieval quantity to five, the retrieval algorithm returns the top five standard dish image feature vectors in the retrieval library with the highest similarity to the dish feature vector.

[0127] As another implementation, the filtering condition may also be a similarity value, that is, the returned standard dish image feature vector is determined by setting a minimum similarity value. If the filtering condition sets the minimum similarity value to 0.98, the retrieval algorithm searches the retrieval library based on the dish feature vector and returns the standard dish image feature vector with a similarity value of more than 0.98 to the dish feature vector.

[0128] As another implementation, the filtering condition may also be a combination of a similarity value and a search quantity. If the filtering condition sets the minimum similarity value to 0.98 and the search quantity to five, the search algorithm searches the search library based on the dish feature vector and returns the standard dish image feature vectors with a similarity value of 0.98 or more and the top five highest similarity values ​​with the dish feature vector. If there are less than five standard dish image feature vectors with a similarity value of 0.98 or more, the similarity value is given priority. For example, if there are three standard dish image feature vectors with a similarity value of 0.98 or more, three standard dish image feature vectors with a similarity value of 0.98 or more are returned.

[0129] As another implementation, if the filtering condition sets the minimum similarity value to 0.98 and the number of searches is five, but the search finds that there are less than five standard dish image feature vectors with similarity values ​​above 0.98, for example, there are three standard dish image feature vectors with similarity values ​​above 0.98, then three standard dish image feature vectors with similarity values ​​above 0.98 and two standard dish image feature vectors with the highest similarity below 0.98 are returned. However, when returning the standard dish image feature vectors, the two standard dish image feature vectors with similarity below 0.98 are distinguished from the three standard dish image feature vectors with similarity values ​​above 0.98. The distinction may be made by color or text marking, which is not specifically limited here.

[0130] Furthermore, the dish category can be obtained through the label data carried by the returned standard dish image feature vector. It can be understood that if five standard dish image feature vectors are returned, there are five corresponding dish categories. When the dish category is returned, the similarity value can be used as the probability of the corresponding dish category.

[0131] The dish identification method proposed in the embodiment of the present application searches the retrieval library according to the dish feature vector through a preset retrieval algorithm and filtering conditions to obtain a feature vector similarity list, wherein the feature vector similarity list includes at least one target feature vector; based on the label data of the target feature vector in the feature vector similarity list, at least one dish category corresponding to the label data is obtained. The present application can obtain at least one dish category corresponding to the dish feature vector according to the set filtering conditions, thereby improving the accuracy and breadth of dish identification.

[0132] Reference Fig.13 , Fig.13 This is a schematic diagram of the overall process of the dish identification method of this application.

[0133] like Fig.13 As shown, first, obtain the dish image through a camera or other photographic equipment; then send it to the dish detection model to obtain the position of a single dish, and crop it, then extract features from the cropped dish image to obtain a feature vector of at least one dish image, and finally, compare the obtained feature vector with the feature vector stored in the retrieval library to find the most similar feature, thereby obtaining the dish category and the score (similarity value) of the corresponding dish category, wherein the feature vector stored in the retrieval library can be obtained by extracting the feature vector of the standard dish image.

[0134] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the dish identification method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0135] This application also provides a dish identification device, please refer to Fig.14 , the dish identification device comprises:

[0136] A target dish image acquisition module 10 is used to acquire a target dish image;

[0137] A dish feature vector extraction module 20 is used for extracting features of the target dish image using a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function;

[0138] The vector search module 30 is used to search the dish feature vector through a preset search library to obtain the dish category.

[0139] Optionally, the target dish image acquisition module 10 is further used for:

[0140] Get the initial dish image;

[0141] Determining a dish position of at least one dish in the initial dish image based on a preset dish detection module, wherein the dish detection module is composed of a PP-PicoDet model;

[0142] The initial dish image is cropped according to the dish position to obtain at least one target dish image.

[0143] Optionally, the dish recognition device further includes a model optimization module 40, and the model optimization module 40 is used to:

[0144] Based on the preset cross entropy loss function and the preset triplet loss function, the preset PP-LCNetV2 model is optimized to obtain the optimized convolutional neural network model.

[0145] Optionally, the dish identification device further includes a search library construction module 50, and the search library construction module 50 is used to:

[0146] Get standard dish images;

[0147] Based on the optimized convolutional neural network model, feature extraction is performed on the standard dish image to obtain a feature vector of the standard dish image;

[0148] A retrieval library is constructed according to the standard dish image feature vector.

[0149] Optionally, the search library construction module 50 is further used for:

[0150] The standard dish image feature vectors are stored and a retrieval library is constructed by using the preset Faiss library tool and IndexFlatIP indexing algorithm.

[0151] Optionally, the vector retrieval module 30 is further used for:

[0152] Using a preset search algorithm, searching the search library according to the dish feature vector to obtain a target feature vector;

[0153] The dish category is determined according to the label data of the target feature vector.

[0154] Optionally, the vector retrieval module 30 is further used for:

[0155] By using a preset search algorithm and screening conditions, the search library is searched according to the dish feature vector to obtain a feature vector similarity list, wherein the feature vector similarity list includes at least one target feature vector;

[0156] According to the label data of the target feature vector in the feature vector similarity list, at least one dish category corresponding to the label data is obtained.

[0157] The dish identification device provided in the present application adopts the dish identification method in the above-mentioned embodiment, which can improve the accuracy of identifying dishes. Compared with the prior art, the beneficial effects of the dish identification device provided in the present application are the same as the beneficial effects of the dish identification method provided in the above-mentioned embodiment, and other technical features in the dish identification device are the same as the features disclosed in the above-mentioned embodiment method, which will not be repeated here.

[0158] The present application provides a dish identification device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the dish identification method in the above-mentioned embodiment one.

[0159] Reference below Fig.15 , which shows a schematic diagram of the structure of a dish recognition device suitable for implementing the embodiment of the present application. The dish recognition device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.15 The dish identification device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0160] like Fig.15 As shown, the dish recognition device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the dish recognition device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the dish identification device to communicate wirelessly or wired with other devices to exchange data. Although the dish identification device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0161] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0162] The dish recognition device provided by the present application adopts the dish recognition method of the above embodiment to improve the accuracy of identifying dishes. Compared with the prior art, the beneficial effects of the dish recognition device provided by the present application are the same as the beneficial effects of the dish recognition method provided by the above embodiment, and other technical features in the dish recognition device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0163] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0164] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0165] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the dish identification method in the above-mentioned embodiment.

[0166] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0167] The computer-readable storage medium may be included in the dish recognition device; or may exist independently without being assembled into the dish recognition device.

[0168] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the dish recognition device, the dish recognition device: obtains a target dish image; extracts features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, and the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function; retrieves the dish feature vector through a preset retrieval library to obtain a dish category.

[0169] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0170] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0171] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0172] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned dish recognition method, and can improve the accuracy of identifying dishes. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the dish recognition method provided in the above-mentioned embodiment, and will not be repeated here.

[0173] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A dish identification method, characterized in that: The dish identification method comprises: Obtain the target dish image; Extracting features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function; The dish feature vector is searched through a preset search library to obtain the dish category.

2. The method according to claim 1, characterized in that The step of obtaining the target dish image comprises: Get the initial dish image; Determining a dish position of at least one dish in the initial dish image based on a preset dish detection module, wherein the dish detection module is composed of a PP-PicoDet model; The initial dish image is cropped according to the dish position to obtain at least one target dish image.

3. The method according to claim 2, characterized in that The step of extracting features from the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function, comprises: Based on the preset cross entropy loss function and the preset triplet loss function, the preset PP-LCNetV2 model is optimized to obtain the optimized convolutional neural network model.

4. The method according to claim 3, characterized in that The step of obtaining the target dish image includes: Get standard dish images; Based on the optimized convolutional neural network model, feature extraction is performed on the standard dish image to obtain a feature vector of the standard dish image; A retrieval library is constructed according to the standard dish image feature vector.

5. The method according to claim 4, characterized in that The step of constructing a retrieval library according to the standard dish image feature vector comprises: The standard dish image feature vectors are stored and a retrieval library is constructed by using the preset Faiss library tool and IndexFlatIP indexing algorithm.

6. The method according to claim 5, characterized in that The step of searching the dish feature vector through a preset search library to obtain the dish category includes: Using a preset search algorithm, searching the search library according to the dish feature vector to obtain a target feature vector; The dish category is determined according to the label data of the target feature vector.

7. The method according to claim 5, characterized in that The step of searching the dish feature vector through a preset search library to obtain the dish category includes: By using a preset search algorithm and screening conditions, the search library is searched according to the dish feature vector to obtain a feature vector similarity list, wherein the feature vector similarity list includes at least one target feature vector; According to the label data of the target feature vector in the feature vector similarity list, at least one dish category corresponding to the label data is obtained.

8. A dish identification device, characterized in that: The dish identification device comprises: A target dish image acquisition module, used to acquire a target dish image; A dish feature vector extraction module, used to extract features of the target dish image based on a convolutional neural network model to obtain a dish feature vector, wherein the convolutional neural network model is optimized by a cross entropy loss function and a triplet loss function; The vector retrieval module is used to retrieve the dish feature vector through a preset retrieval library to obtain the dish category.

9. A dish recognition device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the dish identification method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the dish identification method according to any one of claims 1 to 7 are implemented.