Blur-training with 16-class-ImageNet
Training images are blurred by Gaussian function. The images are more blurred as std.(ฯ) of Gaussian kernel is bigger.
You can try different training schedule as for blurring images. Here is an overview of the training schedule:
Default: AlexNet (16 class)
Since the number of class is 16, I change the number of final units from 1000 to 16.
See more in notebook/models.ipynb
You can also use another architecture by using --arch [ARCHITECTURE NAME]
. See python main.py -h
for the available models (from pytorchvision's model zoo).
- Install Python Packages
$ pip install -r requirements.txt
Or pull and run docker image (e.g. blur-training:latest) which I made for these experiments. You may need to install robustness library in the container like:
$ pip install robustness==1.1
- Get ImageNet images & set the path. If you already have ImageNet, set
in_path
variable intraining/utils.py
.
If not, Download the ImageNet dataset from http://www.image-net.org/
(Note that the ImageNet images need to be divided in two subdirectories,train/
andval/
.)
Then set the path.
General usage example:
$ cd training
$ python main.py --arch [ARCHITECTURE NAME] --mode [TRAINING MODE] -n [EXPERIMENT NAME]
For main.py
, you need to use --exp_name
or -n
option to define your experiment's name.
Then the experiment's name is used for managing results under logs/
directory.
logs/
directory will automatically be created when you run main.py
.
You can choose the training mode from:
normal, all, mix, reversed-single-step, single-step, multi-steps
by using --mode [TRAINING MODE]
option.
- normal
This mode trains Normal model (default: AlexNet).
usage example:
$ python main.py --mode normal -e 60 -b 64 --lr 0.01 -n normal
- all
This mode blurs ALL images in the training mode.
usage example:
$ python main.py --mode all -s1 -n all_s1
- mix
This mode blurs half training data. usage example:
$ python main.py --mode mix -s 1 -n mix_s1
- random-mix
This mode blurs half training data randomly.
usage example:
$ python main.py --arch alexnet --mode random-mix --min_sigma 0 --max_sigma 5 -n alexnet_random-mix_s0-5
- single-step
This mode blurs first half epochs (e.g. first 30 epochs in 60 entire epochs) in the training. usage example:
$ python main.py --mode single-step -s 1 -n single-step_s1
- multi-steps
This mode blurs images step by step (e.g. every 10 epochs).
usage example:
$ python main.py --mode multi-steps -n multi-steps
--resume [PATH TO SAVED MODEL]
This option trains your saved model starting from the latest epoch.
usage example:
$ python main.py --arch alexnet --mode mix -s 1 -n alexnet_mix_s1 --resume ../logs/models/alexnet_mix_s1/checkpoint.pth.tar
Demonstrations of 16-class-ImageNet, GaussianBlur, and CNN model architectures.
Training scripts and functions are based rely on [pytorch tutorial][pytorch-tutorial] and pytorch imagenet trainning example.