-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.lua
33 lines (28 loc) · 1.11 KB
/
demo.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
model_path = '/home/zxw/ssd-torch7/model120000iteration.t7'
img_path ='/home/zxw/ssd-torch7/LVUsine.jpg'
torch.setdefaulttensortype('torch.FloatTensor')
_=dofile('ssd.lua')
dofile('cfg.lua')
dofile('utils.lua')
require 'image'
model = torch.load('/home/zxw/DeepGrasp/output/model12_1e-3_Aug44832000iter.t7')
model = torch.load(model_path):cuda()
img = image.load(img_path)
res = img:clone()
img = image.scale(img, 300, 300)
class_list = {'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus',
'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike',
'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'}
img_r = img[{{1},{},{}}]
img_b = img[{{3},{},{}}]
img[{{1},{},{}}] = img_b
img[{{3},{},{}}] = img_r
boxes, classes, scores = Detect(model, img, 0.45, 0.6, cfg)
for i = 1, boxes[1]:size(1) do
boxes[1][i][1] = boxes[1][i][1] * res:size(3)
boxes[1][i][2] = boxes[1][i][2] * res:size(2)
boxes[1][i][3] = boxes[1][i][3] * res:size(3)
boxes[1][i][4] = boxes[1][i][4] * res:size(2)
end
res = DrawRect(res, boxes[1], classes[1], class_list)
image.savePNG('LVUsine.png', res)