Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
1ed7ef39
Commit
1ed7ef39
authored
Aug 20, 2020
by
Kaushik Shivakumar
Browse files
fix naming
parent
e350c59c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
37 deletions
+37
-37
research/object_detection/core/target_assigner.py
research/object_detection/core/target_assigner.py
+37
-37
No files found.
research/object_detection/core/target_assigner.py
View file @
1ed7ef39
...
@@ -1982,86 +1982,86 @@ class DETRTargetAssigner(object):
...
@@ -1982,86 +1982,86 @@ class DETRTargetAssigner(object):
batch_reg_weights
)
batch_reg_weights
)
def
assign
(
self
,
def
assign
(
self
,
box_
preds
,
pred
_boxe
s
,
g
roundtruth
_boxes
,
g
t
_boxes
,
pred_class
_batch
,
pred_class
es
,
g
roundtruth
_labels
,
g
t
_labels
,
g
roundtruth
_weights
=
None
):
g
t
_weights
=
None
):
"""Assign classification and regression targets to each box_pred.
"""Assign classification and regression targets to each box_pred.
For a given set of
box_
preds and groundtruth detections, match
box_
preds
For a given set of pred
_boxe
s and groundtruth detections, match pred
_boxe
s
to g
roundtruth
_boxes and assign classification and regression targets to
to g
t
_boxes and assign classification and regression targets to
each box_pred as well as weights based on the resulting match (specifying,
each box_pred as well as weights based on the resulting match (specifying,
e.g., which
box_
preds should not contribute to training loss).
e.g., which pred
_boxe
s should not contribute to training loss).
box_
preds that are not matched to anything are given a classification target
pred
_boxe
s that are not matched to anything are given a classification target
of self._unmatched_cls_target which can be specified via the constructor.
of self._unmatched_cls_target which can be specified via the constructor.
Args:
Args:
box_
preds: a BoxList representing N
box_
preds
pred
_boxe
s: a BoxList representing N pred
_boxe
s
g
roundtruth
_boxes: a BoxList representing M groundtruth boxes
g
t
_boxes: a BoxList representing M groundtruth boxes
pred_class
_batch
: A tensor with shape [max_num_boxes, num_classes]
pred_class
es
: A tensor with shape [max_num_boxes, num_classes]
to be used by certain similarity calculators.
to be used by certain similarity calculators.
g
roundtruth
_labels: a tensor of shape [M, num_classes]
g
t
_labels: a tensor of shape [M, num_classes]
with labels for each of the ground_truth boxes. The subshape
with labels for each of the ground_truth boxes. The subshape
[num_classes] can be empty (corresponding to scalar inputs). When set
[num_classes] can be empty (corresponding to scalar inputs). When set
to None, g
roundtruth
_labels assumes a binary problem where all
to None, g
t
_labels assumes a binary problem where all
ground_truth boxes get a positive label (of 1).
ground_truth boxes get a positive label (of 1).
g
roundtruth
_weights: a float tensor of shape [M] indicating the weight to
g
t
_weights: a float tensor of shape [M] indicating the weight to
assign to all
box_
preds match to a particular groundtruth box. The
assign to all pred
_boxe
s match to a particular groundtruth box. The
weights must be in [0., 1.]. If None, all weights are set to 1.
weights must be in [0., 1.]. If None, all weights are set to 1.
Generally no groundtruth boxes with zero weight match to any
box_
preds
Generally no groundtruth boxes with zero weight match to any pred
_boxe
s
as matchers are aware of groundtruth weights. Additionally,
as matchers are aware of groundtruth weights. Additionally,
`cls_weights` and `reg_weights` are calculated using groundtruth
`cls_weights` and `reg_weights` are calculated using groundtruth
weights as an added safety.
weights as an added safety.
Returns:
Returns:
cls_targets: a float32 tensor with shape [num_
box_
preds, num_classes],
cls_targets: a float32 tensor with shape [num_pred
_boxe
s, num_classes],
where the subshape [num_classes] is compatible with g
roundtruth
_labels
where the subshape [num_classes] is compatible with g
t
_labels
which has shape [num_gt_boxes, num_classes].
which has shape [num_gt_boxes, num_classes].
cls_weights: a float32 tensor with shape [num_
box_
preds, num_classes],
cls_weights: a float32 tensor with shape [num_pred
_boxe
s, num_classes],
representing weights for each element in cls_targets.
representing weights for each element in cls_targets.
reg_targets: a float32 tensor with shape [num_
box_
preds,
reg_targets: a float32 tensor with shape [num_pred
_boxe
s,
box_code_dimension]
box_code_dimension]
reg_weights: a float32 tensor with shape [num_
box_
preds]
reg_weights: a float32 tensor with shape [num_pred
_boxe
s]
"""
"""
unmatched_class_label
=
tf
.
constant
(
unmatched_class_label
=
tf
.
constant
(
[
1
]
+
[
0
]
*
(
g
roundtruth
_labels
.
shape
[
1
]
-
1
),
tf
.
float32
)
[
1
]
+
[
0
]
*
(
g
t
_labels
.
shape
[
1
]
-
1
),
tf
.
float32
)
if
g
roundtruth
_weights
is
None
:
if
g
t
_weights
is
None
:
num_gt_boxes
=
g
roundtruth
_boxes
.
num_boxes_static
()
num_gt_boxes
=
g
t
_boxes
.
num_boxes_static
()
if
not
num_gt_boxes
:
if
not
num_gt_boxes
:
num_gt_boxes
=
g
roundtruth
_boxes
.
num_boxes
()
num_gt_boxes
=
g
t
_boxes
.
num_boxes
()
g
roundtruth
_weights
=
tf
.
ones
([
num_gt_boxes
],
dtype
=
tf
.
float32
)
g
t
_weights
=
tf
.
ones
([
num_gt_boxes
],
dtype
=
tf
.
float32
)
g
roundtruth
_boxes
.
add_field
(
fields
.
BoxListFields
.
classes
,
g
t
_boxes
.
add_field
(
fields
.
BoxListFields
.
classes
,
g
roundtruth
_labels
)
g
t
_labels
)
box_
preds
.
add_field
(
fields
.
BoxListFields
.
classes
,
pred_class
_batch
)
pred
_boxe
s
.
add_field
(
fields
.
BoxListFields
.
classes
,
pred_class
es
)
match_quality_matrix
=
self
.
_similarity_calc
.
compare
(
match_quality_matrix
=
self
.
_similarity_calc
.
compare
(
g
roundtruth
_boxes
,
g
t
_boxes
,
box_
preds
)
pred
_boxe
s
)
match
=
self
.
_matcher
.
match
(
match_quality_matrix
,
match
=
self
.
_matcher
.
match
(
match_quality_matrix
,
valid_rows
=
tf
.
greater
(
g
roundtruth
_weights
,
0
))
valid_rows
=
tf
.
greater
(
g
t
_weights
,
0
))
matched_gt_boxes
=
match
.
gather_based_on_match
(
matched_gt_boxes
=
match
.
gather_based_on_match
(
g
roundtruth
_boxes
.
get
(),
g
t
_boxes
.
get
(),
unmatched_value
=
tf
.
zeros
(
4
),
unmatched_value
=
tf
.
zeros
(
4
),
ignored_value
=
tf
.
zeros
(
4
))
ignored_value
=
tf
.
zeros
(
4
))
matched_gt_boxlist
=
box_list
.
BoxList
(
matched_gt_boxes
)
matched_gt_boxlist
=
box_list
.
BoxList
(
matched_gt_boxes
)
ty
,
tx
,
th
,
tw
=
matched_gt_boxlist
.
get_center_coordinates_and_sizes
()
ty
,
tx
,
th
,
tw
=
matched_gt_boxlist
.
get_center_coordinates_and_sizes
()
reg_targets
=
tf
.
transpose
(
tf
.
stack
([
ty
,
tx
,
th
,
tw
]))
reg_targets
=
tf
.
transpose
(
tf
.
stack
([
ty
,
tx
,
th
,
tw
]))
cls_targets
=
match
.
gather_based_on_match
(
cls_targets
=
match
.
gather_based_on_match
(
g
roundtruth
_labels
,
g
t
_labels
,
unmatched_value
=
unmatched_class_label
,
unmatched_value
=
unmatched_class_label
,
ignored_value
=
unmatched_class_label
)
ignored_value
=
unmatched_class_label
)
reg_weights
=
match
.
gather_based_on_match
(
reg_weights
=
match
.
gather_based_on_match
(
g
roundtruth
_weights
,
g
t
_weights
,
ignored_value
=
0.
,
ignored_value
=
0.
,
unmatched_value
=
0.
)
unmatched_value
=
0.
)
cls_weights
=
match
.
gather_based_on_match
(
cls_weights
=
match
.
gather_based_on_match
(
g
roundtruth
_weights
,
g
t
_weights
,
ignored_value
=
0.
,
ignored_value
=
0.
,
unmatched_value
=
1
)
unmatched_value
=
1
)
...
...
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