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
f17d16da
You need to sign in or sign up before continuing.
Commit
f17d16da
authored
Sep 01, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Cascade R-CNN] only train with nonempty boxes
parent
b6318616
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
examples/FasterRCNN/modeling/model_cascade.py
examples/FasterRCNN/modeling/model_cascade.py
+6
-4
No files found.
examples/FasterRCNN/modeling/model_cascade.py
View file @
f17d16da
...
@@ -3,7 +3,7 @@ import tensorflow as tf
...
@@ -3,7 +3,7 @@ import tensorflow as tf
from
tensorpack.tfutils
import
get_current_tower_context
from
tensorpack.tfutils
import
get_current_tower_context
from
config
import
config
as
cfg
from
config
import
config
as
cfg
from
utils.box_ops
import
pairwise_iou
from
utils.box_ops
import
pairwise_iou
,
area
as
tf_area
from
.model_box
import
clip_boxes
from
.model_box
import
clip_boxes
from
.model_frcnn
import
BoxProposals
,
FastRCNNHead
,
fastrcnn_outputs
from
.model_frcnn
import
BoxProposals
,
FastRCNNHead
,
fastrcnn_outputs
...
@@ -27,8 +27,8 @@ class CascadeRCNNHead(object):
...
@@ -27,8 +27,8 @@ class CascadeRCNNHead(object):
self
.
num_cascade_stages
=
len
(
cfg
.
CASCADE
.
IOUS
)
self
.
num_cascade_stages
=
len
(
cfg
.
CASCADE
.
IOUS
)
self
.
is_
training
=
get_current_tower_context
()
.
is_training
self
.
training
=
get_current_tower_context
()
.
is_training
if
self
.
is_
training
:
if
self
.
training
:
@
tf
.
custom_gradient
@
tf
.
custom_gradient
def
scale_gradient
(
x
):
def
scale_gradient
(
x
):
return
x
,
lambda
dy
:
dy
*
(
1.0
/
self
.
num_cascade_stages
)
return
x
,
lambda
dy
:
dy
*
(
1.0
/
self
.
num_cascade_stages
)
...
@@ -72,6 +72,8 @@ class CascadeRCNNHead(object):
...
@@ -72,6 +72,8 @@ class CascadeRCNNHead(object):
refined_boxes
=
head
.
decoded_output_boxes_class_agnostic
()
refined_boxes
=
head
.
decoded_output_boxes_class_agnostic
()
refined_boxes
=
clip_boxes
(
refined_boxes
,
self
.
image_shape2d
)
refined_boxes
=
clip_boxes
(
refined_boxes
,
self
.
image_shape2d
)
if
self
.
training
:
refined_boxes
=
tf
.
boolean_mask
(
refined_boxes
,
tf_area
(
refined_boxes
)
>
0
)
return
head
,
tf
.
stop_gradient
(
refined_boxes
,
name
=
'output_boxes'
)
return
head
,
tf
.
stop_gradient
(
refined_boxes
,
name
=
'output_boxes'
)
def
match_box_with_gt
(
self
,
boxes
,
iou_threshold
):
def
match_box_with_gt
(
self
,
boxes
,
iou_threshold
):
...
@@ -81,7 +83,7 @@ class CascadeRCNNHead(object):
...
@@ -81,7 +83,7 @@ class CascadeRCNNHead(object):
Returns:
Returns:
BoxProposals
BoxProposals
"""
"""
if
self
.
is_
training
:
if
self
.
training
:
with
tf
.
name_scope
(
'match_box_with_gt_{}'
.
format
(
iou_threshold
)):
with
tf
.
name_scope
(
'match_box_with_gt_{}'
.
format
(
iou_threshold
)):
iou
=
pairwise_iou
(
boxes
,
self
.
gt_boxes
)
# NxM
iou
=
pairwise_iou
(
boxes
,
self
.
gt_boxes
)
# NxM
max_iou_per_box
=
tf
.
reduce_max
(
iou
,
axis
=
1
)
# N
max_iou_per_box
=
tf
.
reduce_max
(
iou
,
axis
=
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