Skip to content

Commit

Permalink
Fixes in opts
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimkantorov committed Sep 1, 2016
1 parent cf3c6ef commit a52a173
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ The results are available on the [project website](http://www.di.ens.fr/willow/r
This is a joint work of [Vadim Kantorov](http://vadimkantorov.com), [Maxime Oquab](http://github.com/qassemoquab), [Minsu Cho](http://www.di.ens.fr/~mcho), and [Ivan Laptev](http://www.di.ens.fr/~laptev).

# Running the code
1. Install the dependencies: [Torch](http://github.com/torch/distro) with [cuDNN](http://developer.nvidia.com/cudnn) support; [HDF5](http://www.hdfgroup.org/HDF5/); [matio](http://github.com/tbeu/matio); [protobuf](http://github.com/google/protobuf); Luarocks packages [rapidjson](http://github.com/xpol/lua-rapidjson), [hdf5](http://github.com/deepmind/torch-hdf5), [matio](http://github.com/soumith/matio-ffi.torch), [loadcaffe](http://github.com/szagoruyko/loadcaffe).
1. Install the dependencies: [Torch](http://github.com/torch/distro) with [cuDNN](http://developer.nvidia.com/cudnn) support; [HDF5](http://www.hdfgroup.org/HDF5/); [matio](http://github.com/tbeu/matio); [protobuf](http://github.com/google/protobuf); Luarocks packages [rapidjson](http://github.com/xpol/lua-rapidjson), [hdf5](http://github.com/deepmind/torch-hdf5), [matio](http://github.com/soumith/matio-ffi.torch), [loadcaffe](http://github.com/szagoruyko/loadcaffe), [xml](https://://github.com/lubyk/xml).

We strongly recommend using [wigwam](http://wigwam.in/) for this (fix the paths to `nvcc` and `libcudnn.so` before running the command):

```
$ wigwam install torch hdf5 matio protobuf -DPATH_TO_NVCC="/path/to/cuda/bin/nvcc" -DPATH_TO_CUDNN_SO="/path/to/cudnn/lib64/libcudnn.so"
$ wigwam install lua-rapidjson lua-hdf5 lua-matio lua-loadcaffe
$ wigwam install lua-rapidjson lua-hdf5 lua-matio lua-loadcaffe lua-xml
```
2. Clone this repository, change the current directory to `contextlocnet`, and compile the ROI pooling module:

Expand All @@ -27,30 +27,30 @@ This is a joint work of [Vadim Kantorov](http://vadimkantorov.com), [Maxime Oqua
$ cd contextlocnet
$ (cd ./model && luarocks make)
```
3. Download the [VOC 2007](http://host.robots.ox.ac.uk/pascal/VOC/voc2007/) dataset and Koen van de Sande's [selective search windows](http://koen.me/research/selectivesearch/) for VOC 2007 and the [VGG-F](https://gist.github.com/ksimonyan/a32c9063ec8e1118221a) model. Optionally download the [VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/) and Rob Girshick's [selective search windows](https://github.com/rbgirshick/fast-rcnn/blob/master/data/scripts/fetch_fast_rcnn_models.sh) by manually downloading [VOC 2012 test data tarball](http://host.robots.ox.ac.uk:8080/eval/downloads/VOC2012test.tar) to `data/common` and then running the second command):
3. Download the [VOC 2007](http://host.robots.ox.ac.uk/pascal/VOC/voc2007/) dataset and Koen van de Sande's [selective search windows](http://koen.me/research/selectivesearch/) for VOC 2007 and the [VGG-F](https://gist.github.com/ksimonyan/a32c9063ec8e1118221a) model by running the first command. Optionally download the [VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/) and Rob Girshick's [selective search windows](https://github.com/rbgirshick/fast-rcnn/blob/master/data/scripts/fetch_fast_rcnn_models.sh) by manually downloading [VOC 2012 test data tarball](http://host.robots.ox.ac.uk:8080/eval/downloads/VOC2012test.tar) to `data/common` and then running the second command:

```
$ make -f data/common/Makefile download_and_extract_VOC2007 download_VGGF
$ # make -f data/common/Makefile download_and_extract_VOC2012
```
4. Preprocess the VOC data and convert the VGG-F model to Torch format:
4. Choose a dataset, preprocess it, and convert the VGG-F model to the Torch format:

```
$ export DATASET=VOC2007
$ th preprocess.lua VOC VGGF
```
5. Choose a dataset, a model (our best model is `model/contrastive_s.lua`, other choices are `model/contrastive_a.lua`, `model/additive.lua`, and `model/wsddn_repro.lua`) and train it:
5. Select a GPU and train a model model (our best model is `model/contrastive_s.lua`, other choices are `model/contrastive_a.lua`, `model/additive.lua`, and `model/wsddn_repro.lua`):

```
$ export MODEL=model/contrastive_s.lua
$ export DATASET=VOC2007
$ th train.lua
$ export CUDA_VISIBLE_DEVICES=0
$ th train.lua model/contrastive_s.lua # will produce ./data/model_epoch30.h5 and ./data/log.json
```
6. Test the trained model and compute CorLoc and mAP:

```
$ SUBSET=trainval th test.lua
$ SUBSET=trainval th test.lua ./data/model_epoch30.h5
$ th corloc.lua
$ SUBSET=test th test.lua
$ SUBSET=test th test.lua ./data/model_epoch30.h5
$ th detection_mAP.lua
```

Expand Down
13 changes: 10 additions & 3 deletions opts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,24 @@ PATHS =
DETECTION_MAP = paths.concat(DATA, 'detection_map.json'),
}

local BASE_MODEL = 'VGGF'
local DATASET = os.getenv('DATASET') or 'VOC2007'
local ROI_FACTOR = tonumber(os.getenv('ROI_FACTOR')) or 1.8
local NUM_EPOCHS = tonumber(os.getenv('NUM_EPOCHS')) or 30
local SUBSET = os.getenv('SUBSET') or 'trainval'
local BASE_MODEL = 'VGGF'

opts = {
DATASET = DATASET,
BASE_MODEL = BASE_MODEL,
ROI_FACTOR = ROI_FACTOR,
ROI_FACTOR = 1.8,
OUTPUTS_FIELDS = {'output_prod'},
SEED = 2,
NUM_EPOCHS = NUM_EPOCHS,
NUM_SCALES = 5,
SUBSET = SUBSET,
PATHS =
{
MODEL = arg[1],

DATA = DATA,
DATA_COMMON = DATA_COMMON,

Expand Down
3 changes: 2 additions & 1 deletion preprocess.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function VOC()
end

for _, a in ipairs(arg) do
print('Preprocessing', a, '...')
print('Preprocessing', a)
_G[a]()
end
print('Done')
5 changes: 1 addition & 4 deletions test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ dofile('perf/util.lua')

assert(os.getenv('CUDA_VISIBLE_DEVICES') ~= nil and cutorch.getDeviceCount() <= 1, 'SHOULD RUN ON ONE GPU FOR NOW')

opts.NUM_SCALES = tonumber(os.getenv('NUM_SCALES')) or 5
opts.SUBSET = os.getenv('SUBSET') or 'trainval'
opts.MODEL = arg[1]

loaded = model_load(opts.MODEL, opts)
loaded = model_load(opts.PATHS.MODEL, opts)

meta = {
opts = opts,
Expand Down
11 changes: 3 additions & 8 deletions train.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ dofile('opts.lua')
dofile('util.lua')
dofile('dataset.lua')
dofile('model/util.lua')
dofile('perf/util.lua')

require 'optim'
dofile('fbnn_Optim.lua')

assert(os.getenv('CUDA_VISIBLE_DEVICES') ~= nil and cutorch.getDeviceCount() <= 1, 'SHOULD RUN ON ONE GPU FOR NOW')

opts.SEED = tonumber(os.getenv('SEED')) or torch.initialSeed()
opts.NUM_EPOCHS = tonumber(os.getenv('NUM_EPOCHS')) or 30
opts.MODEL = arg[1]

torch.manualSeed(opts.SEED)
cutorch.manualSeedAll(opts.SEED)

Expand All @@ -31,16 +26,16 @@ example_loader_options_preset = {
}
}

if paths.extname(opts.MODEL) == 'lua' then
loaded = model_load(opts.MODEL, opts)
if paths.extname(opts.PATHS.MODEL) == 'lua' then
loaded = model_load(opts.PATHS.MODEL, opts)
meta = {
model_path = loaded.model_path,
opts = opts,
example_loader_options = example_loader_options_preset
}
log = {{meta = meta}}
else
loaded = model_load(opts.MODEL)
loaded = model_load(opts.PATHS.MODEL)
meta = loaded.meta
log = loaded.log
previous_epoch = loaded.epoch
Expand Down

0 comments on commit a52a173

Please sign in to comment.