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
4afec6ba
Commit
4afec6ba
authored
Jul 26, 2021
by
Frederick Liu
Committed by
A. Unique TensorFlower
Jul 26, 2021
Browse files
[vision] Add yxyxtocxcyhw to box ops.
PiperOrigin-RevId: 386977208
parent
b26a5ca6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
official/vision/beta/ops/box_ops.py
official/vision/beta/ops/box_ops.py
+28
-0
No files found.
official/vision/beta/ops/box_ops.py
View file @
4afec6ba
...
@@ -50,6 +50,34 @@ def yxyx_to_xywh(boxes):
...
@@ -50,6 +50,34 @@ def yxyx_to_xywh(boxes):
return
new_boxes
return
new_boxes
def
yxyx_to_cycxhw
(
boxes
):
"""Converts box corner coordinates to center plus height and width terms.
Args:
boxes: a `Tensor` with last dimension of 4, representing the coordinates of
boxes in ymin, xmin, ymax, xmax order.
Returns:
boxes: a `Tensor` with the same shape as the inputted boxes, in the format
of cy, cx, height, width.
Raises:
ValueError: if the last dimension of boxes is not 4.
"""
if
boxes
.
shape
[
-
1
]
!=
4
:
raise
ValueError
(
'Last dimension of boxes must be 4 but is {:d}'
.
format
(
boxes
.
shape
[
-
1
]))
boxes_ycenter
=
(
boxes
[...,
0
]
+
boxes
[...,
2
])
/
2
boxes_xcenter
=
(
boxes
[...,
1
]
+
boxes
[...,
3
])
/
2
boxes_height
=
boxes
[...,
2
]
-
boxes
[...,
0
]
boxes_width
=
boxes
[...,
3
]
-
boxes
[...,
1
]
new_boxes
=
tf
.
stack
(
[
boxes_ycenter
,
boxes_xcenter
,
boxes_height
,
boxes_width
],
axis
=-
1
)
return
new_boxes
def
jitter_boxes
(
boxes
,
noise_scale
=
0.025
):
def
jitter_boxes
(
boxes
,
noise_scale
=
0.025
):
"""Jitter the box coordinates by some noise distribution.
"""Jitter the box coordinates by some noise distribution.
...
...
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