项目作者: fbuchert

项目描述 :
PyTorch implementation of Unsupervised Representation Learning by Predicting Image Rotations
高级语言: Python
项目地址: git://github.com/fbuchert/rotation-prediction-pytorch.git
创建时间: 2021-07-02T16:39:39Z
项目社区:https://github.com/fbuchert/rotation-prediction-pytorch

开源协议:MIT License

下载


PyTorch Implementation: RotNet

License

PyTorch implementation of Unsupervised Representation Learning by Predicting Image Rotations
based on the official implementation.

The implementation supports the following datasets:

  • CIFAR-10 / CIFAR-100
  • SVHN
  • Caltech101 / Caltech256
  • STL10
  • HAM10000
  • ImageNet

Installation

Required python packages are listed in requirements.txt. All dependencies can be installed using pip

  1. pip install -r requirements.txt

or using conda

  1. conda install --file requirements.txt

Training

RotNet training is started by running the following command (--pbar to show progress bar during training):

  1. python main.py --pbar

All commandline arguments, which can be used to adapt the configuration of the RotNet training are defined and described in arguments.py.
By default the following configuration is run:

  1. model: 'NIN_4'
  2. dataset: 'cifar10'
  3. lr: 0.1
  4. wd: 0.0005
  5. epochs: 100
  6. batch_size: 128
  7. device: 'cuda'
  8. out_dir: 'rotation_prediction'
  9. momentum: 0.9

In addition to these, the following arguments can be used to further configure the RotNet training process:

  • --device <cuda / cpu>: Specify whether training should be run on GPU (if available) or CPU
  • --num-workers <num_workers>: Number of workers used by torch dataloader
  • --resume <path to run_folder>: Resumes training of training run saved at specified path, e.g. 'out/rotnet_training/run_0'. Dataset splits, model state, optimizer state, etc.
    are loaded and training is resumed with specified arguments.
  • see arguments.py for more

Alternatively, the polyaxon.yaml-file can be used to start the RotNet training on a polyaxon-cluster:

  1. polyaxon run -f polyaxon.yaml -u

For a general introduction to polyaxon and its commandline client, please refer to the official documentation

Monitoring

The training progress (loss, accuracy, etc.) can be monitored using tensorboard as follows:

  1. tensorboard --logdir <result_folder>

This starts a tensorboard instance at localhost:6006, which can be opened in any common browser.

Evaluation

A trained RotNet model can be evaluated by running:

  1. python3 eval.py --run-path out/rotnet_training/run_0 --pbar --device <cuda / cpu>

where --run-path specifies the path at which the run to be evaluated is saved. Alternatively, one can also check all
metrics over all epochs using the tensorboard file.

References

  1. @inproceedings{
  2. gidaris2018unsupervised,
  3. title={Unsupervised Representation Learning by Predicting Image Rotations},
  4. author={Spyros Gidaris and Praveer Singh and Nikos Komodakis},
  5. booktitle={International Conference on Learning Representations},
  6. year={2018},
  7. url={https://openreview.net/forum?id=S1v4N2l0-},
  8. }