Deep Convolutional Generative Adversarial Network Based Food Recognition Using Partially Labeled Data
Bappaditya Mandal N. B. Puhan Avijit Verma




Vol. X, No. X, XX XXXXXXXXXXX



Sensor Applications








































Manuscript received XX XX, XXXX









Traditional machine learning algorithms using hand-crafted feature extraction techniques (such as local binary pattern) have limited accuracy because of high variation in images of the same class (or intra-class variation) for food recognition task. In recent works, convolutional neural networks (CNN) have been applied to this task with better results than all previously reported methods. However, they perform best when trained with large amount of annotated (labeled) food images. This is problematic when obtained in large volume, because they are expensive, laborious and impractical. Our work aims at developing an efficient deep CNN learning-based method for food recognition alleviating these limitations by using partially labeled training data on generative adversarial networks (GANs). We make new enhancements to the unsupervised training architecture introduced by Goodfellow et al. (2014), which was originally aimed at generating new data by sampling a dataset. In this work, we make modifications to deep convolutional GANs to make them robust and efficient for classifying food images. Experimental results on benchmarking datasets show the superiority of our proposed method as compared to the current-state-of-the-art methodologies even when trained with partially labeled training data.



Generative Adversarial Network, Deep CNN, Semi-Supervised Learning, Food Recognition.












Deep Convolutional Generative Adversarial Network Based Food Recognition Using Partially Labeled Data
    Bappaditya Mandal1, N. B. Puhan2 and Avijit Verma2
1School of Computing and Mathematics, Keele University, Staffordshire ST5 5BG, United Kingdom.

2School of Electrical Sciences, Indian Institute of Technology, Bhubaneswar, Odisha 751013, India.

Corresponding author: B. Mandal (e-mail: b.mandal@keele.ac.uk).

    December 30, 2023
===========================================================================================================================================================================================================================================================================================================================





§ INTRODUCTION AND RELATED WORK


A substantial increase has been witnessed in the health consciousness amongst masses due to increasing health risks. Diabetes, obesity and cholesterol cases are being increasingly reported every year. World Health Organisation (WHO) has reported that the global prevalence of diabetes has doubled over 1980 to 2014 <cit.>. Improper diet and excessive calorie intake have been major factors causing these health risks and hence keeping a check on the calorie consumption can help avoid this risk <cit.>. With the advent of smart devices, apps for multi-modal data logging mechanism, which can be used anywhere and anytime are in high demand. At present, the existing mobile apps like MyFitnessPal <cit.>, LoseIt <cit.> and others work on manual data entry. This is cumbersome for most people hindering the long-term usability of such apps. Mobile cameras are used to capture image/video data and then typically rely on expert nutritionists to analyze the image offline (at a particular time) <cit.>. Crowd sourcing has also been used as an approach to analyze the food images. However, both these methods are costly, inefficient and slow; thus, they are not suitable for widespread usage.

Appearance of any food is highly characterized by the recipe, ingredients used, style of preparation and others. They exhibit large intra-class variation in terms of size, color, shape, texture, viewpoint and others <cit.>. In this case, classic feature descriptors like speeded up robust features (SURF), histogram of gradient (HOG), spatial pyramidal pooling, bag of scale invariant feature transform (SIFT), color correlogram, etc. can only succeed when used for laboratory generated small datasets. Even popular subspace learning algorithms <cit.> follow the similar trend. Typically, a SVM is trained using these extracted features or a combination of these features <cit.>. To improve accuracy for this task, researchers have worked towards estimating the region of the image in which the food item is present. One way to do this is to use standard segmentation and object detection methods or ask the user to input a bounding box giving this information as done in <cit.>. Another approach is to use convolutional neural network (CNN) based semantic segmentation, which has shown an increase in accuracy <cit.>. Some approaches use ingredient-level features to recognize the food items <cit.>. Pairwise statistics of local features have also been applied for food recognition task <cit.>.

Deep CNN learning algorithms overcome the drawbacks of traditional machine learning algorithms based on hand designed features. These algorithms have the inherent capability to mimic human information processing systems and work very well with images <cit.>, in many applications <cit.> including food recognition <cit.>. In the recent years, CNN based food recognition has shown excellent results even on extensive and large datasets with non-uniform background <cit.>. Recent reviews on recurrent neural networks (RNN) <cit.>, shows the similar trend for learning long-term dependencies in sequential images (video) and time-series data. A common problem to all these existing methodologies is that they would need large amount of labeled training data to perform reasonably well, which is difficult and expensive to obtain when required in large amount.




 §.§ Related Generative Adversarial Network Architectures

