A food visual recognition method for a scenario lacking training samples

By using the RER method, which employs two classifiers to erase discriminative regions and trains with soft labels, the problem of food category recognition in scenarios lacking training samples is solved, thus improving the accuracy of food visual recognition.

CN118135557BActive Publication Date: 2026-11-24CHONGQING UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410317885.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-20
Publication Date
2026-11-24
Estimated Expiration
2044-03-20

AI Technical Summary

Technical Problem

In scenarios lacking training samples, existing technologies struggle to accurately identify food categories, particularly due to model bias caused by ignoring food ingredient information or using ingredient labels.

Method used

The Region Erasure-Reactivation (RER) method is adopted, which uses two classifiers to identify different regions of food images, erases the discriminative regions, and uses soft labels to train the model to enhance the food representation.

Benefits of technology

It improves the accuracy of visual food recognition, especially when the ingredients are not obvious or invisible. It enriches food representation by learning complementary information and reduces model bias.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118135557B_ABST
    Figure CN118135557B_ABST
Patent Text Reader

Abstract

This invention relates to a food visual recognition method for scenarios lacking training samples. This method uses an adversarial erasure strategy to automatically discover components in images and learn a more comprehensive representation. The method includes two classifiers, each mining different regions of the target. First, one classifier identifies and erasures local discriminative regions on an intermediate feature map. Then, the erased features are fed into another classifier to discover complementary information about the target. Furthermore, soft labels, rather than component labels, are used to supervise the second classifier, thereby reducing model bias caused by invisible components in the samples. Experiments on two benchmark datasets, Food-101 and VIREO Food-172, demonstrate that RER outperforms state-of-the-art FSFR methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision, and in particular to a method for visual food recognition in scenarios where training samples are scarce. Background Technology

[0002] Food recognition, the task of identifying food categories from images, is an important branch of computer vision with various applications, such as health management, smart kitchens, and dietary assessment. However, food recognition also faces challenges, particularly in few-shot scenarios, where the goal is to train a model that can identify new food categories using only a small number of labeled examples. These scenarios are common in the real world, with diverse food varieties across different regions, cultures, and seasons, and collecting and labeling large-scale images of these foods is expensive and time-consuming. Therefore, exploring how to improve the performance of few-shot food recognition (FSFR) using limited data is a valuable research question.

[0003] In recent years, Few-shot Food Recognition (FSFR) has attracted increasing attention, and some pioneering works have proposed solutions to this problem. Zhao et al. used graph convolutional networks and semantic embeddings to capture relationships between food categories; however, they neglected information about the ingredients in the food. Ingredients are the building blocks of any dish and can provide important supplementary information for food recognition. For example, ... Figure 1 As shown in (a), "bruschetta" is made with tomatoes and served on hard bread. From the food image, we can clearly observe the presence of two visible components, "tomato" and "hard bread," in "bruschetta." If the model focuses only on discriminative information for classifying local regions of a sample, it may incorrectly classify the sample as one of the components, thus reducing performance.

[0004] To alleviate this problem, Jiang et al. introduced a component-supervised deep network that extracts component-oriented features and fuses them with category-oriented visual features for FSFR (Food Safety and Recognition). It effectively utilizes components to provide supplementary and discriminative information for food identification. However, collecting corresponding component labels for each food is tedious and not always available. Meanwhile, as... Figure 1 As shown in (b), some food ingredients (e.g., "lobster bisque", "pancakes" and "dumplings") are not clearly visible in the image. In such cases, using ingredient labels for hard supervision may lead to biased models. Summary of the Invention

[0005] In view of the above-mentioned problems in the existing technology, the technical problem to be solved by the present invention is: how to more accurately identify food categories.

