Yelp Food Identification via Image Feature Extraction and Classification

Yelp has been one of the most popular local service search engine in US since 2004. It is powered by crowd-sourced text reviews and photo reviews. Restaurant customers and business owners upload photo images to Yelp, including reviewing or advertising either food, drinks, or inside and outside decorations. It is obviously not so effective that labels for food photos rely on human editors, which is an issue should be addressed by innovative machine learning approaches. In this paper, we present a simple but effective approach which can identify up to ten kinds of food via raw photos from the challenge dataset. We use 1) image pre-processing techniques, including filtering and image augmentation, 2) feature extraction via convolutional neural networks (CNN), and 3) three ways of classification algorithms. Then, we illustrate the classification accuracy by tuning parameters for augmentations, CNN, and classification. Our experimental results show this simple but effective approach to identify up to 10 food types from images.


INTRODUCTION
Nowadays people really love taking photos, especially when they are in a fancy restaurant, in addition that smart mobile phones today are well equipped with high-resolution cameras. So, it is not a surprise that you can see there would be thousands of pictures from someone's phone album after a year. However, labeling and searching by words for these photos becomes a real hassle. For 1 Wikipedia: https://en.wikipedia.org/wiki/Yelp 2 Yelp Data Challenge: https://www.yelp.com/dataset/challenge Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for third-party components of this work must be honored. For all other uses, contact the owner/author(s). E511'18, December 2018, Bloomington, IN © 2018 Copyright held by the owner/author(s). ACM ISBN 978-x-xxxx-xxxx-x/YY/MM. https://doi.org/10.1145/nnnnnnn.nnnnnnn example, imaging you are talking with a friend about your extraordinary experience of eating a lobster in Bloomington IN, turning your phone upside down just want to share this picture, oops, you can not find it. This is because you forgot to label this picture and did not remember which day you took this picture.
Not just for personal photo album management, this issue raises astonishing importance for companies like Yelp, which does showing and researching business reviews. Digital photos identification poses a hard problem for those companies which rely on users' uploaded photos. Since they serve millions of customers and they may have billions of photos [4]. It would be almost infeasible to edit photo labels by human editors. So, it would be promising that developing some automatically identification solution for user uploaded pictures.
More formally, in this work, we would like to build a model that can automatically classify a user uploaded food photo into a set of applicable categories, and the accuracy of prediction should be beyond average human guess. We first consider using pre-trained features provided by Yelp Data Challenge and feeding them to traditional machine learning algorithms like Convolutional Neural Network, Support Vector Machine, Gradient Boosting, with crossvalidation. But unfortunately, the classification result was way below human eyeball. After double check, it becomes evident that the main issue lies on the features. As Yelp is a user-generated content platform, many pictures in our training set are vague, offtopic or mislabeled.
Given so, the decision was to do it from scratch. We carefully select 30 pictures for each class, use argumentation methods to enlarge our train set, manually extract features, finally the classification result is satisfactory.
The rest of the paper is organized as follows. Section 2 discusses some related works, some of which either address similar issues or adopt similar solution methods that are related to the content of this work. Section 3 presents the overview of our solution, machine learning models, algorithms, and et al. Section 4 and 5 show the overview of the original datasets from Yelp and our experiments of showing the effectiveness of our implementation. Finally, this paper concludes the work and discusses some advantages and limitations of the work in Section 6.

RELATED WORK
In 2015, this work from Berkeley [6] revealed that fully convolutional networks for semantic segmentation adopting AlexNet [5], VGGNet [11], and Google Net [13] can improve and simplify the state-of-art learning and inference. So, we also adopt the CNN architecture as a solution of image feature extraction, details of which can be found in Section 3. [1], which is a simpel deep learning neural network for image classification for features relying on basic processing, such as PCA, binary hashing, and blockwise histogram. While our work does not rely on PCA, we use some image augmentation techniques which can improve accuracy.

Chan et al. proposes PCANet
While Convolutional Neural Network (CNN) is a promising approach to address many problems, Maggiori et al. [7] presented an end-to-end framework, which adopts fully CNN approach to train large set of imperfect image sets with small sets of correctly labeled data sets. They demostrated this CNN architecture and its effective to classification problems. In this paper, our approach to address Yelp photo classification is similar to the extent where we mix large amount of low-confidence labeled datasets with augmentation datasets. We also use CNN for image feature extractions, in addition, we use image augmentation with xgboost and SVM classification methods comparing with direct CNN. Figure 1 presents the overall architecture of our machine learning pipeline. Our structure consists of four major steps: raw image preprocessing, image augmentation, feature extraction and classification. The raw Yelp dataset decomposes into K different clusters based on specific users' labels being chosen. Clean and correct images are filtered out manually from each cluster. After being applied different augmentation methods such as flip, rotate, scale, gaussian noise and GAN, these filtered images are mixed with both new augmented images and previous images from K clusters to form a big training dataset. A CNN is then used to extract features from the training dataset and finally we apply different classification methods such as Xgboost, SVM and MLP on those extracted features to get our classification accuracy.

