Skip to content

Food recognition system for raw cooking ingredients (i.e. fruits, vegetables, etc.)

Notifications You must be signed in to change notification settings

samirkt/raw_food_recognition

Repository files navigation

# RAW FOOD IMAGE RECOGNITION #


### DESCRIPTION ###

This code base enables a user to download raw food images using URLs from ImageNet and train a fine-tuned MobileNet model on the acquired data for object recognition. This README offers a description of the files contained in this repository and their outputs as well as a walkthrough of its usage.


### PROJECT CONTENTS ###

Data:
All scripts are in the root directory. Data is initially stored in 'data/train/' after running download script or unzipping raw data file. After removing corrupt images, part of data can be split into training and validation sets (SEE "USAGE"). Validation data is stored in 'data/val/'. The final result of unpacking and cleaning the data is as follows:

data
|
---- train
|	|
|	---- class1
|	|
|	---- class2
|
---- val
	|
	---- class1
	|
	---- class2

Training:
Training will save each trained model to a *.h5 file in the 'models/' directory. The model will be saved as 'modelX.h5' where X is the lowest unused number in the 'models/' directory. Model hyperparameter settings will be appended to 'models.txt'. Training outputs will be saved to model specific files in the 'outputs/' directory. Training is performed using the 'train.py' script (SEE "USAGE").

Testing:
Testing will accumulate stats for a model's performance on the validation set on a per-class basis. Per-class accuracies, total accuracy, and total RMSE for the tested model will be appended to 'results/all_results.txt'. Testing is performed using the 'test.py' script (SEE "USAGE").

Predicting Files:
A model can be tested more thoroughly with the 'predict_all.py' script (SEE "USAGE"). In this script, all training and validation images are passed through a model. The names of all correctly classified files will be saved in a file called 'correct.txt' inside the directory 'results/modelX/' where X applies to the model number. The incorrectly classified files will be stored similarly in a file called 'incorrect.txt'. The prediction code will also report the performance statistics described in the "Testing" section above for both the training and validation data. These statistics will be stored in a file called 'performance.txt' in the same model-specific directory where 'correct.txt' and 'incorrect.txt' are located.


### USAGE ###

#### Get URLS ####
1. Download full URLs file for imagenet dataset:
		http://image-net.org/download-imageurls
		(save as 'original_urls.txt')
2. gcc urls_to_csv.c					// converts URLS to comma separated format

#### Get images ####
3. python download_images.py			// downloads URLS from 'urls.txt'
	(...or unzip raw_data.zip)

#### Organize data ####
4. python remove_corrupt.py data/train/		// removes images that can't be opened in 'data/'
5. python split_data.py data/				// creates validation image set from images in 'data/train/'

#### Train model ####
6. python train.py data/					// train on images in 'data/'

#### Test model ####
7. python test.py data/ x					// test model number x

#### Predict all data ####
8. python predict_all.py data/ x			// classify all training and validation data with model x

About

Food recognition system for raw cooking ingredients (i.e. fruits, vegetables, etc.)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published