Machine Learning for Asian food recognition – Part 1
A couple of months ago I was transferred to Singapore. Since the first day of my life here, I fell in love with amazing local food. It’s just awesome – dozens of cuisines, huge variety of meals, everyone can find whatever he wants. Food paradise if you wish…
But there is one problem… I have no idea how to remember the name of the meal that I just finished. Also, it’s quite difficult to make a choice when I’m travelling – not each food court has English menu.
And during one of my trips, I had got the idea – what if I had the application, which would be able to recognize the meal from the photo that I just took from the menu. Or the photo I had in the memory of my phone.
Please check the following links before reading the rest of the article:
- Create a Cloud Foundry Account
- Install the Cloud Foundry Command Line Interface (CLI)
- Use the Image Classification API from a REST Client
For instance, on the picture below you can see well-known in Southeast Asia soup – Laksa
Hope you are not hungry because it’s not the last delicious photo for today ?
Let’s try to upload this picture to Machine Learning Image Classification API.
24% that this is broccoli, 22% for consomme and 20% that this is soup… Seems like model also isn’t good enough in Asian food. Okay, then we need to train it a little bit.
Let’s start small and focus on soups. For the model I’ve chosen 5 soups:
- Laksa (Southeast Asia)
- Tom Kha Gai (Thailand)
- Ramen (Japan)
- Bakso (Indonesia)
- Borscht (Ukraine, just in case I forget how it looks like).
More photo of soups:
For the model we need to create test(10%), training(80%) and validation(10%) sets. I googled a lot and prepared 71 photo of each soup:
- Training – 56 photos
- Test – 7 photos
- Validation – 7 photos
- Try (to try the model) – 1 photo
Dataset is ready, we need ML instance. In Cloud Foundry cockpit, on the navigation side bar click on Service Marketplace and select ml-foundation-trial-beta
On the navigation side bar click on Instances and then New Instance
No params required, instance name – soups
Instance has been created, in order to send commands from CLI we need to get Service Keys. On the navigation side bar click Service Keys. Create Service Key button, name soups-key
Instance is ready. Let’s upload dataset, train the model and deploy it.
Open the terminal and log in to Cloud Foundry using command “cf login”
Config the instance using params from the service key.
Upload test, validation and training data sets to Cloud Foundry
Prepare simple configuration file for the training job:
And trigger the job, checking it while it’s not successfully finished.
Finally, deploy retrained model
Okay, model is deployed and ready. Now, let’s try the same image to test:
Cool, more than 78%. I used relatively small dataset, therefore result isn’t perfect, but still good.
In the next blog I will create the app and test it at the food court!
Very nice and interesting blog. The soups pictures are awesome..mouth watering:)
Awesome share - will be following this series! Now if only I could find a bowl of Laksa... </so hungry>
when using command cf sapml set auth_server......, why it gives error 'sampl' is not a registered command. See 'cf help -a' ?
try to install ML plugin - https://tools.hana.ondemand.com/#mlfoundation
Thanks. Yes it helps.
Nice Blog! This comes under supervised ML for classification scenario, correct?
This is so cool !! and very easily explained !! Thanks Alexey, I will replicate your scenario !!