[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: a food visual recognition method for scenarios lacking training samples, comprising the following steps:

[0007] S1: Obtain the basic dataset: Obtain several food images to construct the basic dataset. x i Let y represent the i-th food image. i y represents the unique heat category label of the i-th food image. i ∈C base C base N represents the set of categories in the underlying dataset. base This represents the total number of samples in the base dataset.

[0008] S2: Building and training the recognition model: This recognition model consists of three components: feature extraction, feature erasure, and feature reactivation.

[0009] Feature extraction: A convolutional neural network is used as a shared feature extractor, given an image. and its unique hot category tag y i ∈C base Convolutional neural networks are applied to extract their intermediate feature maps.

[0010]

[0011] Where c, h, and w represent the number of channels, height, and width, respectively, and f θ (x) represents a convolutional neural network.

[0012] Then, by using classifier Ag A Using Global Average Pooling (GAP) to obtain predicted labels Calculate predicted labels With actual label y i Between losses

[0013] Feature erasure: Before applying global average pooling (GAP), the final convolutional feature map is represented as follows: Where L×L is the spatial dimension, K is the number of channels, and M is the given class activation map. c The class activation graph c is defined as: in It is relative to category i th The weight of the c-th channel.

[0014] By M c Normalize to the range [0,1], and set a threshold through the hyperparameter σ to normalize M. c Convert to binary mask To achieve feature erasure, based on a binary mask Erase v i The distinguishable regions in the image are identified, and the feature map after erasure is obtained. Where ⊙ represents element-wise multiplication.

[0015] Feature reactivation: Classifier B g B The input is the erased feature map. Used to predict classification scores Calculate soft tags With predicted classification scores Losses between The That is, the output logits of classifier A in the previous period.

[0016] When the total loss of the recognition model When it stops changing, a well-trained recognition model is obtained.

[0017] S3: For an unknown object image, input the unknown object image into the trained recognition model to obtain the probability value of the unknown object image belonging to each unique hot category. Sort the probability values ​​in descending order and output the top-k.

[0018] As a preferred option, calculation The method is as follows:

[0019] Calculate using cross-entropy loss With y i The losses between them are expressed as follows:

[0020]

[0021] Where N represents the number of training samples in each batch, G(·) is the global average pooling, and l ce (·) represents the cross-entropy loss.

[0022] As a preferred option, when training classifier B, a "warm-up" period is set, and... This represents the epoch number of the "warm-up" period. During the "warm-up" period, when training classifier B, each sample input to classifier B uses its corresponding unique hot class label as the true label to calculate the loss.

[0023] As a preferred option, calculation The method is as follows:

[0024]

[0025] Preferably, the calculation of total loss The method is as follows:

[0026]

[0027] Compared with the prior art, the present invention has at least the following advantages:

[0028] A food visual recognition method for scenarios lacking training samples comprises two classifiers to find different regions of the target. First, one classifier identifies the most discriminative region in the sample and generates a binary mask based on the class activation map to erase the corresponding region on intermediate features. Then, the erased feature map is input into another classifier to discover complementary information in the target. This strategy encourages both classifiers to mine complementary visual information in the samples and enhances the food representation. For samples with clearly present ingredients, the method first erases the most discriminative region of the sample, then forces the recognition model to further search for remaining ingredient information in the image. For samples with invisible ingredients, the method helps the recognition model learn complementary information in the samples and enriches the food representation. Furthermore, for the erased features, soft labels are used instead of ingredient labels to supervise model training, which mitigates model bias caused by invisible ingredients in the image. Finally, the method is evaluated on two popular benchmark datasets, Food-101 and VIREOFood-172, and extensive experiments demonstrate its superiority over recent FSFR methods. Attached Figure Description

[0029] Figure 1 Example of a food image. Figure 1 (a) Example of food image misclassification. Figure 1 (b) Example of food images with indistinct ingredients.

[0030] Figure 2 : A model structure diagram of the method of this invention.

[0031] Figure 3 : Visualization of class activation graphs using different benchmark methods on the Food-101 dataset. Detailed Implementation

[0032] The present invention will now be described in further detail.

[0033] To explore more visual information in food images, we propose a simple yet efficient method for food visual recognition in scenarios lacking training samples, called "Regional Erase-Reactivation" (RER). This method uses an adversarial erasure strategy to automatically discover components in the image, enabling the learning of a more comprehensive representation. Specifically, two classifiers are designed to find different regions of the target. First, one classifier identifies the most discriminative region in the sample and generates a binary mask based on the class activation map to erase the corresponding region on the intermediate features. Then, the erased features are input into the other classifier to discover complementary information in the target. This strategy encourages both classifiers to mine complementary visual information in the samples and enhance the food representation. For samples where components are clearly present, RER first erases the most discriminative region of the sample and then forces the model to further search for the remaining component information in the image. For samples where components are not visible, RER helps the model learn complementary information in the samples and enriches the food representation. Furthermore, for erased features, soft labels are used instead of component labels to supervise model training, which mitigates model bias caused by invisible components in the image. The proposed method is evaluated on two popular benchmark datasets, Food-101 and VIREO Food-172, and extensive experiments demonstrate the superiority of the proposed RER over recent FSFR methods.

[0034] A method for visual food recognition in scenarios lacking training samples includes the following steps:

[0035] S1: Obtain the basic dataset: Obtain several food images to construct the basic dataset. x i Let y represent the i-th food image. i y represents the unique heat category label of the i-th food image. i ∈C base C base N represents the set of categories in the underlying dataset. base This represents the total number of samples in the base dataset.

[0036] S2: Building and training the recognition model: This recognition model consists of three components: feature extraction, feature erasure, and feature reactivation;

[0037] Feature extraction: Convolutional neural networks, such as ResNet and VGG, are used as shared feature extractors given an image. and its unique hot category tag y i ∈C base Applying convolutional neural networks to extract their intermediate feature maps:

[0038]

[0039] Where c, h, and w represent the number of channels, height, and width, respectively, and f θ (x) represents a convolutional neural network;

[0040] Then, by using classifier Ag A Using Global Average Pooling (GAP) to obtain predicted labels Calculate predicted labels With actual label y i Between losses

[0041] Feature erasure: Before applying global average pooling (GAP), the final convolutional feature map is represented as follows: Where L×L is the spatial dimension, K is the number of channels, and M is the given class activation map. c The class activation graph c is defined as: in It is relative to category i th The weight of the c-th channel;

[0042] By M c Normalize to the range [0,1], and set a threshold through the hyperparameter σ to normalize M. c Convert to binary mask This is used to achieve feature erasure, where the mask indicates the most distinctive region of the target. Then, based on the binary mask... Erase v i The distinguishable regions in the image are identified, and the feature map after erasure is obtained. Where ⊙ represents element-wise multiplication.

[0043] Feature reactivation: Classifier B g B The input is the erased feature map. Used to predict classification scores Calculate soft tags With predicted classification scores Losses between The That is, the output logits of classifier A in the previous period;

[0044] The training process and cross-entropy loss for classifier B are the same as for classifier A. The only difference is that we use soft labels instead of one-hot labels at this stage. Specifically, classifier B g B The input is the erased feature map. Used to predict classification scores Since we have already erased the discriminative regions in the samples based on the class activation map obtained from classifier A, continuing to use one-hot labels to guide training might introduce bias. Therefore, we use soft labels. That is, the output logits of classifier A in the previous period are used to train classifier B.

[0045] When the total loss of the recognition model When it stops changing, we obtain a well-trained recognition model;

[0046] S3: For an unknown object image, input the unknown object image into the trained recognition model to obtain the probability value of the unknown object image belonging to each unique hot category. Sort the probability values ​​in descending order and output the top-k.

[0047] Specifically, calculation The method is as follows:

[0048] Calculate using cross-entropy loss With y i The losses between them are expressed as follows:

[0049]

[0050] Where N represents the number of training samples in each batch, G(·) is the global average pooling, and l ce (·) represents the cross-entropy loss.

[0051] Specifically, when training classifier B, a "warm-up" period is set, and... Let represent the epoch number of the "warm-up" period; during the "warm-up" period, when training classifier B, each sample input to classifier B uses its corresponding one-hot class label as the true label to calculate the loss. In the early stages of training, the soft label output from classifier A is not accurate. Therefore, our method includes a "warm-up" period during which we still use one-hot class labels to guide the training of classifier B. Let Let τ represent the number of the "warm-up" period. After the "warm-up" period, the model is trained using soft labels updated by classifier A in the previous period. Therefore, the loss of classifier B can be written in the following form, where τ represents the current period in which the model is trained. Here, we empirically use τ = τ + τ. Set it to 10.

[0052] Specifically, calculation The method is as follows:

[0053]

[0054] Specifically, the calculation of total loss The method is as follows:

[0055]

[0056] Experiments and Analysis

[0057] 1. Datasets and Implementation Details: Experiments were conducted on two popular datasets: Food-101 and VIREO Food-172. Food-101 is a large-scale image dataset of Western food, containing a total of 101,000 images, divided into 101 categories, with 1,000 images per category. The number of categories used for training and testing were 71 and 30, respectively. In VIREO Food-172, there are 172 categories of Chinese food, with a total of 110,241 images. The number of categories used for training and testing were 132 and 40, respectively.

[0058] Two common neural networks (ResNet-12 and VGG-16) were used for fair comparison with recent few-shot food recognition (FSFR) studies. ResNet-12 consisted of four residual blocks with filter numbers set to (64, 128, 256, 512). VGG-16 contained five blocks with a total of 13 convolutional layers and 5 pooling layers. Classifiers A and B each consisted of three convolutional layers. The models were optimized using the SGD optimizer with a momentum value of 0.9 and a weight decay rate of 5. Initially, the learning rate was set to 0.05, decaying by a factor of 0.1 after 60 and 80 epochs, respectively. Binary masks were used. The threshold was set to σ = 0.6. Similar to previous FSFR studies, 5-way 1-sample and 5-way 5-sample classification tasks were considered. Evaluation was performed using 600 tasks randomly sampled at each run, and the average accuracy across five runs was reported.

[0059] Table 1. Food identification accuracy (in percentage) on the Food-101 dataset with few samples. Best results are shown in bold.

[0060]

[0061] Table 2. Food identification accuracy (in percentage) on the VIREO Food-172 dataset with few samples. Best results are shown in bold.

[0062]

[0063] Results of food identification with few samples:

[0064] Table 1 shows the FSFR accuracy on the Food-101 dataset using different feature extractors for 5-way 1-sample and 5-way 5-sample tasks. It can be observed that the method of this invention has significant advantages on different feature extractors and achieves the best performance on ResNet-12. Compared to the benchmark, RER achieves performance improvements in both networks, particularly in VGG-16, with performance improvements of 3.24% and 4.42% on both tasks, respectively. Furthermore, in the case of ResNet-12, RER outperforms the second-best FSFR method by 0.11% and 2.42% on the 5-way 1-sample and 5-way 5-sample tasks, respectively.

[0065] Table 2 reports the FSFR results on the VIREO Food-172 dataset. Similar to the observations on Food-101, RER remains the best-performing method. For example, when using VGG-16 for 5-way 1-sample and 5-way 5-sample tasks, RER outperforms the second-best method (MVFSL-TC) by 2.04% and 2.30% in accuracy, respectively. In ResNet-12, RER outperforms the baseline and DSFN by 0.39% and 1.58% on both tasks, respectively. These experimental results demonstrate that the method of this invention can effectively explore complementary visual information in the target object, enrich the representation, and improve the accuracy of FSFR recognition.

[0066] 2. Visual Analysis

[0067] Figure 3 Several class activation maps from Food-101 are shown to qualitatively evaluate the Recognition Efficiency Ratio (RER). The baseline method primarily focuses on local regions of the sample. Similarly, classifier A only learns local discriminative information about the target. After erasure, classifier B learns visual information different from classifier A in the reactivated regions, enriching the food representation and improving the model's recognition performance. Figure 3 As shown in rows 1 and 2, the recognition model learns complementary component information at different stages within the sample, when components are visible in the sample. For example, for the food "bruschetta," different classifiers can be used to discover its main components: "tomato" and "hard bread." For the samples in rows 3 and 4, where component information is not obvious, the recognition model explores different regions of the target to obtain more complete features. Overall, the method of this invention encourages two classifiers to learn complementary food knowledge within the sample.

[0068] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1.A food visual recognition method for a scenario lacking training samples, characterized in that: Comprising the following steps: S1: Obtain a basic dataset: Obtain a plurality of food images to construct a basic dataset , , denotes the i-th food image, denotes the one-hot class label of the i-th food image, , denotes a set of classes in the basic dataset, denotes the total number of samples in the basic dataset; S2: constructing and training an identification model: the identification model is composed of three components of feature extraction, feature erasing and feature reactivation; Feature extraction: a convolutional neural network is employed as a shared feature extractor given an image and its one-hot class label , a convolutional neural network is applied to extract an intermediate feature map thereof: (1) wherein, and n, h and w represent the number of channels, height and width, respectively, CNN represents a convolutional neural network; Then, a predicted label is obtained by using a classifier A and a global average pooling GAP , calculates a loss between the predicted label and an actual label ;​ Feature erasing: before applying global average pooling GAP, the last convolutional feature map is represented as where is the spatial dimension, is the number of channels, the class activation map for a given class is defined as: where is the weight of the th channel with respect to class . By Normalize to the range [0, 1] and pass through hyperparameters. Set a threshold, Convert to binary mask To achieve feature erasure, based on binary masks erase The distinguishable regions in the image are identified, and the feature map after erasure is obtained. ,in This indicates element-wise multiplication; Feature reactivation: classifier B The input to classifier B is the erased feature map to predict classification scores Compute soft labels The loss between the predicted classification scores and the true labels is computed i.e. the output logits of classifier A at the previous time step when the total loss of the recognition model stops changing, a trained recognition model is obtained; S3: for an unknown food image, inputting the unknown food image into the trained identification model to obtain probability values of the unknown food image belonging to each one-hot category, arranging the probability values in descending order, and outputting the top-k. 2.The food visual recognition method for a scene lacking training samples according to claim 1, wherein: The method of computing is: The cross-entropy loss is calculated as The loss between the is expressed as follows: (2) wherein represents the number of training samples per batch, is a global average pooling, while represents a cross-entropy loss. 3.The food visual recognition method for a scenario lacking training samples according to claim 2, wherein: When training classifier B, a "warm-up" period is set, and it is set the number of iterations representing the "warm-up" period; during the "warm-up" period of training classifier B, each sample input to classifier B uses its corresponding one-hot class label as the true label to compute the loss. 4.The food visual recognition method for a scene lacking training samples according to claim 3, wherein: The method of computing is: (3)。 5. The food visual recognition method for a scene lacking training samples according to claim 4, characterized in that: Calculate total loss The method is as follows: (4)。