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
17c25692
Commit
17c25692
authored
Jul 16, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MaskRCNN] don't use default args, they are evaluated too early
parent
0050d6e7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
examples/FasterRCNN/data.py
examples/FasterRCNN/data.py
+12
-7
examples/FasterRCNN/model_fpn.py
examples/FasterRCNN/model_fpn.py
+1
-0
No files found.
examples/FasterRCNN/data.py
View file @
17c25692
...
...
@@ -29,9 +29,7 @@ class MalformedData(BaseException):
@
memoized
def
get_all_anchors
(
stride
=
cfg
.
RPN
.
ANCHOR_STRIDE
,
sizes
=
cfg
.
RPN
.
ANCHOR_SIZES
):
def
get_all_anchors
(
stride
=
None
,
sizes
=
None
):
"""
Get all anchors in the largest possible image, shifted, floatbox
Args:
...
...
@@ -43,6 +41,10 @@ def get_all_anchors(
The layout in the NUM_ANCHOR dim is NUM_RATIO x NUM_SIZE.
"""
if
stride
is
None
:
stride
=
cfg
.
RPN
.
ANCHOR_STRIDE
if
sizes
is
None
:
sizes
=
cfg
.
RPN
.
ANCHOR_SIZES
# Generates a NAx4 matrix of anchor boxes in (x1, y1, x2, y2) format. Anchors
# are centered on stride / 2, have (approximate) sqrt areas of the specified
# sizes, and aspect ratios as given.
...
...
@@ -69,20 +71,23 @@ def get_all_anchors(
shifts
.
reshape
((
1
,
K
,
4
))
.
transpose
((
1
,
0
,
2
)))
field_of_anchors
=
field_of_anchors
.
reshape
((
field_size
,
field_size
,
A
,
4
))
# FSxFSxAx4
assert
np
.
all
(
field_of_anchors
==
field_of_anchors
.
astype
(
'int32'
))
# Many rounding happens inside the anchor code anyway
# assert np.all(field_of_anchors == field_of_anchors.astype('int32'))
field_of_anchors
=
field_of_anchors
.
astype
(
'float32'
)
field_of_anchors
[:,
:,
:,
[
2
,
3
]]
+=
1
return
field_of_anchors
@
memoized
def
get_all_anchors_fpn
(
strides
=
cfg
.
FPN
.
ANCHOR_STRIDES
,
sizes
=
cfg
.
RPN
.
ANCHOR_SIZES
):
def
get_all_anchors_fpn
(
strides
=
None
,
sizes
=
None
):
"""
Returns:
[anchors]: each anchors is a SxSx NUM_ANCHOR_RATIOS x4 array.
"""
if
strides
is
None
:
strides
=
cfg
.
FPN
.
ANCHOR_STRIDES
if
sizes
is
None
:
sizes
=
cfg
.
RPN
.
ANCHOR_SIZES
assert
len
(
strides
)
==
len
(
sizes
)
foas
=
[]
for
stride
,
size
in
zip
(
strides
,
sizes
):
...
...
examples/FasterRCNN/model_fpn.py
View file @
17c25692
...
...
@@ -122,6 +122,7 @@ def multilevel_roi_align(features, rcnn_boxes, resolution):
boxes_on_featuremap
=
boxes
*
(
1.0
/
cfg
.
FPN
.
ANCHOR_STRIDES
[
i
])
all_rois
.
append
(
roi_align
(
featuremap
,
boxes_on_featuremap
,
resolution
))
# this can fail if using TF<=1.8 with MKL build
all_rois
=
tf
.
concat
(
all_rois
,
axis
=
0
)
# NCHW
# Unshuffle to the original order, to match the original samples
level_id_perm
=
tf
.
concat
(
level_ids
,
axis
=
0
)
# A permutation of 1~N
...
...
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