Skip to content

mehedihasanbijoy/imgclassifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imgclassifier

It is a naive image classifier developed on top of PyTorch. One can train a model and evaluate the performance of the model on a custom dataset by simply calling the train function of this package. An overview of image classification using imgclassifier is available on YouTube.

Current Version: 0️⃣.0️⃣.2️⃣

✔️ Available backbones: ➖ default (resnet18) ➖ alexnet ➖ vgg11 ➖ vgg13 ➖ vgg16 ➖ vgg19 ➖ resnet18 ➖ resnet34 ➖ resnet50 ➖ resnet101 ➖ resnet152 ➖ densenet121 ➖ densenet161 ➖ densenet169 ➖ densenet201 ➖ mobilenet_v2 ➖ mobilenet_v3_large ➖ mobilenet_v3_small ➖ mnasnet1_0 ➖ mnasnet0_5 ➖ shufflenet_v2_x1_0 ➖ resnext101_32x8d ➖ resnext50_32x4d.

✔️ Available Directory Structures: ➖ ImageFolder ➖ Custom.

ImageFolder Custom

Dataset
├── Train
        └── classes
                └── images
├── Validation
        └── classes
                └── images
├── Test
        └── classes
                └── images

Dataset
└── Classes
        └── images

✔️ Evaluation Criteria: ➖ Precision ➖ Recall ➖ F1 Score ➖ Accuracy.

Installation

!pip install git+https://github.com/mehedihasanbijoy/imgclassifier.git

Usage

Train and test the model using "Custom" directory structure

from imgclassifier import train

model, train_acc, train_loss, test_acc, targets, preds = train(
    data_root='/Your/Dataset/Path', 
    folder_structure='Custom', 
    df = df,
    backbone='resnet18',
    transform = transform,
    device='cuda' if torch.cuda.is_available() else 'cpu', 
    epochs=10
)

Train and test the model using "ImageFolder" directory structure

from imgclassifier import train

model, train_acc, train_loss, test_acc, targets, preds = train(
    data_root='/Your/Dataset/Path', 
    folder_structure='ImageFolder', 
    backbone='resnet18',
    device='cuda' if torch.cuda.is_available() else 'cpu', 
    epochs=10
)

Evaluation of the method using Precision, Recall, F1 Score, and Accuracy

from imgclassifier import evaluation_report

pr, re, f1, acc = evaluation_report(targets, preds)

Example Notebooks

Bangla Handwritten Character Recognition using imgclassifier

https://colab.research.google.com/drive/13pu3Mw7FVPGV-f_g2VhVOMiE-wrhPo3F?usp=sharing

Animal Classification using imgclassifier

https://colab.research.google.com/drive/1BKg0sFqQsatqQUMT73KrRavhRYLPqsab?usp=sharing

Cite The Repository

If you find this work useful in your research, please consider citing:

@misc{imgclassifier,
  author = {Bijoy, Mehedi Hasan},
  title = {imgclassifier: A Python Library for Image Classification},
  year = {2022},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/mehedihasanbijoy/imgclassifier}}
}