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
c987d27c
"git@developer.sourcefind.cn:modelzoo/resnet50_tensorflow.git" did not exist on "8a72df2d8c62f7ffa2d58995fc5d484e47955546"
Commit
c987d27c
authored
Aug 16, 2020
by
Kaushik Shivakumar
Browse files
clean up label map reading and other fixes
parent
b152ed9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
36 deletions
+6
-36
research/object_detection/dataset_tools/create_ava_actions_tf_record.py
...t_detection/dataset_tools/create_ava_actions_tf_record.py
+6
-36
No files found.
research/object_detection/dataset_tools/create_ava_actions_tf_record.py
View file @
c987d27c
...
@@ -456,47 +456,17 @@ class Ava(object):
...
@@ -456,47 +456,17 @@ class Ava(object):
SPLITS
[
split
][
"excluded-csv"
]
=
excluded_csv_path
SPLITS
[
split
][
"excluded-csv"
]
=
excluded_csv_path
paths
[
split
]
=
(
csv_path
,
excluded_csv_path
)
paths
[
split
]
=
(
csv_path
,
excluded_csv_path
)
#
label_map = self.get_label_map(os.path.join(
self.path_to_data_download, "ava_action_list_v2.2.pbtxt"))
label_map
=
self
.
get_label_map
(
os
.
path
.
join
(
#
self
.
path_to_data_download
,
label_map
=
self
.
get_label_map
(
"object_detection/data/mscoco_label_map
.pbtxt"
)
"ava_action_list_v2.2_for_activitynet_2019
.pbtxt"
)
)
return
paths
,
label_map
return
paths
,
label_map
def
get_label_map
(
self
,
path
):
def
get_label_map
(
self
,
path
):
"""Parses a label map into {integer:string} format."""
"""Parses a label map into {integer:string} format."""
label_map
=
{}
label_map_dict
=
label_map_util
.
get_label_map_dict
(
path
)
label_map
=
label_map_util
.
load_labelmap
(
path
)
label_map_dict
=
{
v
:
bytes
(
k
,
"utf8"
)
for
k
,
v
in
label_map_dict
.
items
()}
print
(
label_map
)
label_map_dict
=
{}
for
item
in
label_map
.
item
:
label_map_dict
[
item
.
name
]
=
item
.
label_id
with
open
(
path
,
"rb"
)
as
f
:
#label_map_util.load_labelmap()
#label_map_str = f.read()
#print(str(label_map_str))
#label_map = string_int_label_map_pb2.StringIntLabelMap()
#label_map.ParseFromString(label_map_str)
pass
"""
current_id = -1
current_label = ""
for line in f:
if "item {" in line:
current_id = -1
current_label = ""
if "name:" in line:
first_quote = line.find('"') + 1
second_quote = line.find('"', first_quote)
assert second_quote > -1
current_label = line[first_quote:second_quote]
if "id:" in line:
current_id = int(line.split()[1])
if "}" in line:
label_map[current_id] = bytes(current_label, "utf8")"""
print
(
'label map dict'
)
logging
.
info
(
label_map_dict
)
logging
.
info
(
label_map_dict
)
assert
len
(
label_map
)
==
NUM_CLASSES
return
label_map_dict
return
label_map
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
def
_close_on_exit
(
writers
):
def
_close_on_exit
(
writers
):
...
...
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