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
473f34aa
Commit
473f34aa
authored
May 23, 2022
by
Liangzhe Yuan
Committed by
A. Unique TensorFlower
May 23, 2022
Browse files
Add horizontal_flip_box in box_ops.
PiperOrigin-RevId: 450545434
parent
2eb57715
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
official/vision/ops/box_ops.py
official/vision/ops/box_ops.py
+22
-0
No files found.
official/vision/ops/box_ops.py
View file @
473f34aa
...
...
@@ -217,6 +217,28 @@ def denormalize_boxes(boxes, image_shape):
return
denormalized_boxes
def
horizontal_flip_boxes
(
normalized_boxes
):
"""Flips normalized boxes horizontally.
Args:
normalized_boxes: the boxes in normalzied coordinates.
Returns:
horizontally flipped boxes.
"""
if
normalized_boxes
.
shape
[
-
1
]
!=
4
:
raise
ValueError
(
'boxes.shape[-1] is {:d}, but must be 4.'
.
format
(
normalized_boxes
.
shape
[
-
1
]))
with
tf
.
name_scope
(
'horizontal_flip_boxes'
):
ymin
,
xmin
,
ymax
,
xmax
=
tf
.
split
(
value
=
normalized_boxes
,
num_or_size_splits
=
4
,
axis
=-
1
)
flipped_xmin
=
tf
.
subtract
(
1.0
,
xmax
)
flipped_xmax
=
tf
.
subtract
(
1.0
,
xmin
)
flipped_boxes
=
tf
.
concat
([
ymin
,
flipped_xmin
,
ymax
,
flipped_xmax
],
axis
=-
1
)
return
flipped_boxes
def
clip_boxes
(
boxes
,
image_shape
):
"""Clips boxes to image boundaries.
...
...
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