This repository is copied from Image Classification Examples of MXNet. And I made some modifications to these examples, including removing some files that I don't need (eg. R programs) and adding some useful files. And I simplfied the README.md, if you want a more detailed description, you should read the original README.md.
Assume all images are stored as individual image files such as .png or .jpg, and images belonging to the same class are placed in the same directory. All these class directories are then in the same root data
directory.
- We first prepare two
.lst
files, which consist of the labels and image paths can be used for generatingrec
files.python im2rec.py rec/img data/ --list=True --train-ratio=0.8 --recursive=True
- Then we generate the
.rec
files. We resize the images such that the short edge is at least 256px.python im2rec.py rec/img_train data/ --resize=256 python im2rec.py rec/img_val data/ --resize=256
- Use
python im2rec.py --help
to see more options.
Python training programs is provided (R training programs is not provided here). Use train_*.py
to train a network on a particular dataset. For example:
-
Train the datasets prepared before. There is a rich set of options, one can list them by passing
--help
.python train.py --data-train rec/img_train.rec --data-val rec/img_val.rec
-
When the training process is finished, we generate a training log in
log/train.log
and useparse_log.py
to parse it into a markdown table.python parse_log.py log/train.log
We can use score.py
to score a model on a dataset.
python score.py --model models/img_cls --epoch 30 --data-val rec/img_val.rec
We can use predict.py
to predict an image.
python predict.py img.jpg --model models/img_cls --epoch 30
TODO