Skip to content

Commit d9bbfb5

Browse files
committed
first init
1 parent 1c2348e commit d9bbfb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+40595
-0
lines changed

data/ImageNet_models/dump

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
init

data/RON_models/dump

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
init

demo_camera.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python tools/demo_video.py

lib/Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
all:
2+
python setup.py build_ext --inplace
3+
rm -rf build
4+
clean:
5+
rm -rf nms/*.so nms/*.c
6+
rm -rf utils/*.so utils/*.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function VOCopts = get_voc_opts(path)
2+
3+
tmp = pwd;
4+
cd(path);
5+
try
6+
addpath('VOCcode');
7+
VOCinit;
8+
catch
9+
rmpath('VOCcode');
10+
cd(tmp);
11+
error(sprintf('VOCcode directory not found under %s', path));
12+
end
13+
rmpath('VOCcode');
14+
cd(tmp);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
function res = voc_eval(path, comp_id, test_set, output_dir, rm_res)
2+
3+
VOCopts = get_voc_opts(path);
4+
VOCopts.testset = test_set;
5+
6+
for i = 1:length(VOCopts.classes)
7+
cls = VOCopts.classes{i};
8+
res(i) = voc_eval_cls(cls, VOCopts, comp_id, output_dir, rm_res);
9+
end
10+
11+
fprintf('\n~~~~~~~~~~~~~~~~~~~~\n');
12+
fprintf('Results:\n');
13+
aps = [res(:).ap]';
14+
fprintf('%.1f\n', aps * 100);
15+
fprintf('%.1f\n', mean(aps) * 100);
16+
fprintf('~~~~~~~~~~~~~~~~~~~~\n');
17+
18+
function res = voc_eval_cls(cls, VOCopts, comp_id, output_dir, rm_res)
19+
20+
test_set = VOCopts.testset;
21+
year = VOCopts.dataset(4:end);
22+
23+
addpath(fullfile(VOCopts.datadir, 'VOCcode'));
24+
25+
res_fn = sprintf(VOCopts.detrespath, comp_id, cls);
26+
27+
recall = [];
28+
prec = [];
29+
ap = 0;
30+
ap_auc = 0;
31+
32+
do_eval = (str2num(year) <= 2007) | ~strcmp(test_set, 'test');
33+
if do_eval
34+
% Bug in VOCevaldet requires that tic has been called first
35+
tic;
36+
[recall, prec, ap] = VOCevaldet(VOCopts, comp_id, cls, true);
37+
ap_auc = xVOCap(recall, prec);
38+
39+
% force plot limits
40+
ylim([0 1]);
41+
xlim([0 1]);
42+
43+
print(gcf, '-djpeg', '-r0', ...
44+
[output_dir '/' cls '_pr.jpg']);
45+
end
46+
fprintf('!!! %s : %.4f %.4f\n', cls, ap, ap_auc);
47+
48+
res.recall = recall;
49+
res.prec = prec;
50+
res.ap = ap;
51+
res.ap_auc = ap_auc;
52+
53+
save([output_dir '/' cls '_pr.mat'], ...
54+
'res', 'recall', 'prec', 'ap', 'ap_auc');
55+
56+
if rm_res
57+
delete(res_fn);
58+
end
59+
60+
rmpath(fullfile(VOCopts.datadir, 'VOCcode'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function ap = xVOCap(rec,prec)
2+
% From the PASCAL VOC 2011 devkit
3+
4+
mrec=[0 ; rec ; 1];
5+
mpre=[0 ; prec ; 0];
6+
for i=numel(mpre)-1:-1:1
7+
mpre(i)=max(mpre(i),mpre(i+1));
8+
end
9+
i=find(mrec(2:end)~=mrec(1:end-1))+1;
10+
ap=sum((mrec(i)-mrec(i-1)).*mpre(i));

lib/datasets/__init__.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# --------------------------------------------------------
2+
# Fast R-CNN
3+
# Copyright (c) 2015 Microsoft
4+
# Licensed under The MIT License [see LICENSE for details]
5+
# Written by Ross Girshick
6+
# --------------------------------------------------------
7+
8+
from .imdb import imdb
9+
from .pascal_voc import pascal_voc
10+
from .coco import coco
11+
from . import factory
12+
13+
import os.path as osp
14+
ROOT_DIR = osp.join(osp.dirname(__file__), '..', '..')
15+
16+
# We assume your matlab binary is in your path and called `matlab'.
17+
# If either is not true, just add it to your path and alias it as matlab, or
18+
# you could change this file.
19+
MATLAB = 'matlab'
20+
21+
# http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
22+
def _which(program):
23+
import os
24+
def is_exe(fpath):
25+
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
26+
27+
fpath, fname = os.path.split(program)
28+
if fpath:
29+
if is_exe(program):
30+
return program
31+
else:
32+
for path in os.environ["PATH"].split(os.pathsep):
33+
path = path.strip('"')
34+
exe_file = os.path.join(path, program)
35+
if is_exe(exe_file):
36+
return exe_file
37+
38+
return None
39+
40+
if _which(MATLAB) is None:
41+
msg = ("MATLAB command '{}' not found. "
42+
"Please add '{}' to your PATH.").format(MATLAB, MATLAB)
43+
#raise EnvironmentError(msg)

0 commit comments

Comments
 (0)