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
87fbcfec
Commit
87fbcfec
authored
Jul 24, 2020
by
Kaushik Shivakumar
Browse files
fixes to sequence example utils
parent
9da43afc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
research/object_detection/dataset_tools/create_ava_tf_record.py
...ch/object_detection/dataset_tools/create_ava_tf_record.py
+1
-1
research/object_detection/dataset_tools/seq_example_util.py
research/object_detection/dataset_tools/seq_example_util.py
+21
-4
research/object_detection/dataset_tools/seq_example_util_test.py
...h/object_detection/dataset_tools/seq_example_util_test.py
+2
-1
No files found.
research/object_detection/dataset_tools/create_ava_tf_record.py
View file @
87fbcfec
...
@@ -264,7 +264,7 @@ class Ava(object):
...
@@ -264,7 +264,7 @@ class Ava(object):
print
(
total_boxes
)
print
(
total_boxes
)
yield
seq_example_util
.
make_sequence_example
(
"AVA"
,
media_id
,
total_images
,
yield
seq_example_util
.
make_sequence_example
(
"AVA"
,
media_id
,
total_images
,
int
(
height
),
int
(
width
),
'jpeg'
,
total_source_ids
,
None
,
total_is_annotated
,
int
(
height
),
int
(
width
),
'jpeg'
,
total_source_ids
,
None
,
total_is_annotated
,
total_boxes
,
total_label_strings
)
total_boxes
,
total_label_strings
,
use_strs_for_source_id
=
True
)
#Move middle_time_frame, skipping excluded frames
#Move middle_time_frame, skipping excluded frames
frames_mv
=
0
frames_mv
=
0
...
...
research/object_detection/dataset_tools/seq_example_util.py
View file @
87fbcfec
...
@@ -122,6 +122,13 @@ def sequence_bytes_feature(ndarray):
...
@@ -122,6 +122,13 @@ def sequence_bytes_feature(ndarray):
feature
.
bytes_list
.
value
[:]
=
row
feature
.
bytes_list
.
value
[:]
=
row
return
feature_list
return
feature_list
def
sequence_strings_feature
(
strings
):
new_str_arr
=
[]
for
str
in
strings
:
new_str_arr
.
append
(
tf
.
train
.
Feature
(
bytes_list
=
tf
.
train
.
BytesList
(
value
=
[
str
.
encode
(
"utf8"
)])))
return
tf
.
train
.
FeatureList
(
feature
=
new_str_arr
)
def
boxes_to_box_components
(
bboxes
):
def
boxes_to_box_components
(
bboxes
):
"""Converts a list of numpy arrays (boxes) to box components.
"""Converts a list of numpy arrays (boxes) to box components.
...
@@ -137,8 +144,11 @@ def boxes_to_box_components(bboxes):
...
@@ -137,8 +144,11 @@ def boxes_to_box_components(bboxes):
ymax_list
=
[]
ymax_list
=
[]
xmax_list
=
[]
xmax_list
=
[]
for
bbox
in
bboxes
:
for
bbox
in
bboxes
:
bbox
=
np
.
array
(
bbox
).
astype
(
np
.
float32
)
if
bbox
!=
[]:
ymin
,
xmin
,
ymax
,
xmax
=
np
.
split
(
bbox
,
4
,
axis
=
1
)
bbox
=
np
.
array
(
bbox
).
astype
(
np
.
float32
)
ymin
,
xmin
,
ymax
,
xmax
=
np
.
split
(
bbox
,
4
,
axis
=
1
)
else
:
ymin
,
xmin
,
ymax
,
xmax
=
[],
[],
[],
[]
ymin_list
.
append
(
np
.
reshape
(
ymin
,
[
-
1
]))
ymin_list
.
append
(
np
.
reshape
(
ymin
,
[
-
1
]))
xmin_list
.
append
(
np
.
reshape
(
xmin
,
[
-
1
]))
xmin_list
.
append
(
np
.
reshape
(
xmin
,
[
-
1
]))
ymax_list
.
append
(
np
.
reshape
(
ymax
,
[
-
1
]))
ymax_list
.
append
(
np
.
reshape
(
ymax
,
[
-
1
]))
...
@@ -159,7 +169,8 @@ def make_sequence_example(dataset_name,
...
@@ -159,7 +169,8 @@ def make_sequence_example(dataset_name,
label_strings
=
None
,
label_strings
=
None
,
detection_bboxes
=
None
,
detection_bboxes
=
None
,
detection_classes
=
None
,
detection_classes
=
None
,
detection_scores
=
None
):
detection_scores
=
None
,
use_strs_for_source_id
=
False
):
"""Constructs tf.SequenceExamples.
"""Constructs tf.SequenceExamples.
Args:
Args:
...
@@ -217,11 +228,17 @@ def make_sequence_example(dataset_name,
...
@@ -217,11 +228,17 @@ def make_sequence_example(dataset_name,
'image/timestamp'
:
sequence_int64_feature
(
image_timestamps
),
'image/timestamp'
:
sequence_int64_feature
(
image_timestamps
),
}
}
print
(
"Source IDs"
,
image_source_ids
)
# Add optional fields.
# Add optional fields.
if
image_format
is
not
None
:
if
image_format
is
not
None
:
context_dict
[
'image/format'
]
=
context_bytes_feature
([
image_format
])
context_dict
[
'image/format'
]
=
context_bytes_feature
([
image_format
])
if
image_source_ids
is
not
None
:
if
image_source_ids
is
not
None
:
feature_list
[
'image/source_id'
]
=
sequence_bytes_feature
(
image_source_ids
)
if
(
use_strs_for_source_id
):
feature_list
[
'image/source_id'
]
=
sequence_strings_feature
(
image_source_ids
)
else
:
feature_list
[
'image/source_id'
]
=
sequence_bytes_feature
(
image_source_ids
)
if
bboxes
is
not
None
:
if
bboxes
is
not
None
:
bbox_ymin
,
bbox_xmin
,
bbox_ymax
,
bbox_xmax
=
boxes_to_box_components
(
bboxes
)
bbox_ymin
,
bbox_xmin
,
bbox_ymax
,
bbox_xmax
=
boxes_to_box_components
(
bboxes
)
feature_list
[
'region/bbox/xmin'
]
=
sequence_float_feature
(
bbox_xmin
)
feature_list
[
'region/bbox/xmin'
]
=
sequence_float_feature
(
bbox_xmin
)
...
...
research/object_detection/dataset_tools/seq_example_util_test.py
View file @
87fbcfec
...
@@ -122,7 +122,8 @@ class SeqExampleUtilTest(tf.test.TestCase):
...
@@ -122,7 +122,8 @@ class SeqExampleUtilTest(tf.test.TestCase):
bboxes
=
[
bboxes
=
[
np
.
array
([[
0.
,
0.
,
0.
,
0.
],
np
.
array
([[
0.
,
0.
,
0.
,
0.
],
[
0.
,
0.
,
1.
,
1.
]],
dtype
=
np
.
float32
),
[
0.
,
0.
,
1.
,
1.
]],
dtype
=
np
.
float32
),
np
.
zeros
([
0
,
4
],
dtype
=
np
.
float32
)
np
.
zeros
([
0
,
4
],
dtype
=
np
.
float32
),
np
.
array
([],
dtype
=
np
.
float32
)
]
]
label_strings
=
[
label_strings
=
[
np
.
array
(
labels
),
np
.
array
(
labels
),
...
...
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