Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
1ae8b540
Commit
1ae8b540
authored
Nov 20, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MaskRCNN] refactor into generalized rcnn
parent
55603b75
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
83 deletions
+104
-83
examples/FasterRCNN/README.md
examples/FasterRCNN/README.md
+3
-3
examples/FasterRCNN/config.py
examples/FasterRCNN/config.py
+2
-2
examples/FasterRCNN/model_fpn.py
examples/FasterRCNN/model_fpn.py
+5
-5
examples/FasterRCNN/model_frcnn.py
examples/FasterRCNN/model_frcnn.py
+1
-1
examples/FasterRCNN/model_rpn.py
examples/FasterRCNN/model_rpn.py
+1
-1
examples/FasterRCNN/train.py
examples/FasterRCNN/train.py
+92
-71
No files found.
examples/FasterRCNN/README.md
View file @
1ae8b540
...
...
@@ -91,9 +91,9 @@ Mask R-CNN results contain both box and mask mAP.
| R50-FPN | 42.0;36.3 | | 41h |
<details><summary>
+Cascade
</summary>
`MODE_FPN=True FPN.CASCADE=True`
</details>
|
| R50-FPN | 39.5;35.2 | 39.5;34.4
<sup>
[
2
](
#ft2
)
</sup>
| 33h |
<details><summary>
+ConvGNHead
</summary>
`MODE_FPN=True`
<br/>
`FPN.FRCNN_HEAD_FUNC=fastrcnn_4conv1fc_gn_head`
</details>
|
| R50-FPN | 40.0;36.2
[
:arrow_down:
](
http://models.tensorpack.com/FasterRCNN/COCO-R50FPN-MaskRCNN-StandardGN.npz
)
| 40.3;35.7 | 40h |
<details><summary>
+GN
</summary>
`MODE_FPN=True`
<br/>
`FPN.NORM=GN BACKBONE.NORM=GN`
<br/>
`FPN.FRCNN_HEAD_FUNC=fastrcnn_4conv1fc_gn_head`
<br/>
`FPN.MRCNN_HEAD_FUNC=maskrcnn_up4conv_gn_head`
|
| R101-C4 | 41.4;35.2
[
:arrow_down:
](
http://models.tensorpack.com/FasterRCNN/COCO-R101C4-MaskRCNN-Standard.npz
)
| | 60h |
<details><summary>
standard
</summary>
`BACKBONE.RESNET_NUM_BLOCK=[3,4,23,3]`
</details>
|
| R101-FPN | 40.4;36.6
[
:arrow_down:
](
http://models.tensorpack.com/FasterRCNN/COCO-R101FPN-MaskRCNN-Standard.npz
)
| 40.9;36.4 | 38h |
<details><summary>
standard
</summary>
`MODE_FPN=True`
<br/>
`BACKBONE.RESNET_NUM_BLOCK=[3,4,23,3]`
</details>
|
| R101-FPN | 46.5;40.1
[
:arrow_down:
](
http://models.tensorpack.com/FasterRCNN/COCO-R101FPN-MaskRCNN-BetterParams.npz
)
<sup>
[
3
](
#ft3
)
</sup>
| | 73h |
<details><summary>
+++
</summary>
`MODE_FPN=True FPN.CASCADE=True`
<br/>
`BACKBONE.RESNET_NUM_BLOCK=[3,4,23,3]`
<br/>
`TEST.RESULT_SCORE_THRESH=1e-4`
<br/>
`PREPROC.TRAIN_SHORT_EDGE_SIZE=[640,800]`
<br/>
`TRAIN.LR_SCHEDULE=[420000,500000,540000]`
</details>
|
| R101-C4 | 41.4;35.2
[
:arrow_down:
](
http://models.tensorpack.com/FasterRCNN/COCO-R101C4-MaskRCNN-Standard.npz
)
| | 60h |
<details><summary>
standard
</summary>
`BACKBONE.RESNET_NUM_BLOCK
S
=[3,4,23,3]`
</details>
|
| R101-FPN | 40.4;36.6
[
:arrow_down:
](
http://models.tensorpack.com/FasterRCNN/COCO-R101FPN-MaskRCNN-Standard.npz
)
| 40.9;36.4 | 38h |
<details><summary>
standard
</summary>
`MODE_FPN=True`
<br/>
`BACKBONE.RESNET_NUM_BLOCK
S
=[3,4,23,3]`
</details>
|
| R101-FPN | 46.5;40.1
[
:arrow_down:
](
http://models.tensorpack.com/FasterRCNN/COCO-R101FPN-MaskRCNN-BetterParams.npz
)
<sup>
[
3
](
#ft3
)
</sup>
| | 73h |
<details><summary>
+++
</summary>
`MODE_FPN=True FPN.CASCADE=True`
<br/>
`BACKBONE.RESNET_NUM_BLOCK
S
=[3,4,23,3]`
<br/>
`TEST.RESULT_SCORE_THRESH=1e-4`
<br/>
`PREPROC.TRAIN_SHORT_EDGE_SIZE=[640,800]`
<br/>
`TRAIN.LR_SCHEDULE=[420000,500000,540000]`
</details>
|
<a
id=
"ft1"
>
1
</a>
: Here we comapre models that have identical training & inference cost between the two implementation. However their numbers are different due to many small implementation details.
...
...
examples/FasterRCNN/config.py
View file @
1ae8b540
...
...
@@ -86,8 +86,8 @@ _C.DATA.CLASS_NAMES = [] # NUM_CLASS (NUM_CATEGORY+1) strings, to be populated
# basemodel ----------------------
_C
.
BACKBONE
.
WEIGHTS
=
''
# /path/to/weights.npz
_C
.
BACKBONE
.
RESNET_NUM_BLOCK
=
[
3
,
4
,
6
,
3
]
# for resnet50
# RESNET_NUM_BLOCK = [3, 4, 23, 3] # for resnet101
_C
.
BACKBONE
.
RESNET_NUM_BLOCK
S
=
[
3
,
4
,
6
,
3
]
# for resnet50
# RESNET_NUM_BLOCK
S
= [3, 4, 23, 3] # for resnet101
_C
.
BACKBONE
.
FREEZE_AFFINE
=
False
# do not train affine parameters inside norm layers
_C
.
BACKBONE
.
NORM
=
'FreezeBN'
# options: FreezeBN, SyncBN, GN
_C
.
BACKBONE
.
FREEZE_AT
=
2
# options: 0, 1, 2
...
...
examples/FasterRCNN/model_fpn.py
View file @
1ae8b540
...
...
@@ -160,7 +160,7 @@ def multilevel_rpn_losses(
total_label_loss
=
tf
.
add_n
(
losses
[::
2
],
name
=
'label_loss'
)
total_box_loss
=
tf
.
add_n
(
losses
[
1
::
2
],
name
=
'box_loss'
)
add_moving_summary
(
total_label_loss
,
total_box_loss
)
return
total_label_loss
,
total_box_loss
return
[
total_label_loss
,
total_box_loss
]
@
under_name_scope
()
...
...
@@ -179,11 +179,11 @@ def generate_fpn_proposals(
assert
len
(
multilevel_pred_boxes
)
==
num_lvl
assert
len
(
multilevel_label_logits
)
==
num_lvl
ctx
=
get_current_tower_context
()
training
=
get_current_tower_context
()
.
is_training
all_boxes
=
[]
all_scores
=
[]
if
cfg
.
FPN
.
PROPOSAL_MODE
==
'Level'
:
fpn_nms_topk
=
cfg
.
RPN
.
TRAIN_PER_LEVEL_NMS_TOPK
if
ctx
.
is_
training
else
cfg
.
RPN
.
TEST_PER_LEVEL_NMS_TOPK
fpn_nms_topk
=
cfg
.
RPN
.
TRAIN_PER_LEVEL_NMS_TOPK
if
training
else
cfg
.
RPN
.
TEST_PER_LEVEL_NMS_TOPK
for
lvl
in
range
(
num_lvl
):
with
tf
.
name_scope
(
'Lvl{}'
.
format
(
lvl
+
2
)):
pred_boxes_decoded
=
multilevel_pred_boxes
[
lvl
]
...
...
@@ -210,8 +210,8 @@ def generate_fpn_proposals(
all_scores
=
tf
.
concat
(
all_scores
,
axis
=
0
)
proposal_boxes
,
proposal_scores
=
generate_rpn_proposals
(
all_boxes
,
all_scores
,
image_shape2d
,
cfg
.
RPN
.
TRAIN_PRE_NMS_TOPK
if
ctx
.
is_
training
else
cfg
.
RPN
.
TEST_PRE_NMS_TOPK
,
cfg
.
RPN
.
TRAIN_POST_NMS_TOPK
if
ctx
.
is_
training
else
cfg
.
RPN
.
TEST_POST_NMS_TOPK
)
cfg
.
RPN
.
TRAIN_PRE_NMS_TOPK
if
training
else
cfg
.
RPN
.
TEST_PRE_NMS_TOPK
,
cfg
.
RPN
.
TRAIN_POST_NMS_TOPK
if
training
else
cfg
.
RPN
.
TEST_POST_NMS_TOPK
)
tf
.
sigmoid
(
proposal_scores
,
name
=
'probs'
)
# for visualization
return
tf
.
stop_gradient
(
proposal_boxes
,
name
=
'boxes'
),
\
...
...
examples/FasterRCNN/model_frcnn.py
View file @
1ae8b540
...
...
@@ -171,7 +171,7 @@ def fastrcnn_losses(labels, label_logits, fg_boxes, fg_box_logits):
add_moving_summary
(
label_loss
,
box_loss
,
accuracy
,
fg_accuracy
,
false_negative
,
tf
.
to_float
(
num_fg
,
name
=
'num_fg_label'
))
return
label_loss
,
box_loss
return
[
label_loss
,
box_loss
]
@
under_name_scope
()
...
...
examples/FasterRCNN/model_rpn.py
View file @
1ae8b540
...
...
@@ -98,7 +98,7 @@ def rpn_losses(anchor_labels, anchor_boxes, label_logits, box_logits):
box_loss
=
tf
.
where
(
tf
.
equal
(
nr_pos
,
0
),
placeholder
,
box_loss
,
name
=
'box_loss'
)
add_moving_summary
(
label_loss
,
box_loss
,
nr_valid
,
nr_pos
)
return
label_loss
,
box_loss
return
[
label_loss
,
box_loss
]
@
under_name_scope
()
...
...
examples/FasterRCNN/train.py
View file @
1ae8b540
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment