This project contains code for image recognition to see if it is possible to: 1. identify if a banana is in a photo 2. classify how ripe that banana is. For more details you can read the research paper.
Note: Extracted features files can be found in extracted_features/
, classification can be done directly on those.
To process raw images (i.e. crop, rotate, and label), run this command:
python process_raw_images.py raw_images/ processed_images/
Raw images should be in the raw_images/
folder. Within that folder there should be a folder for each class containing all the images belonging to that class. Processed images will be saved in the second argument, processed_images/
in this case, along with a classes.txt
file (dictionary containing the index to class mapping), as well as an item-labels.txt
file (another dictionary containing the image filename to class index mapping).
To extract features using a neural network, make sure you have the alexnet model installed and in a caffe/
directory adjacent to this project folder. You can customize that info in the extract_features.py
file. If you don't have the necessary model, the file will tell you what you're missing. run this command:
python extract_features.py fc8 processed_images/ features_fc8.npz
First command is where to get the features from the neural net. Second is directory of processed images, and third is where to save the result. Make sure the last file ends in .npz
To run classification on the extracted features call:
python svc.py extracted_features/features_fc8.npz
The file you pass in is the features from the previous step (or use one of the pre-extracted ones in extracted_features/
).