Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openvinotoolkit
mmaction2
提交
388b8a06
M
mmaction2
项目概览
openvinotoolkit
/
mmaction2
大约 1 年 前同步成功
通知
2
Star
5
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mmaction2
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
388b8a06
编写于
7月 04, 2020
作者:
T
tangjiaqi
提交者:
linjintao
7月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add sth scripts.
上级
c8603e81
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
3 deletion
+99
-3
tools/data/build_file_list.py
tools/data/build_file_list.py
+9
-3
tools/data/parse_file_list.py
tools/data/parse_file_list.py
+90
-0
未找到文件。
tools/data/build_file_list.py
浏览文件 @
388b8a06
...
...
@@ -3,7 +3,9 @@ import glob
import
os.path
as
osp
import
random
from
tools.data.parse_file_list
import
parse_directory
,
parse_ucf101_splits
from
tools.data.parse_file_list
import
(
parse_directory
,
parse_sthv1_splits
,
parse_sthv2_splits
,
parse_ucf101_splits
)
def
parse_args
():
...
...
@@ -153,9 +155,13 @@ def main():
if
args
.
dataset
==
'ucf101'
:
splits
=
parse_ucf101_splits
(
args
.
level
)
elif
args
.
dataset
==
'sthv1'
:
splits
=
parse_sthv1_splits
(
args
.
level
)
elif
args
.
dataset
==
'sthv2'
:
splits
=
parse_sthv2_splits
(
args
.
level
)
else
:
raise
ValueError
(
f
"Supported datasets are 'ucf101', but got
{
args
.
dataset
}
"
)
raise
ValueError
(
f
"Supported datasets are 'ucf101, sthv1, sthv2',"
f
'but got
{
args
.
dataset
}
'
)
assert
len
(
splits
)
==
args
.
num_split
out_path
=
args
.
out_root_path
+
args
.
dataset
...
...
tools/data/parse_file_list.py
浏览文件 @
388b8a06
import
fnmatch
import
glob
import
json
import
os
...
...
@@ -110,3 +111,92 @@ def parse_ucf101_splits(level):
splits
.
append
((
train_list
,
test_list
))
return
splits
def
parse_sthv1_splits
(
level
):
"""Parse Something-Something dataset V1 into "train", "val" splits.
Args:
level: directory level of data.
Returns:
list: "train", "val", "test" splits of Something-Something dataset V1.
"""
# Read the annotations
# yapf: disable
class_index_file
=
'data/sthv1/annotations/something-something-v1-labels.csv'
# noqa
# yapf: enable
train_file
=
'data/sthv1/annotations/something-something-v1-train.csv'
val_file
=
'data/sthv1/annotations/something-something-v1-validation.csv'
test_file
=
'data/sthv1/annotations/something-something-v1-test.csv'
with
open
(
class_index_file
,
'r'
)
as
fin
:
class_index
=
[
x
.
strip
()
for
x
in
fin
]
class_mapping
=
{
class_index
[
idx
]:
idx
for
idx
in
range
(
len
(
class_index
))}
def
line_to_map
(
line
,
test_mode
=
False
):
items
=
line
.
strip
().
split
(
';'
)
vid
=
items
[
0
]
vid
=
'/'
.
join
(
vid
.
split
(
'/'
)[
-
level
:])
if
test_mode
:
return
vid
else
:
label
=
class_mapping
[
items
[
1
]]
return
vid
,
label
with
open
(
train_file
,
'r'
)
as
fin
:
train_list
=
[
line_to_map
(
x
)
for
x
in
fin
]
with
open
(
val_file
,
'r'
)
as
fin
:
val_list
=
[
line_to_map
(
x
)
for
x
in
fin
]
with
open
(
test_file
,
'r'
)
as
fin
:
test_list
=
[
line_to_map
(
x
,
test_mode
=
True
)
for
x
in
fin
]
return
((
train_list
,
val_list
,
test_list
),
)
def
parse_sthv2_splits
(
level
):
"""Parse Something-Something dataset V2 into "train", "val" splits.
Args:
level: directory level of data.
Returns:
list: "train", "val", "test" splits of Something-Something dataset V2.
"""
# Read the annotations
# yapf: disable
class_index_file
=
'data/sthv2/annotations/something-something-v2-labels.json'
# noqa
# yapf: enable
train_file
=
'data/sthv2/annotations/something-something-v2-train.json'
val_file
=
'data/sthv2/annotations/something-something-v2-validation.json'
test_file
=
'data/sthv2/annotations/something-something-v2-test.json'
with
open
(
class_index_file
,
'r'
)
as
fin
:
class_mapping
=
json
.
loads
(
fin
.
read
())
def
line_to_map
(
item
,
test_mode
=
False
):
vid
=
item
[
'id'
]
vid
=
'/'
.
join
(
vid
.
split
(
'/'
)[
-
level
:])
if
test_mode
:
return
vid
else
:
template
=
item
[
'template'
].
replace
(
'['
,
''
)
template
=
template
.
replace
(
']'
,
''
)
label
=
class_mapping
[
template
]
return
vid
,
label
with
open
(
train_file
,
'r'
)
as
fin
:
items
=
json
.
loads
(
fin
.
read
())
train_list
=
[
line_to_map
(
item
)
for
item
in
items
]
with
open
(
val_file
,
'r'
)
as
fin
:
items
=
json
.
loads
(
fin
.
read
())
val_list
=
[
line_to_map
(
item
)
for
item
in
items
]
with
open
(
test_file
,
'r'
)
as
fin
:
items
=
json
.
loads
(
fin
.
read
())
test_list
=
[
line_to_map
(
item
,
test_mode
=
True
)
for
item
in
items
]
return
((
train_list
,
val_list
,
test_list
),
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录