Image Preprocessing
3.2.1 Image Augmentation. Given the Yelp photos are from users' uploads, most images are not directly usable to feed into Machine Learning Models. Because user uploaded images are usually taken from phone cameras with some distortion, which can largely degrade feature extraction and the final accuracy of classifications. After necessary transformations beforehand and filtering duplicates, the clean visible images seize below 10% of the overall data sets. So, we use image augmentation techniques to enlarge our data sets in order to build accurate models. Some augmentation techniques used in our project are listed below: 1) Flip: Images are flipped both vertically and horizontally.
3) Scale: Because camera photos are usually take not far from objects, we scale images both outward and inward by only 10%. 4) Gaussian Noise: We place random black and white pixels over images to simulate Gaussian noise. 5) Generative Adversarial Networks (not used but ideally works): The overall idea behind GANs is that you have two models playing with each other. As Ian Goodfellow describes it: one is a counterfeiter trying to produce seemingly real data while the other is a cop trying to determine what the fake counterfeit data is while trying to not raise false positives on real data, and in this way we can train neural networks to generate plausible data using a zero sum game.
More specifically, in this work, we apply the above techniques and generate 32 times of augmented images.

Convolutional Neural Network
Convolutional Neural Network (CNNs or ConvNets) are a category of feed-forward neural networks that are commonly used in areas such as image recognition and classification. They take advantage of spatial coherence between nearby elements from inputs, which allows them to have fewer weights as some parameters are shared. CNNs are composed of a number of convolutional and subsampling layers followed by pooling layers and fully connected layers. In this way, CNNs can easily transform the origin picture's pixel values into final scores with relatively low computation cost based on fewer parameters in the hidden layer.

Image Feature Extraction
Keras [9] as an open source library provides a set of state-of-theart deep learning CNN models with pre-trained weights on Ima-geNet [8]. These pre-trained models such as VGG16 [11], ResNet50 [3] and InceptionV3 [12] can be used for image feature extraction.
In order to show the effective of our prepared images for augmentation, we study Silhouette coefficient in KMeans clustering algorithm. Figure 2 presents the Silhouette analysis results base on how many clusters can be selected from our prepared images for augmentation. In this figure, x-axis values are the number of clusters y-axis values are silhouette coefficient accordingly. The silhouette scores of VGG16 (blue bars) shows that using 10 clusters can obtain the highest scores, ResNet50 (red bars) shows also 10 clusters will get the highest scores and InceptionV3 (yellow bars) shows 8 will get the highest scores following by 10. The majority of models show their highest scores around 10 clusters , which means our ten types of food images are effective.
Due to the reason that VGG16 has less weight layers and perform relatively faster and more stable around 10 clusters, we utilize VGG16 as a CNN model to extract features from our original datasets and new augmented datasets. We restrict the input size of images as 64X64 to boost our training speed and the final output of features has a dimension of 2048.
The Silhouette Coefficient used to valida k clusters is defined as follow: b − a max(a, b) , in which the Silhouette Coefficient is calculated using the mean intra-cluster distance (a) and the mean nearest-cluster distance (b) for each sample. [10] 3.5 Image Classification 3.5.1 Xgboost. Gradient Boosting We tried gradient boost for this problem, specifically we used XGBoost, which is an implementation of gradient boosted decision trees designed for speed and performance. [2] 3.5.2 Support Vector Machine (SVM). Support Vector Machine (SVM) is a supervised machine learning algorithm which can be used for both classification or regression challenges. we plot each   We applied SVM with a linear kernel and RBF kernel on the data set. In order to get better performance, we also use grid search method to tune the C value.

Radial Basis Function kernel. Radial Basis Function kernel
(RBF) is a kernel function which extends to patterns that are not linearly separable by transformations of original data to tap into new space, defined as follow:

Multilayer Perceptron.
Neural network is a series of algorithms that endeavors to recognize underlying relationships in a set of data through a process that mimics the way the human brain operates. Neural networks can adapt to changing input so the network generates the best possible result without needing to redesign the output criteria.

Cross Validation.
Considering there is no ground truth dataset for testing, we use the training set splits for both training and testing. In our three classification methods, all tests are tuned to take 70% as training sets and 30% as testing sets.

