Code in Torch for PlantVillage challenge: https://www.crowdai.org/challenges/1
Clone or download
Latest commit 4d27711 Oct 26, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
datasets
logs
models models now return createModel function Aug 2, 2016
.gitignore Initial commit May 21, 2016
INSTALL.md
README.md
log.lua Logging and major refactoring of train script Jul 26, 2016
main.lua
submission.lua Merge branch 'master' of github.com:chsasank/plantvillage-challenge May 30, 2016
train.lua

README.md

Code in Torch for PlantVillage challenge

I wrote a blog post describing the code here: http://chsasank.github.io/plantvillage-tutorial.html

Requirements

See the installation instructions for a step-by-step guide.

If you already have Torch installed, update nn, cunn, and cudnn.

Divide the training data in to train and val folders. You can use a bash script like this:

cd directory/contaning/c_0c_1...etcdirectories
mkdir -p train val
for i in {0..37}; do mkdir val/c_$i; done
mv c_* train

Training

The training scripts come with several options, which can be listed with the --help flag.

$ th main.lua --help
Torch-7 PlantVillage Challenge Training script

  -learningRate initial learning rate for sgd [0.01]
  -momentum     momentum term of sgd [0.9]
  -maxEpochs    Max # Epochs [120]
  -batchSize    batch size [32]
  -nbClasses    # of classes [38]
  -nbChannels   # of channels [3]
  -backend      Options: cudnn | nn [cudnn]
  -model        Options: alexnet | vgg | resnet [alexnet]
  -depth        For vgg depth: A | B | C | D, For resnet depth: 18 | 34 | 50 | 101 | ... Not applicable for alexnet [A]
  -retrain      Path to model to finetune [none]
  -save         Path to save models [.]
  -data         Path to folder with train and val directories [datasets/crowdai/]

Example usage

Train alexnet:

$ th main.lua -model alexnet -data path/to/train-val-directories

Train alexnet on CPU (not recommended):

$ th main.lua -model alexnet -data path/to/train-val-directories -backend nn

Train resnet 34

$ th main.lua -model resnet -depth 34 -learningRate 0.1 -data path/to/train-val-directories

This checkpoints the model every 10 epochs. It also saves the best model as per validation set. You can use these to make a submission.

Submission

Create a submission using model.t7:

th submission.lua model.t7 path/to/test > submission.csv