Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ayu___
fast-rcnn
提交
421fdb1b
F
fast-rcnn
项目概览
Ayu___
/
fast-rcnn
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fast-rcnn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
421fdb1b
编写于
3月 03, 2015
作者:
R
Ross Girshick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
matlab eval
上级
7d458af0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
13 deletion
+14
-13
fast_rcnn_test.py
fast_rcnn_test.py
+14
-13
未找到文件。
fast_rcnn_test.py
浏览文件 @
421fdb1b
#!/usr/bin/env python
#!/usr/bin/env python
import
sys
import
sys
import
subprocess
caffe_path
=
'../caffe/python'
caffe_path
=
'../caffe/python'
sys
.
path
.
insert
(
0
,
caffe_path
)
sys
.
path
.
insert
(
0
,
caffe_path
)
...
@@ -186,8 +187,9 @@ def _vis_detections(im, class_name, dets):
...
@@ -186,8 +187,9 @@ def _vis_detections(im, class_name, dets):
plt
.
pause
(
0.5
)
plt
.
pause
(
0.5
)
def
_write_voc_results_file
(
imdb
,
all_boxes
):
def
_write_voc_results_file
(
imdb
,
all_boxes
):
pid
=
os
.
getpid
()
#/data/VOC2007/VOCdevkit/results/VOC2007/Main/comp4-44503_det_test_aeroplane.txt
#/data/VOC2007/VOCdevkit/results/VOC2007/Main/comp4-44503_det_test_aeroplane.txt
base_path
=
'
/data/VOC2007/VOCdevkit/results/VOC2007/Main/comp4-py_'
base_path
=
'
./datasets/VOCdevkit2007/results/VOC2007/Main/comp4-{}_'
.
format
(
pid
)
for
cls_ind
,
cls
in
enumerate
(
imdb
.
classes
):
for
cls_ind
,
cls
in
enumerate
(
imdb
.
classes
):
if
cls
==
'__background__'
:
if
cls
==
'__background__'
:
continue
continue
...
@@ -207,6 +209,15 @@ def _write_voc_results_file(imdb, all_boxes):
...
@@ -207,6 +209,15 @@ def _write_voc_results_file(imdb, all_boxes):
f
.
write
(
'{:s} {:.3f} {:.1f} {:.1f} {:.1f} {:.1f}
\n
'
.
format
(
f
.
write
(
'{:s} {:.3f} {:.1f} {:.1f} {:.1f} {:.1f}
\n
'
.
format
(
index
,
dets
[
k
,
-
1
],
dets
[
k
,
0
],
dets
[
k
,
1
],
index
,
dets
[
k
,
-
1
],
dets
[
k
,
0
],
dets
[
k
,
1
],
dets
[
k
,
2
],
dets
[
k
,
3
]))
dets
[
k
,
2
],
dets
[
k
,
3
]))
print
'Evaluate comp4-{}'
.
format
(
pid
)
return
pid
def
_do_matlab_eval
(
pid
):
cmd
=
'cd ../rcnn;'
cmd
+=
'matlab -nodisplay -nodesktop '
cmd
+=
'-r "load imdb/cache/imdb_voc_2007_test.mat; '
cmd
+=
'imdb_eval_voc_py(imdb, {});"'
.
format
(
pid
)
status
=
subprocess
.
call
(
cmd
),
shell
=
True
)
def
fast_rcnn_test
(
net
,
imdb
):
def
fast_rcnn_test
(
net
,
imdb
):
num_images
=
len
(
imdb
.
image_index
)
num_images
=
len
(
imdb
.
image_index
)
...
@@ -277,7 +288,8 @@ def fast_rcnn_test(net, imdb):
...
@@ -277,7 +288,8 @@ def fast_rcnn_test(net, imdb):
with
open
(
'dets.pkl'
,
'wb'
)
as
f
:
with
open
(
'dets.pkl'
,
'wb'
)
as
f
:
cPickle
.
dump
(
all_boxes
,
f
,
cPickle
.
HIGHEST_PROTOCOL
)
cPickle
.
dump
(
all_boxes
,
f
,
cPickle
.
HIGHEST_PROTOCOL
)
_write_voc_results_file
(
imdb
,
all_boxes
)
pid
=
_write_voc_results_file
(
imdb
,
all_boxes
)
_do_matlab_eval
(
pid
)
# Write results file and call matlab to evaluate
# Write results file and call matlab to evaluate
...
@@ -292,17 +304,6 @@ if __name__ == '__main__':
...
@@ -292,17 +304,6 @@ if __name__ == '__main__':
caffe
.
set_device
(
GPU_ID
)
caffe
.
set_device
(
GPU_ID
)
net
=
caffe
.
Net
(
prototxt
,
caffemodel
)
net
=
caffe
.
Net
(
prototxt
,
caffemodel
)
print
'!!!!!!!!!!!!!!!!!! REMOVE mean/std??? !!!!!!!!!!!!!!!!!!'
# TODO(rbg): save net with these changes during training snapshots
import
scipy.io
stats
=
scipy
.
io
.
loadmat
(
'../rcnn/data/voc_2007_means_stds.mat'
)
stds
=
stats
[
'stds'
].
ravel
()[
np
.
newaxis
,
np
.
newaxis
,
:,
np
.
newaxis
]
means
=
stats
[
'means'
].
ravel
()[
np
.
newaxis
,
np
.
newaxis
,
np
.
newaxis
,
:]
net
.
params
[
'fc8_pascal_bbox'
][
0
].
data
[...]
=
\
net
.
params
[
'fc8_pascal_bbox'
][
0
].
data
*
stds
net
.
params
[
'fc8_pascal_bbox'
][
1
].
data
[...]
=
\
net
.
params
[
'fc8_pascal_bbox'
][
1
].
data
+
means
import
datasets.pascal_voc
import
datasets.pascal_voc
imdb
=
datasets
.
pascal_voc
(
'test'
,
'2007'
)
imdb
=
datasets
.
pascal_voc
(
'test'
,
'2007'
)
fast_rcnn_test
(
net
,
imdb
)
fast_rcnn_test
(
net
,
imdb
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录