forked from facebookarchive/fb.resnet.torch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
36 lines (30 loc) · 994 Bytes
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--
-- Copyright (c) 2016, Facebook, Inc.
-- All rights reserved.
--
-- This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree. An additional grant
-- of patent rights can be found in the PATENTS file in the same directory.
--
-- ImageNet and CIFAR-10 datasets
--
local M = {}
local function isvalid(opt, cachePath)
local imageInfo = torch.load(cachePath)
if imageInfo.basedir and imageInfo.basedir ~= opt.data then
return false
end
return true
end
function M.create(opt, split)
local cachePath = paths.concat(opt.gen, opt.dataset .. '.t7')
if not paths.filep(cachePath) or not isvalid(opt, cachePath) then
paths.mkdir('gen')
local script = paths.dofile(opt.dataset .. '-gen.lua')
script.exec(opt, cachePath)
end
local imageInfo = torch.load(cachePath)
local Dataset = require('datasets/' .. opt.dataset)
return Dataset(imageInfo, opt, split)
end
return M