Image Classification library built on top of Keras. Identifies the best set of hyperparameters and train a classification model accordingly, hence, smart.
MIT License
SMart Image Classifier (abbreviated and named as SMIC) is a deep learning library built on top of keras using the TensorFlow backend for building models for image classification. Specialities of this library:
It is advised that you use a GPU for training your models, as it might take days using a CPU.
Current implementation of the library depends on the following:
1. tqdm
2. pandas
3. numpy
4. opencv-python
5. tensorflow
6. h5py
7. keras==2.0.9
Please make sure that the requirements are satisifies.
Requirements can be installed by pip install -r requirements.py
This package can be installed by
pip install smic
and you're done.
The train and test images should be put in seperate directories. The required data format is,
/path/to/data/folder/
|---->train
|----|----->trainImage1 #Image names can be anything
|----|----->trainImage2
|----|----->trainImage3
|----|----->___so on___
|---->test
|----|----->testImage1 #Image names can be anything
|----|----->testImage2
|----|----->testImage3
|----|----->___so on___
|---->trainLabels.csv #Contains records in `"trainImage1","cat"` format
|---->testLabels.csv #Contains records in `"testImage1","dog"` formmat
Building an image classification model is made really easy.
from smic import SMIC
clf = SMIC()
clf.prepare_train_data('/path/to/data/folder')
hyperparameters = clf.search_optimal_parameters()
clf.fit(hyperparameters, epochs = 50, batch_size=32)
hyperparameters
is a dict returned by search_optimal_parameters()
and contains the hyperparameters that seem to work best for the current task at hand.
If you want you can use your own hyperparameters; skip line [4] and create your own hyperparameters dict like
hyperparameters = {'transfer_model' : 'vgg16', 'optimizer' : 'sgd',
'top_layers' : [['dense', 512, 'relu'],['dense', 512, 'relu']]}
Pass this dict as an argument to .fit()
.
'transfer_model' : ['vgg16', 'vgg19', 'resnet50', 'inception_v3']
'optimizer': ['sgd', 'rmsprop', 'adam']
'top_layers': A list of all the layers that you want to add on top of the pre-trained CNN.
Eg: [['dense', 512, 'relu'],['dense', 512, 'relu'],...]
Here 'dense' is the type of layer, 512 is the output dimension and
'relu' is the activation function.
Train
|--->Cat
|--->|----catImage1
|--->|----catImage2
|--->|----......
|--->Dog
|--->|----dogImage1
|--->|----dogImage2
|--->|----......
.............