2015-09-24 07:49:45 +08:00
|
|
|
local M = { }
|
|
|
|
|
|
|
|
-- http://stackoverflow.com/questions/6380820/get-containing-path-of-lua-file
|
|
|
|
function script_path()
|
|
|
|
local str = debug.getinfo(2, "S").source:sub(2)
|
|
|
|
return str:match("(.*/)")
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.parse(arg)
|
|
|
|
|
|
|
|
local cmd = torch.CmdLine()
|
|
|
|
cmd:text()
|
2015-10-09 22:48:06 +08:00
|
|
|
cmd:text('OpenFace')
|
2015-09-24 07:49:45 +08:00
|
|
|
cmd:text()
|
|
|
|
cmd:text('Options:')
|
|
|
|
|
|
|
|
------------ General options --------------------
|
|
|
|
cmd:option('-cache',
|
|
|
|
paths.concat(script_path(), 'work'),
|
2016-06-14 01:29:29 +08:00
|
|
|
'Directory to cache experiments and data.')
|
|
|
|
cmd:option('-save', '', 'Directory to save experiment.')
|
2015-09-24 07:49:45 +08:00
|
|
|
cmd:option('-data',
|
2015-10-09 22:48:06 +08:00
|
|
|
paths.concat(os.getenv('HOME'), 'openface', 'data',
|
2015-09-24 07:49:45 +08:00
|
|
|
'casia-facescrub',
|
|
|
|
'dlib-affine-sz:96'),
|
|
|
|
-- 'dlib-affine-224-split'),
|
|
|
|
'Home of dataset. Split into "train" and "val" directories that separate images by class.')
|
2016-01-07 05:04:10 +08:00
|
|
|
cmd:option('-manualSeed', 2, 'Manually set RNG seed')
|
2016-01-12 04:36:58 +08:00
|
|
|
cmd:option('-cuda', true, 'Use cuda.')
|
2016-06-15 03:55:46 +08:00
|
|
|
cmd:option('-device', 1, 'Cuda device to use.')
|
2016-06-14 01:29:29 +08:00
|
|
|
cmd:option('-cudnn', true, 'Convert the model to cudnn.')
|
2015-09-24 07:49:45 +08:00
|
|
|
|
|
|
|
------------- Data options ------------------------
|
2016-01-07 05:04:10 +08:00
|
|
|
cmd:option('-nDonkeys', 2, 'number of donkeys to initialize (data loading threads)')
|
2015-09-24 07:49:45 +08:00
|
|
|
|
|
|
|
------------- Training options --------------------
|
2016-01-07 05:04:10 +08:00
|
|
|
cmd:option('-nEpochs', 1000, 'Number of total epochs to run')
|
2016-03-07 09:03:54 +08:00
|
|
|
cmd:option('-epochSize', 250, 'Number of batches per epoch')
|
2016-01-07 05:04:10 +08:00
|
|
|
cmd:option('-epochNumber', 1, 'Manual epoch number (useful on restarts)')
|
|
|
|
-- GPU memory usage depends on peoplePerBatch and imagesPerPerson.
|
|
|
|
cmd:option('-peoplePerBatch', 15, 'Number of people to sample in each mini-batch.')
|
|
|
|
cmd:option('-imagesPerPerson', 20, 'Number of images to sample per person in each mini-batch.')
|
2016-03-07 08:45:37 +08:00
|
|
|
cmd:option('-testing', true, 'Test with the LFW.')
|
2016-03-05 07:30:39 +08:00
|
|
|
cmd:option('-testBatchSize', 800, 'Batch size for testing.')
|
2016-03-20 03:44:47 +08:00
|
|
|
cmd:option('-lfwDir', '../data/lfw/aligned', 'LFW aligned image directory for testing.')
|
2015-09-24 07:49:45 +08:00
|
|
|
|
|
|
|
---------- Model options ----------------------------------
|
2016-01-07 05:04:10 +08:00
|
|
|
cmd:option('-retrain', 'none', 'provide path to model to retrain with')
|
2015-10-09 22:48:06 +08:00
|
|
|
cmd:option('-modelDef', '../models/openface/nn4.def.lua', 'path to model definiton')
|
2016-01-12 05:44:50 +08:00
|
|
|
cmd:option('-imgDim', 96, 'Image dimension. nn2=224, nn4=96')
|
2016-01-07 05:04:10 +08:00
|
|
|
cmd:option('-embSize', 128, 'size of embedding from model')
|
|
|
|
cmd:option('-alpha', 0.2, 'margin in TripletLoss')
|
2015-09-24 07:49:45 +08:00
|
|
|
cmd:text()
|
|
|
|
|
|
|
|
local opt = cmd:parse(arg or {})
|
|
|
|
os.execute('mkdir -p ' .. opt.cache)
|
2016-06-14 01:29:29 +08:00
|
|
|
|
|
|
|
if opt.save == '' then
|
|
|
|
opt.save = paths.concat(opt.cache, os.date("%Y-%m-%d_%H-%M-%S"))
|
2015-09-24 07:49:45 +08:00
|
|
|
end
|
2016-06-14 01:29:29 +08:00
|
|
|
os.execute('mkdir -p ' .. opt.save)
|
2015-09-24 07:49:45 +08:00
|
|
|
|
|
|
|
return opt
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|