Skip to content

Asad-Ismail/fruits-classfication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fruits-classfication training and deployment (Tensorflow 2.x)

Goal

The purpose of this repo is to provoide complete pipeline from training to deployment in local machine as well as Amazon sagemaker and deployment of trained model in some embedded hardware like Rasberrypie using cpp and tflite as well as in cloud using amazon sagemaker.

Features

  1. Train, Prediction and Evaluation scripts for classifcation model
  2. Conversion from tensorflow model to tensorflow lite
  3. cpp files to use tensorflow lite model with option of using CPU or GPU delegates (The script can be used in some embedded device for inference)
  4. Model training and deployment in AWS sagemaker for cloud training and deployment

The repostiry contains tensorflow implementation of fruits 360 classification dataset which contains 131 coategories of fruits (https://github.com/Horea94/Fruit-Images-Dataset)

Example images from dataset

r_67_100 50_100 65_100 244_100

Training

  1. Download the dataset from the above link
  2. To train the model python train.py --train_dir [path to train set] --test_dir [path to test set] --out_dir [path to output dir]

Results

After 30 epochs Inception V3 model achieves 99.418% accuracy on test set

Infer on image

To test on one image python pred_one.py --weights [path to weight file] --input [path to input image]

Conversion to tflite model

To convert to tflite model python convert_to_tflite.py --weights_dir [path to .hdf5 file] --test_dir [path to test set]

Testing tf model@ x86 Intel G4550, GTX1080TI

size

Run time performance

See cpp-inference for cpp inference files

  1. cpp inference (XNNPACK delegate for CPU)(1 thread)

inference

  1. cpp inference (GPU delegate)(cpu 1 thread)

cpp

For more detailed benchmarking see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/tools/benchmark