APE is A simPle image classification framEwork for quick and easy training/evaluation/deployment.
Codes are in the ape
folder.
train.py
is for training, test.py
is for testing accuracy using test dataset, predict.py
is for predicting the label of given images.
Configuration files are in configs
folder. Configs are python files.
- python>=3.6
- pytorch>=1.1.0
- tensorboard>=1.14.0 (better with tensorflow installed, but not required)
- joblib>=0.14.1
Datasets are loaded using torchvision.datasets.ImageFolder. Simply arrange your dataset by categories, in this way:
$DATASET_PATH/dog/xxx.png
$DATASET_PATH/dog/xxy.png
$DATASET_PATH/dog/xxz.png
$DATASET_PATH/cat/123.png
$DATASET_PATH/cat/nsdf3.png
$DATASET_PATH/cat/asd932_.png
And it will be loaded automatically.
To train the model, first define a model config, configs/model.py
for example. Then run:
python -u ape/train.py --config /path/to/your/config
# Example:
python -u ape/train.py --config configs/model.py
Note that config files should always be placed within the
configs
folder due to import mechanisms of python.
You can also resume a training process using a model checkpoint. Set resume = True
and set the checkpoint path in the config, and it will be resumed from the checkpoint.
To test the model using test dataset, run:
python -u ape/test.py --config /path/to/your/config
# Example:
python -u ape/test.py --config configs/model.py
You can use predict.py
to inference images using trained model. Run:
python -u ape/predict.py --config /path/to/your/config --path /path/to/your/images --ext <Extension-Name> --output /path/to/output/result
# Example:
python -u ape/predict.py --config configs/model.py --path /data/dataset/ --ext png --output infer_output/