One of the attractive features in generative adversarial network (GAN) based modeling is that it does not require labeled data. Its learning approach is classified into generative and discriminative models: A generative model is trained to learn the joint probability of the input data and output class labels simultaneously, i.e. P(x,y). This can be used to infer the conditional distribution P(y|x) by applying Bayes rule. More importantly, the joint probability learned can be used for other purposes, such as generating new (x, y) samples. A discriminative model is trained to learn a target function that maps the input data x to a set of output class labels y. Mathematically, it approximates the conditional distribution P(y|x). While both types of models: generative and discriminative have their use cases, generative models have the ability to model the internal nature of the input data even in the absence of any labels. In our current generation real world applications, unlabelled data is abundant and easy to obtain. The cost of acquiring labeled data can sometimes be too high to justify. In such cases, generative models provide a desirable solution.

As summarized in Algorithm <ref>, the principle idea behind a GAN is to pit a discriminative framework against a generative one. Thus, the two component neural networks in a GAN, discriminative and generative, act as adversaries. The generative network is given Gaussian noise as input and is trained to generate samples indistinguishable from the real samples. The discriminator network is given both the generated fake samples and corresponding real samples and is trained to identify the fake sample. In the introductory GAN work, Goodfellow et al. <cit.> used fully connected neural networks for both the generator and discriminator. Consequently, this architecture was applied to standard image datasets for testing purposes, specifically MNIST (handwritten digits) <cit.> and CIFAR-10 (natural images) <cit.> datasets.

It is evident from the literature and benchmarking competitions that convolutional neural networks (CNNs) are extremely well suited to image data <cit.> analysis, like our case for food recognition <cit.>. Initial experiments conducted on small datasets, like CIFAR-10, showed that achieving convergence in convolutional GANs  was harder than in CNNs, with similar computational power as that used for supervised learning. One solution to this problem was to use a cascade of CNNs with a Laplacian pyramid framework presented by Denton et al. (LAPGAN) <cit.>. This essentially decomposed the generation process with the images generated in a coarse to fine manner. A group of network architectures called DCGAN (deep convolutional GAN) proposed by Radford et al. <cit.>, showed promising results on image datasets. Here, a pair of convolutional discriminator and generator networks are simultaneously trained using strided and fractionally-strided convolutions. Thus, their aim was to learn the mapping from image space to the discriminator output space (down-sampling) and also to learn the mapping from a lower dimensional latent space to the image space (up-sampling). The widespread adoption of this group of GAN architectures for a number of applications makes it a natural choice for our semi-supervised task at hand.








§ PROPOSED SOLUTION USING GANS

Our present focus is on the food recognition system that can deal with non-uniformity of the background and is extendable to out of sample test images. This would ensure that the system is robust and easy to use, the architecture has been designed for it using a semi-supervised approach as shown in Fig 1. The architecture has two parts: the Generator and the Discriminator. Although both are useful, discriminator is the network which learns the nature of the problem better and thus can be used as a multi-label classifier to recognize different food items. Below we describe our newly proposed semi-supervised GAN (SSGAN) architecture in detail.



 §.§ Semi-Supervised Generative Adversarial Networks

For a general classifier, the input is the data point x and the output is a k-dimensional vector of logits (inverse of the sigmoidal “logistic” function): φ_1, φ_2, … , φ_k, which can be used to calculate class probabilities using softmax function: p_model(y = i|x) = exp(φ_i)/∑_j=1^k exp(φ_j), where k is the number of classes. To train the model, we minimize the negative log-likelihood between p_model(y|x) and the observed labels y. We add the fake generated samples from the generator G to our dataset and also add another output class to our classifier to detect these fake samples. Now that we have k+1 classes, p_model(y = k + 1 | x) determines the probability of the input data point being fake. This formulation also provides us the capability of learning from unlabeled data, provided it can be classified under one of the k classes of real data by minimizing [-log p_model(y ϵ (1, … , k)|x)].

In case of even distribution of data points, the loss function can be decomposed into two components, θ, which is the negative log-likelihood of the label (supervised), when the data is real and δ, which is the GAN loss (unsupervised).

    L = -𝔼_x,y ∼ p_data(x,y)[ log p_model(y|x) ] 
    
        - 𝔼_x ∼ G[ log p_model(y = k+1 | x ) ].

Total loss,
L = θ + δ, where

    θ = -𝔼_x,y ∼ p_data(x,y)[ log p_model(y|x, y < k+1) ]

and

    δ = -𝔼_x ∼ p_data(x)[ 1 - log p_model(y = k+1|x) ]
     -
        𝔼_x ∼ G[ log p_model(y = k+1 | x ) ].


The outputs from the GAN discriminator network D is an estimated probability that the input image is obtained from the data generating distribution. Traditionally, this is implemented with a feed-forward network ending in a single sigmoid unit, but in this work a softmax output layer is used as one unit for each of the real classes and one fake unit for generated images. It can be seen that D has k+1 output units corresponding to [class-1, class-2, . . ., class-k, fake]. In this case, D can also act as a classifier C. We use higher granularity labels for the half of the mini-batch that has been drawn from the data generating distribution. Training is performed on the discriminator/classifier network to minimize the negative log-likelihood corresponding to the given labels.

