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
b3d7c348
Commit
b3d7c348
authored
Jul 27, 2021
by
Frederick Liu
Committed by
A. Unique TensorFlower
Jul 27, 2021
Browse files
[vision] Add cycxhwyxyx to box ops.
PiperOrigin-RevId: 387159154
parent
ab87b64e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
official/vision/beta/ops/box_ops.py
official/vision/beta/ops/box_ops.py
+26
-0
No files found.
official/vision/beta/ops/box_ops.py
View file @
b3d7c348
...
...
@@ -78,6 +78,32 @@ def yxyx_to_cycxhw(boxes):
return
new_boxes
def
cycxhw_to_yxyx
(
boxes
):
"""Converts box center coordinates plus height and width terms to corner.
Args:
boxes: a numpy array whose last dimension is 4 representing the coordinates
of boxes in cy, cx, height, width order.
Returns:
boxes: a numpy array whose shape is the same as `boxes` in new format.
Raises:
ValueError: If the last dimension of boxes is not 4.
"""
if
boxes
.
shape
[
-
1
]
!=
4
:
raise
ValueError
(
'boxes.shape[-1] is {:d}, but must be 4.'
.
format
(
boxes
.
shape
[
-
1
]))
boxes_ymin
=
boxes
[...,
0
]
-
boxes
[...,
2
]
/
2
boxes_xmin
=
boxes
[...,
1
]
-
boxes
[...,
3
]
/
2
boxes_ymax
=
boxes
[...,
0
]
+
boxes
[...,
2
]
/
2
boxes_xmax
=
boxes
[...,
1
]
+
boxes
[...,
3
]
/
2
new_boxes
=
tf
.
stack
([
boxes_ymin
,
boxes_xmin
,
boxes_ymax
,
boxes_xmax
],
axis
=-
1
)
return
new_boxes
def
jitter_boxes
(
boxes
,
noise_scale
=
0.025
):
"""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