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
c95500cc
Commit
c95500cc
authored
Jul 27, 2020
by
Kaushik Shivakumar
Browse files
updates
parent
ceb406bb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
16 deletions
+7
-16
research/object_detection/core/box_list_ops.py
research/object_detection/core/box_list_ops.py
+1
-10
research/object_detection/core/losses.py
research/object_detection/core/losses.py
+4
-1
research/object_detection/core/region_similarity_calculator.py
...rch/object_detection/core/region_similarity_calculator.py
+2
-4
research/object_detection/core/target_assigner.py
research/object_detection/core/target_assigner.py
+0
-1
No files found.
research/object_detection/core/box_list_ops.py
View file @
c95500cc
...
...
@@ -339,16 +339,12 @@ def giou_loss(boxlist1, boxlist2, scope=None):
Returns:
a tensor with shape [N, M] representing the pairwise GIoU loss.
"""
# Import done internally so this dependency is not required for
# the OD API as a whole.
import
tensorflow_addons
as
tfa
with
tf
.
name_scope
(
scope
,
"PairwiseGIoU"
):
N
=
boxlist1
.
num_boxes
()
M
=
boxlist2
.
num_boxes
()
boxes1
=
tf
.
repeat
(
boxlist1
.
get
(),
repeats
=
M
,
axis
=
0
)
boxes2
=
tf
.
tile
(
boxlist2
.
get
(),
multiples
=
[
N
,
1
])
return
tf
.
reshape
(
tfa
.
losse
s
.
giou
_loss
(
boxes1
,
boxes2
),
[
N
,
M
])
return
tf
.
reshape
(
1.0
-
op
s
.
giou
(
boxes1
,
boxes2
),
[
N
,
M
])
def
matched_iou
(
boxlist1
,
boxlist2
,
scope
=
None
):
"""Compute intersection-over-union between corresponding boxes in boxlists.
...
...
@@ -365,16 +361,11 @@ def matched_iou(boxlist1, boxlist2, scope=None):
intersections
=
matched_intersection
(
boxlist1
,
boxlist2
)
areas1
=
area
(
boxlist1
)
areas2
=
area
(
boxlist2
)
print
(
"AREAS AND INTERSECTION"
,
areas1
,
areas2
,
intersections
)
unions
=
areas1
+
areas2
-
intersections
return
tf
.
where
(
tf
.
equal
(
intersections
,
0.0
),
tf
.
zeros_like
(
intersections
),
tf
.
truediv
(
intersections
,
unions
))
def
matched_giou
(
boxlist1
,
boxlist2
,
scope
=
None
):
with
tf
.
name_scope
(
scope
,
'MatchedGIOU'
):
pass
def
ioa
(
boxlist1
,
boxlist2
,
scope
=
None
):
"""Computes pairwise intersection-over-area between box collections.
...
...
research/object_detection/core/losses.py
View file @
c95500cc
...
...
@@ -37,7 +37,7 @@ from object_detection.core import box_list
from
object_detection.core
import
box_list_ops
from
object_detection.utils
import
ops
from
object_detection.utils
import
shape_utils
import
tensorflow_addons
as
tfa
class
Loss
(
six
.
with_metaclass
(
abc
.
ABCMeta
,
object
)):
"""Abstract base class for loss functions."""
...
...
@@ -181,6 +181,7 @@ class WeightedSmoothL1LocalizationLoss(Loss):
reduction
=
tf
.
losses
.
Reduction
.
NONE
),
axis
=
2
)
class
WeightedIOULocalizationLoss
(
Loss
):
"""IOU localization loss function.
...
...
@@ -209,6 +210,8 @@ class WeightedIOULocalizationLoss(Loss):
target_boxes
)
return
tf
.
reshape
(
weights
,
[
-
1
])
*
per_anchor_iou_loss
class
WeightedGIOULocalizationLoss
(
Loss
):
"""IOU localization loss function.
...
...
research/object_detection/core/region_similarity_calculator.py
View file @
c95500cc
...
...
@@ -31,8 +31,6 @@ import tensorflow.compat.v1 as tf
from
object_detection.core
import
box_list_ops
from
object_detection.core
import
standard_fields
as
fields
EPSILON
=
1e-8
class
RegionSimilarityCalculator
(
six
.
with_metaclass
(
ABCMeta
,
object
)):
"""Abstract base class for region similarity calculator."""
...
...
@@ -109,8 +107,8 @@ class DETRSimiliarity(RegionSimilarityCalculator):
classification_scores
=
tf
.
matmul
(
groundtruth_labels
,
tf
.
nn
.
softmax
(
predicted_labels
),
transpose_b
=
True
)
return
-
5
*
box_list_ops
.
l1
(
boxlist1
,
boxlist2
)
+
\
classification_scores
+
\
2
*
(
1
-
box_list_ops
.
giou_loss
(
boxlist1
,
boxlist2
))
2
*
(
1
-
box_list_ops
.
giou_loss
(
boxlist1
,
boxlist2
))
+
\
classification_scores
class
NegSqDistSimilarity
(
RegionSimilarityCalculator
):
"""Class to compute similarity based on the squared distance metric.
...
...
research/object_detection/core/target_assigner.py
View file @
c95500cc
...
...
@@ -42,7 +42,6 @@ import tensorflow.compat.v2 as tf2
from
object_detection.box_coders
import
faster_rcnn_box_coder
from
object_detection.box_coders
import
mean_stddev_box_coder
from
object_detection.box_coders
import
detr_box_coder
from
object_detection.core
import
box_coder
from
object_detection.core
import
box_list
from
object_detection.core
import
box_list_ops
...
...
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