Binary convnet for food image recognizion (Keras tensorflow)
This project answer to the need of recognize cooked dish from supplied pictures. The model is pre-trained and can be used for prediction by runing demo.py (or demo_noDisplay.py from outside a Jupyter notebook). If you're interested of how this have been done and if you speak french, please check the abstact.pdf file.
Important note: I am far to be a neural network expert so I may have done some misinterpretation, errors and my model is not perfect. I think this model can be improved by working on the data-set. Nethertheless I only had one full week to learn from scratch everything on deep learning and neural network and I think my result are prety good. I may keep working on this model and improved it so if you have advise or questions please tell!
This model is based on CatdogNet - Keras Convnet Starter by Jeff Delaney witch is already based on Building powerful image classification models using very little data from Keras blog.
The main differences are:
- The data have been adapted for the need as well as some adjustment.
- This script also do cross validation
- Always keep the best weight per epoch depending on the validation loss
- generate more trends (like ROC curve).
- Save the all model (json, weight and model) at each run
- Some refactoring
This is a binary model so I just have two classes:
- cookedDish
- notCookedDish (often called "something else")
If you wish to see how I build my data-set for each classes, please read the two .text file in cookedDishRecognizer/data-set/
I am 99.92% sure this is something else:
I am 68.02% sure this is something else:
I am 87.32% sure this is a cooked dish:
I am 96.58% sure this is a cooked dish:
- Windows 10
- Ubuntu 16.04
cd /tmp
curl -O https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
bash Anaconda3-4.2.0-Linux-x86_64.sh
source ~/.bashrc
You can check installation by running "conda list". Try to restart the terminal if it doesn't work.
conda create --name tensorflow python=3.5
source activate tensorflow #ubuntu
activate tensorflow #windows
If you want to have both, please create a new environment With gpu:
pip install tensorflow-gpu
With cpu:
pip install tensorflow
Then:
conda install scipy
conda install -c anaconda keras=1.1.1
conda install -c menpo opencv3=3.2.0
conda install jupyter
pip install matplotlib==2.0.0b4
conda install -c anaconda pandas=0.19.2
conda install -c anaconda scikit-learn=0.18.1
conda install -c conda-forge seaborn=0.7.1
Please install the dependencies:
- Tensorflow: Follow Tensorflow installation guide (choose gpu if you want)
- Keras: Follow Keras installation guide
- Python 3.5
- OpenCv3 Add graphical support:
- Jupyter
- Matplotlib To re-train model:
- pandas
- sklearn
- seaborn
git clone https://github.com/plabadille/cookedDishRecognizer
cd cookedDishRecognizer
Just add your pictures in cookedDishRecognizer/data-set/predictDemo/
This model only support .jpg and .png
Then run the demo script:
#without graphical support
source activate tensorflow
cd path/cookedDishRecognizer/
python demo_noDisplay.py
#with graphical support
source activate tensorflow
jupyter notebook
#then run demo.py in the notebook
Warning, I can't provide the data-set (to heavy and this is a study set). So you'll need to build your own. If you just want ton learn there's plenty of data-set available for this (like dogs vs cats!).
- Add pictures of your data-set in cookedDishRecognizer/data-set/train
- These pictures have to be directly in the folder and have to been name like this: _.jpg/png.
Note: You can use one of the script from cookedDishRecognizer/script to move file outside a folder and rename them automatically (the script have to be copy in cookedDishRecognizer/data-set/train). Don't forget to delete the script after.
- Add your test pictures (not validation, just for test the prediction system) in cookedDishRecognizer/data-set/test/
- Run the model (the script will work without edition but the classname will not be yours):
#without graphical support
source activate tensorflow
cd path/cookedDishRecognizer/
python cookedDishModel_noDisplay.py
#with graphical support
source activate tensorflow
jupyter notebook
#then run cookedDishModel.py in the notebook
- [
ETHZ-Food-101 data-set
](https://www.vision.ee.ethz.ch/datasets_extra/food-101/>}{ETHZ-Food-101 data-set) - [
lfw face data-set
](http://vis-www.cs.umass.edu/lfw/>}{lfw face data-set) Indoor Scene Recognition data-set
EurasianCitiesBase data-set
Visual Cognition Laboratory data-set
KTH-ANIMALS data-set
dogsVsCats data-set
Caltech256 data-set
voc2007 data-set
mirflickr data-set
Please feel free to use this model if you need or based one on it! Just cite me and this repo!
This project is licensed under the GNU License - see the LICENCE file for details