The generator G is trained to maximize this negative log-likelihood. Our proposed SSGAN framework is summarized in Algorithm <ref>.





§ EXPERIMENTAL RESULTS AND DISCUSSIONS

We have conducted experiments on two datasets, ETH Food-101 <cit.> and Indian Food Dataset <cit.>. The experiments are performed on an NVIDIA Quadro P4000 GPU with 8GB VRAM. Our model details are: GAN type: DCGAN, Optimizer: ADAM, Activation: Leaky ReLu (in all hidden layers), Sigmoid (in discriminator's output layer). The model was run on test data simultaneously after every 100 training epochs. To address the instability of GANs while training, we have implemented feature matching by specifying a new objective for the generator side that prevents it from over training on the discriminator side, similar to as mentioned in <cit.>. Additionally, we implemented one-sided label smoothing and batch normalization for stable convergence as discussed in Salimans et al. <cit.>. In our case, the stochastic layers are zero-centered Gaussian noise, with standard deviation of 0.5 for input and 0.5 for outputs of hidden layers. During the training process, for ETH Food-101 and Indian Food datasets, we used 10% and 50% data of each of the classes as unlabeled data, respectively. For comparisons, fine-tuned deep learned models are used from the popular AlexNet <cit.>, GoogLeNet <cit.>, residual network (ResNet) <cit.>, for all the methods, procedures are used as reported in <cit.>. We also compared the new method (SSGAN) with the recently proposed Lukas et al. <cit.>, Kawano et al. <cit.>, Martinel et al. <cit.> and the ensemble of networks (Ensemble Net) in <cit.>.




 §.§ Results on ETH Food-101 Dataset

ETH Food-101 <cit.> is a database consisting of 1000 images per food class of 101 classes of most popular food categories picked up from foodspotting.com. The top 101 most popular and consistently named dishes were chosen and 750 training images were extracted. An addition of 250 test images were collected per class. While the collected test images were manually cleaned, the training images were not cleaned deliberately to retain some amount of noise. The idea is to increase the robustness of any classifier trained on the dataset. For our experiments, we follow the same training and testing protocols as discussed in <cit.>. Fig. <ref> (a) shows the accuracy vs ranks plots up to top 10 ranks, where the rank r : r ϵ{ 1, 2,..., 10 } denotes the probability of retrieving at least one correct image among the top r retrieved images. This cumulative matching curve (CMC) shows the overall performance of the proposed approach as the number of retrieved images changes. Table <ref> shows the Top-1, Top-5 and Top-10 accuracies using current state-of-the-art methodologies on this dataset.



From Fig. <ref>(a) and Table <ref>, it is evident that our proposed semi-supervised GAN (SSGAN) has outperformed consistently all the current state-of-the-art methodologies on this large real-world food dataset.





 §.§ Results on Indian Food Dataset

Indian food dataset is newly introduced in <cit.> as an extensive collection of Indian food images comprising of 50 food classes with 100 images in each class. The classes were selected keeping in mind the extensive nature of Indian cuisine. Indian food differs in terms of shape, size, color and texture and is devoid of any generalized make-up. Because of the varied nature of the classes present in the dataset, it offers the best option to test a protocol and classifier for its robustness and accuracy. It consists of images from online sources like Food Spotting, Google in addition to images captured using hand-held mobile devices. Similar to the ETH Food-101 database protocol and same protocol as that in <cit.>, we have set aside 80 food images per class for training and rest of the images are used for testing. Fig. <ref> (b) shows accuracy vs ranks plot up to top 10 ranks and Table <ref> shows the Top-1, Top-5 and Top-10 accuracies using the current state-of-the-art methodologies on this dataset. Both of these show that our proposed SSGAN model performs better at recognizing food images in comparison to other CNN frameworks for this dataset. Overall, it is evident from these Figures <ref> (a) &  (b) and Tables <ref> & <ref> that our proposed approach (SSGAN) outperforms the other methods consistently for all ranks on both these datasets.




§ CONCLUSION AND FUTURE WORK

Food recognition is a very challenging task due to the presence of high intra-class variation in food appearance. This is due to the differences in method of preparation, ingredients used, various shapes, viewpoints and other factors. A classifier working well on one kind of cuisine may not give as good results on another type of cuisine. In this work, we have proposed a semi-supervised GANs based on deep convolutional neural network architecture approach to alleviate the shortcomings posed by lack of labeled images and also the classical image recognition problems in food datasets. We have performed experiments on the largest real-world food images ETH Food-101 dataset and the Indian Food dataset with partially labeled data. Experimental results show that the generative semi-supervised deep CNN approach proposed in this work outperforms the current state-of-the-art methodologies consistently for all the ranks for both the datasets even with partially labeled data. While GANs have the potential to improve the food recognition accuracy with partially labeled data, it is difficult to achieve stability and convergence during training. In future, we would try to improve the recognition accuracy with better and robust GAN architecture that could further reduce the usage of labeled training data.


























IEEEtran




