Torch demo for training squeezenet from scratch to recognize foods.
- Is a large enough dataset, however better manageable as compared to ImageNet
- Is better than MNIST
- Is bettern than cats-vs-dogs
- It is worth studying the efficiency wrt the color space
- It is very interesting to study week localization and transfer learning.
Before begin you have to setup your environment. First of all you must have allready installed, Torch and the image, optim, nn, cudnn and cunn packages. This can be done easilly via luarocks install
After installing all requirements follow these steps:
Get this repo:
git clone https://github.com/dimkastan/Torch-Train-on-food-dataset
Download and extract data
All steps are included into setup.sh . Call it using:
./setup.sh
If you are under Windows 10 OS you can use Windows 10 Ubuntu bash.
Now everything ready to start training.
Currently, only "Train from scratch" is supported. In a few weeks I will add two very basic "Transfer Learning" scenarios.
After extracting the data you can easily start training your model by calling the train.lua as follows:
th main.lua
The program will draw the Classification accuracy as well as the loss per epoch.
According to your GPU's memory you can modify the batch size. Also I would advise you to work on a SSD
Here are the accuracy plots for both train and test set (single crop)
In a few weeks I plan to add one or more of the following features:
- Perform data augmentation
- Operate in different color spaces
- Incorporate food localization
- Incorporate semantic image segmentation
For convinience here, I also provide a pretrained model (squeezenet_v1) as well as sample code demonstrating how to load and classify images.
In order to test the model run the following:
th demo_food.lua
This will crop one rectangle from apple_pie.jpg and evaluate it. Run multiple times to see how the output is affected by random crops.