Skip to content

realphongha/simple-image-classification

Repository files navigation

Simple image classification

Simple image classification with Pytorch. Currently supporting:

Backbones:

Necks:

Heads:

  • Linear

Loss functions:

  • Cross entropy
  • Focal loss

Augmentation:

  • Horizontal flip
  • Grayscale
  • Colorjitter
  • Gaussian blur
  • Perspective
  • Rotate
  • Random crop
  • Random erasing

Converting and running models in engines:

  • ONNX

to be added more soon...

Tutorial

Installation:

Clone this repo:
git clone https://github.com/realphongha/simple-image-classification.git
Go in the repo and install requirements:
cd simple-image-classification
pip install -r requirements.txt

Training:

Take the training process of the Dogs vs Cats dataset as an example.

Preparing dataset:

Your dataset should be like this:

simple-image-classification/  
  data/
    your_dataset/
      train/
        label1/
          a.jpg
          b.jpg
        label2/
          c.jpg
        ...
      val/
        label1/
          d.jpg
          e.jpg
        label2/
          f.jpg
        ...

First cd simple-image-classification and mkdir data && mkdir pretrained && cd data
Go here to get the Dogs vs cats dataset that is already rearranged like that. Unzip and put dogs-vs-cats in data.
Go here to get the pretrained weights for ShuffleNet V2 on ImageNet and put it in pretrained.

Run the command below to start training:

python train.py --config configs/customds/configs/customds/dogsvscats_shufflenetv2_none_linearcls_10eps.yaml

Evaluating:

Go to config file and specify path to model weights at TEST.WEIGHTS and run:
python val.py --config path/to/config.yaml
(Remember to set up dataset path as well).

Running inference:

See ./scripts/infer.sh and infer.py.

Exporting models:

See ./scripts/export.sh and export.py.

About

Simple image classification with Pytorch.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published