Simple image classification with Pytorch. Currently supporting:
- Linear
- Cross entropy
- Focal loss
- Horizontal flip
- Grayscale
- Colorjitter
- Gaussian blur
- Perspective
- Rotate
- Random crop
- Random erasing
- ONNX
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
Take the training process of the Dogs vs Cats dataset as an example.
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
.
python train.py --config configs/customds/configs/customds/dogsvscats_shufflenetv2_none_linearcls_10eps.yaml
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).
See ./scripts/infer.sh
and infer.py
.
See ./scripts/export.sh
and export.py
.