[b758a2]: / code / detectorSimple.lua

Download this file

61 lines (47 with data), 1.1 kB

 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'torch';
require 'nn';
require 'image';
cuda = false
--if cuda then
require 'cutorch';
require 'cunn';
--end
require 'sys';
local dir = require 'pl.dir';
local c = os.clock()
local t = os.time()
local trainFolder = '/home/andrew/mitosis/MITOS/training/'
local mapFolder = '/home/andrew/mitosis/maps/'
local netPath = '/home/andrew/mitosis/nets/net.t7'
dofile("getImagePaths.lua")
imagePaths = getImagePaths(trainFolder)
if paths.dirp(mapFolder) == false then
paths.mkdir(mapFolder)
end
dofile("scan.lua")
dofile("expand.lua")
for k,imagePath in ipairs(imagePaths) do
print(k)
local c1 = os.clock()
local t1 = os.time()
local net = torch.load(netPath)
net = expand(net)
if cuda then
net = net:cuda()
else
net = net:float()
end
local img = image.load(imagePath, 3, 'float')
if cuda then
img = img:cuda()
else
img = img:float()
end
local map = scan(img, net)
local outfile = paths.concat(mapFolder, paths.basename(imagePath))
image.save(outfile, map)
print(os.clock()-c1)
print(os.time()-t1)
end
print(os.clock()-c)
print(os.time()-t)