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
effc4d51
Commit
effc4d51
authored
Feb 19, 2020
by
A. Unique TensorFlower
Browse files
Move visualization method for Retinanet to utils/visualization_utils.py.
PiperOrigin-RevId: 296077315
parent
1ca9e3e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
official/vision/detection/executor/detection_executor.py
official/vision/detection/executor/detection_executor.py
+2
-4
official/vision/detection/utils/object_detection/visualization_utils.py
...n/detection/utils/object_detection/visualization_utils.py
+18
-0
No files found.
official/vision/detection/executor/detection_executor.py
View file @
effc4d51
...
...
@@ -21,11 +21,9 @@ from __future__ import print_function
from
absl
import
logging
import
os
import
json
import
tensorflow.compat.v2
as
tf
from
official.modeling.training
import
distributed_executor
as
executor
from
official.vision.detection.utils
import
box
_utils
from
official.vision.detection.utils
.object_detection
import
visualization
_utils
class
DetectionDistributedExecutor
(
executor
.
DistributedExecutor
):
...
...
@@ -115,7 +113,7 @@ class DetectionDistributedExecutor(executor.DistributedExecutor):
# TODO(hongjunchoi): Once dynamic slicing is supported on TPU, only
# write correct slice of outputs to summary file.
if
num_remaining_visualizations
>
0
:
box
_utils
.
visualize_bounding_boxes
(
visualization
_utils
.
visualize_
images_with_
bounding_boxes
(
inputs
,
prediction_outputs
[
'detection_boxes'
],
self
.
global_train_step
,
self
.
eval_summary_writer
)
...
...
official/vision/detection/utils/object_detection/visualization_utils.py
View file @
effc4d51
...
...
@@ -32,6 +32,7 @@ import PIL.ImageFont as ImageFont
import
six
import
tensorflow.compat.v2
as
tf
from
official.vision.detection.utils
import
box_utils
from
official.vision.detection.utils.object_detection
import
shape_utils
...
...
@@ -93,6 +94,23 @@ def encode_image_array_as_png_str(image):
return
png_string
def
visualize_images_with_bounding_boxes
(
images
,
box_outputs
,
step
,
summary_writer
):
"""Records subset of evaluation images with bounding boxes."""
image_shape
=
tf
.
shape
(
images
[
0
])
image_height
=
tf
.
cast
(
image_shape
[
0
],
tf
.
float32
)
image_width
=
tf
.
cast
(
image_shape
[
1
],
tf
.
float32
)
normalized_boxes
=
box_utils
.
normalize_boxes
(
box_outputs
,
[
image_height
,
image_width
])
bounding_box_color
=
tf
.
constant
([[
1.0
,
1.0
,
0.0
,
1.0
]])
image_summary
=
tf
.
image
.
draw_bounding_boxes
(
images
,
normalized_boxes
,
bounding_box_color
)
with
summary_writer
.
as_default
():
tf
.
summary
.
image
(
'bounding_box_summary'
,
image_summary
,
step
=
step
)
summary_writer
.
flush
()
def
draw_bounding_box_on_image_array
(
image
,
ymin
,
xmin
,
...
...
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