Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47816946
simple-faster-rcnn-pytorch
提交
240a61fd
S
simple-faster-rcnn-pytorch
项目概览
weixin_47816946
/
simple-faster-rcnn-pytorch
与 Fork 源项目一致
从无法访问的项目Fork
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
simple-faster-rcnn-pytorch
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
240a61fd
编写于
12月 20, 2017
作者:
C
chenyuntc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tiny modification for optimizer
上级
c96fa0a2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
31 deletion
+26
-31
config.py
config.py
+2
-2
data/dataset.py
data/dataset.py
+2
-22
model/faster_rcnn.py
model/faster_rcnn.py
+16
-5
train.py
train.py
+3
-1
trainer.py
trainer.py
+3
-1
未找到文件。
config.py
浏览文件 @
240a61fd
...
...
@@ -18,7 +18,7 @@ class Config:
roi_sigma
=
1.
# param for optimizer
weight_decay
=
0.000
1
# NOTE:it's modified
weight_decay
=
0.000
5
# 0.0005 in origin paper but 0.0001 in tf-faster-rcnn
lr_decay
=
0.1
# 1e-3 -> 1e-4
# lr = 1e-3
lr1
=
1e-3
# extractor
...
...
@@ -40,7 +40,7 @@ class Config:
# change lr
milestone
=
[
0
,
1
,
5
,
10
]
use_adam
=
False
# debug
debug_file
=
'/tmp/debugf'
...
...
data/dataset.py
浏览文件 @
240a61fd
...
...
@@ -82,7 +82,6 @@ class Dataset():
img
,
bbox
,
label
,
scale
=
self
.
tsf
((
ori_img
,
bbox
,
label
))
# TODO: check whose stride is negative to fix this instead copy all
# some of the strides of a given numpy array are negative.
# This is currently not supported, but will be added in future releases.
return
img
.
copy
(),
bbox
.
copy
(),
label
.
copy
(),
scale
,
ori_img
def
__len__
(
self
):
...
...
@@ -90,34 +89,15 @@ class Dataset():
class
TestDataset
():
def
__init__
(
self
,
opt
):
def
__init__
(
self
,
opt
,
split
=
'test'
,
use_difficult
=
True
):
self
.
opt
=
opt
self
.
db
=
testset
=
VOCBboxDataset
(
opt
.
voc_data_dir
,
split
=
'test'
,
use_difficult
=
True
)
self
.
db
=
testset
=
VOCBboxDataset
(
opt
.
voc_data_dir
,
split
=
split
,
use_difficult
=
use_difficult
)
def
__getitem__
(
self
,
idx
):
ori_img
,
bbox
,
label
,
difficult
=
self
.
db
.
get_example
(
idx
)
img
=
preprocess
(
ori_img
)
return
(
img
),
ori_img
.
shape
[
1
:],
bbox
,
label
,
difficult
# TODO: check whose stride is negative to fix this instead copy all
# some of the strides of a given numpy array are negative.
# This is currently not supported, but will be added in future releases.
def
__len__
(
self
):
return
len
(
self
.
db
)
class
TestDataset2
():
def
__init__
(
self
,
opt
):
self
.
opt
=
opt
self
.
db
=
testset
=
VOCBboxDataset
(
opt
.
voc_data_dir
,
split
=
'trainval'
,
use_difficult
=
True
)
def
__getitem__
(
self
,
idx
):
ori_img
,
bbox
,
label
,
difficult
=
self
.
db
.
get_example
(
idx
)
img
=
preprocess
(
ori_img
)
return
(
img
),
ori_img
.
shape
[
1
:],
bbox
,
label
,
difficult
# TODO: check whose stride is negative to fix this instead copy all
# some of the strides of a given numpy array are negative.
# This is currently not supported, but will be added in future releases.
def
__len__
(
self
):
return
len
(
self
.
db
)
model/faster_rcnn.py
浏览文件 @
240a61fd
...
...
@@ -66,16 +66,14 @@ class FasterRCNN(nn.Module):
Region Proposal Networks. NIPS 2015.
Args:
extractor (
callable Chain): A callab
le that takes a BCHW image
extractor (
nn.Module): A modu
le that takes a BCHW image
array and returns feature maps.
rpn (
callable Chain): A callab
le that has the same interface as
rpn (
nn.Module): A modu
le that has the same interface as
:class:`~chainercv.links.model.faster_rcnn.RegionProposalNetwork`.
Please refer to the documentation found there.
head (
callable Chain
): A callable that takes
head (
nn.Module
): A callable that takes
a BCHW array, RoIs and batch indices for RoIs. This returns class
dependent localization paramters and class scores.
mean (numpy.ndarray): A value to be subtracted from an image
in :meth:`prepare`.
loc_normalize_mean (tuple of four floats): Mean values of
localization estimates.
loc_normalize_std (tupler of four floats): Standard deviation
...
...
@@ -399,3 +397,16 @@ class FasterRCNN(nn.Module):
for
param_group
in
self
.
optimizer
.
param_groups
:
param_group
[
'lr'
]
*=
decay
return
self
.
optimizer
def
get_optimizer_adam
(
self
):
lr
=
opt
.
lr1
*
0.1
self
.
lr1
=
lr
params
=
[]
for
key
,
value
in
dict
(
self
.
named_parameters
()).
items
():
if
value
.
requires_grad
:
if
'bias'
in
key
:
params
+=
[{
'params'
:
[
value
],
'lr'
:
lr
*
2
,
'weight_decay'
:
0
}]
else
:
params
+=
[{
'params'
:
[
value
],
'lr'
:
lr
,
'weight_decay'
:
opt
.
weight_decay
}]
self
.
optimizer
=
t
.
optim
.
Adam
(
params
)
return
self
.
optimizer
train.py
浏览文件 @
240a61fd
...
...
@@ -99,7 +99,9 @@ def train(**kwargs):
trainer
.
vis
.
text
(
str
(
trainer
.
rpn_cm
.
value
().
tolist
()),
win
=
'rpn_cm'
)
# roi confusion matrix
trainer
.
vis
.
img
(
'roi_cm'
,
at
.
totensor
(
trainer
.
roi_cm
.
conf
,
False
).
float
())
if
best_map
>
0.6
:
opt
.
test_num
=
10000
best_map
=
0
eval_result
=
eval
(
test_dataloader
,
faster_rcnn
,
test_num
=
opt
.
test_num
)
if
eval_result
[
'map'
]
>
best_map
:
...
...
trainer.py
浏览文件 @
240a61fd
...
...
@@ -55,6 +55,8 @@ class FasterRCNNTrainer(nn.Module):
self
.
loc_normalize_std
=
faster_rcnn
.
loc_normalize_std
self
.
optimizer
=
self
.
faster_rcnn
.
get_optimizer
()
if
opt
.
use_adam
:
self
.
optimizer
=
self
.
faster_rcnn
.
get_optimizer_adam
()
# visdom wrapper
self
.
vis
=
Visualizer
(
env
=
opt
.
env
)
...
...
@@ -198,7 +200,7 @@ class FasterRCNNTrainer(nn.Module):
save_dict
[
'optimizer'
]
=
self
.
optimizer
.
state_dict
()
if
save_path
is
None
:
timestr
=
time
.
strftime
(
'%m%d
-
%H%M'
)
timestr
=
time
.
strftime
(
'%m%d%H%M'
)
save_path
=
'checkpoints/fasterrcnn_%s'
%
timestr
for
k_
,
v_
in
kwargs
.
items
():
save_path
+=
'_%s'
%
v_
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录