DATASETS AND FEATURES
Yelp publishes over 280,000 pictures from over 2000 businesses, the dataset of which can be found on the Yelp Data Challenge Website [4]. This dataset consists of inside, outside, drink, and food photos. Yelp has labeled the above four categories, while subcategories for specific types of food are missing. Most photos are uploaded either by customers or business owners. These photos may have valid captions, which are correctly descriptions to corresponding photos. There are many photos which do not have any captions or have incorrect captions. For example, a restaurant which sells both burgers and sandwiches tends to write both "burger" and "sandwich" for burger photos and sandwich photos for better marketing.
In summary, there is no ground truth labeled image sets. Figure 3 shows a few representative sample photos. Most food images contain noisy background, including tables, plates, chefs, and etc. Some food images contain more than two kinds of food. So, the baseline accuracy of classification is lower than 40% because of in-perfect word captions from users.

Figure 3: Representative sample photos from Yelp
To isolate the scope of this work and increase the accuracy, initially, we select photos based on observations and keywords from rural user captions. According to our observations, the top ten most popular types are covered: 1) Burger, 2) Cake, 3) Chips, 4) Noodles, 5) Pizza, 6) Roll, 7) Salad, 8) Sandwich, 9) Steak, and 10) Wings. These ten categories are, comparatively, simpler and clearer to identify, so in this work we use them for the classification task.

Evaluation Metrics
The evaluation metrics for our experiment is the prediction accuracy. This accuracy comes from the fraction of data for which the classification algorithm correctly predicted if it can be labeled with the attribute or not. Specifically, for our photo dataset, we would be analyzing the accuracy for all the validation sets of raw k clusters' dataset, augmented dataset and mixing dataset. After manually selecting the images with correct labels, we come up with a very small but relatively clean dataset with 10 selected labels. Each of cluster contains 30 images. Due to the ineffectiveness of small training data, we apply image augmentation to every image and enhance one image into 32 augmented images. Therefore, the size of clean dataset increases from 10 × 30 to 10 × 30 × 32. For the image feature extraction, we used VGG16 as a CNN model to extract image to the dimension of 2048.

Experiments
For each method of classification, we utilized toolboxes for a simple and quick test. In SVM method, we chose RBF kernel with the relative parameter to do the non-linear transformation to the dataset. For MLP method, we created a five layer nerual network with two dropout layer and three activation layer. Considering the output layer result should be in the range of 0 to 10, we selected the activation function of final layer to be RELU. The first and the second activation layer are with RELU and sigmoid function. Between each activation layer, a drop out layer is applied to prevent overfitting and gradient boosting.
All the experiments except SVM were trained on GeForce GTX 960 GPUs. MLP took about 10 minutes to train 1000 epochs on each dataset and XGboost also took not more than 10 minutes. However, because our toolbox for SVM did not supply GPU computing, instead, we ran SVM on school's machine with 64 cores CPU. It took around 2 hours to train the raw dataset and over 6 hours to train the mixing dataset.

5.
3.1 Image Feature Extraction. The augmentation set has a total dimension of 9280 × 2048, the raw training set has a dimension of 4829 × 2048 and the mixing set has a dimension of 14109 × 2048.
After doing cross validation to each set, we got our testing sets which are in the dimension of 1856 × 2048 for aug, 966 × 2048 for raw and 2822 × 2048 for mix respectively.

Image Classification.
In order to avoid overfitting, we perform cross validation. It's very similar to train/test split, but creating more subsets. Meaning, we split our data into k subsets, and train on k-1 one of those subset. What we do is to hold the last subset for test. We perform such operation for each of the subsets. Table 1 shows the testing accuracy of each classification method. Clearly, before augmentation, our classification algorithms perform poorly and even way below human eyeball. While in our mixed data set, the Support Vector Machine achieves accuracy around 68.49%, pretty closes to our expectation.

DISCUSSIONS, CONCLUSIONS AND FUTURE WORK
As we tested k cluster validation with KMeans algorithms, the range of k varies from 4 to 12 by using three Image Model via transfer learning: VGG16, resnet20, and inceptionv3. All of them show effectiveness on our training sets. However, due the limitation of time and computing resources, we can only extract features with VGG16, even though incpetionv3 may produce better features. Even after manually select small sample images from the datasets and augmentation, there are still no ground truth datasets for training. This is mainly due to user uploaded pictures can be very vague and business owners tend to add more irrelevant captions for pictures as many as possible. All these facts can result in a less accurate design of our CNN for features extraction and classification, in which pooling and dropout layers may be not well studied.
The main contribution of this paper is, given low confidence about the quality of the training datasets, image augmentation shows its effectiveness, comparing the classification accuracy of before applying this technique and after. The training accuracy for 10 types of food can be as low as 28% in a multi-layer perceptron. However, after augmentation, the accuracy of classification can be as high as around 70%.
Furthermore, it would be interesting to see some more novelty augmentation methods in application, for example, "style transfer" can be used to augment data in situations where the available data set is unbalanced. Also, business-related metrics such as user comments, the numbers of likes, are supposed to be beneficial to the increasing the classification accuracy.