Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
aab190fc
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
aab190fc
编写于
6月 16, 2020
作者:
X
xiefangqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CocoDataset add category_id validation
上级
6089d58d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
11 deletion
+31
-11
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.cc
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.cc
+16
-9
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.h
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.h
+2
-0
tests/ut/data/dataset/testCOCO/annotations/invalid_category_id.json
...ata/dataset/testCOCO/annotations/invalid_category_id.json
+1
-0
tests/ut/data/dataset/testCOCO/annotations/train.json
tests/ut/data/dataset/testCOCO/annotations/train.json
+1
-1
tests/ut/python/dataset/test_datasets_coco.py
tests/ut/python/dataset/test_datasets_coco.py
+11
-1
未找到文件。
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.cc
浏览文件 @
aab190fc
...
@@ -407,6 +407,11 @@ Status CocoOp::ParseAnnotationIds() {
...
@@ -407,6 +407,11 @@ Status CocoOp::ParseAnnotationIds() {
nlohmann
::
json
image_list
;
nlohmann
::
json
image_list
;
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
js
,
std
::
string
(
kJsonImages
),
&
image_list
));
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
js
,
std
::
string
(
kJsonImages
),
&
image_list
));
RETURN_IF_NOT_OK
(
ImageColumnLoad
(
image_list
,
&
image_que
));
RETURN_IF_NOT_OK
(
ImageColumnLoad
(
image_list
,
&
image_que
));
if
(
task_type_
==
TaskType
::
Detection
||
task_type_
==
TaskType
::
Panoptic
)
{
nlohmann
::
json
node_categories
;
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
js
,
std
::
string
(
kJsonCategories
),
&
node_categories
));
RETURN_IF_NOT_OK
(
CategoriesColumnLoad
(
node_categories
));
}
nlohmann
::
json
annotations_list
;
nlohmann
::
json
annotations_list
;
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
js
,
std
::
string
(
kJsonAnnotations
),
&
annotations_list
));
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
js
,
std
::
string
(
kJsonAnnotations
),
&
annotations_list
));
for
(
auto
annotation
:
annotations_list
)
{
for
(
auto
annotation
:
annotations_list
)
{
...
@@ -440,11 +445,6 @@ Status CocoOp::ParseAnnotationIds() {
...
@@ -440,11 +445,6 @@ Status CocoOp::ParseAnnotationIds() {
for
(
auto
img
:
image_que
)
{
for
(
auto
img
:
image_que
)
{
if
(
coordinate_map_
.
find
(
img
)
!=
coordinate_map_
.
end
())
image_ids_
.
push_back
(
img
);
if
(
coordinate_map_
.
find
(
img
)
!=
coordinate_map_
.
end
())
image_ids_
.
push_back
(
img
);
}
}
if
(
task_type_
==
TaskType
::
Detection
||
task_type_
==
TaskType
::
Panoptic
)
{
nlohmann
::
json
node_categories
;
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
js
,
std
::
string
(
kJsonCategories
),
&
node_categories
));
RETURN_IF_NOT_OK
(
CategoriesColumnLoad
(
node_categories
));
}
num_rows_
=
image_ids_
.
size
();
num_rows_
=
image_ids_
.
size
();
return
Status
::
OK
();
return
Status
::
OK
();
}
}
...
@@ -472,6 +472,9 @@ Status CocoOp::DetectionColumnLoad(nlohmann::json annotation_tree, const std::st
...
@@ -472,6 +472,9 @@ Status CocoOp::DetectionColumnLoad(nlohmann::json annotation_tree, const std::st
uint32_t
category_id
=
0
,
iscrowd
=
0
;
uint32_t
category_id
=
0
,
iscrowd
=
0
;
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
annotation_tree
,
std
::
string
(
kJsonAnnoBbox
),
&
node_bbox
));
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
annotation_tree
,
std
::
string
(
kJsonAnnoBbox
),
&
node_bbox
));
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
annotation_tree
,
std
::
string
(
kJsonAnnoCategoryId
),
&
category_id
));
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
annotation_tree
,
std
::
string
(
kJsonAnnoCategoryId
),
&
category_id
));
auto
search_category
=
category_set_
.
find
(
category_id
);
if
(
search_category
==
category_set_
.
end
())
RETURN_STATUS_UNEXPECTED
(
"category_id can't find in categories where category_id: "
+
std
::
to_string
(
category_id
));
auto
node_iscrowd
=
annotation_tree
.
find
(
kJsonAnnoIscrowd
);
auto
node_iscrowd
=
annotation_tree
.
find
(
kJsonAnnoIscrowd
);
if
(
node_iscrowd
!=
annotation_tree
.
end
())
iscrowd
=
*
node_iscrowd
;
if
(
node_iscrowd
!=
annotation_tree
.
end
())
iscrowd
=
*
node_iscrowd
;
bbox
.
insert
(
bbox
.
end
(),
node_bbox
.
begin
(),
node_bbox
.
end
());
bbox
.
insert
(
bbox
.
end
(),
node_bbox
.
begin
(),
node_bbox
.
end
());
...
@@ -524,22 +527,25 @@ Status CocoOp::PanopticColumnLoad(nlohmann::json annotation_tree, const std::str
...
@@ -524,22 +527,25 @@ Status CocoOp::PanopticColumnLoad(nlohmann::json annotation_tree, const std::str
RETURN_STATUS_UNEXPECTED
(
"No segments_info found in annotations where image_id: "
+
std
::
to_string
(
image_id
));
RETURN_STATUS_UNEXPECTED
(
"No segments_info found in annotations where image_id: "
+
std
::
to_string
(
image_id
));
for
(
auto
info
:
*
itr_segments
)
{
for
(
auto
info
:
*
itr_segments
)
{
std
::
vector
<
float
>
bbox
;
std
::
vector
<
float
>
bbox
;
uint32_t
category_id
=
0
;
auto
itr_bbox
=
info
.
find
(
kJsonAnnoBbox
);
auto
itr_bbox
=
info
.
find
(
kJsonAnnoBbox
);
if
(
itr_bbox
==
info
.
end
())
if
(
itr_bbox
==
info
.
end
())
RETURN_STATUS_UNEXPECTED
(
"No bbox found in segments_info where image_id: "
+
std
::
to_string
(
image_id
));
RETURN_STATUS_UNEXPECTED
(
"No bbox found in segments_info where image_id: "
+
std
::
to_string
(
image_id
));
bbox
.
insert
(
bbox
.
end
(),
itr_bbox
->
begin
(),
itr_bbox
->
end
());
bbox
.
insert
(
bbox
.
end
(),
itr_bbox
->
begin
(),
itr_bbox
->
end
());
coordinate_map_
[
image_file
].
push_back
(
bbox
);
coordinate_map_
[
image_file
].
push_back
(
bbox
);
auto
itr_category_id
=
info
.
find
(
kJsonAnnoCategoryId
);
RETURN_IF_NOT_OK
(
SearchNodeInJson
(
info
,
std
::
string
(
kJsonAnnoCategoryId
),
&
category_id
));
if
(
itr_category_id
==
info
.
end
())
auto
search_category
=
category_set_
.
find
(
category_id
);
RETURN_STATUS_UNEXPECTED
(
"No category_id found in segments_info where image_id: "
+
std
::
to_string
(
image_id
));
if
(
search_category
==
category_set_
.
end
())
RETURN_STATUS_UNEXPECTED
(
"category_id can't find in categories where category_id: "
+
std
::
to_string
(
category_id
));
auto
itr_iscrowd
=
info
.
find
(
kJsonAnnoIscrowd
);
auto
itr_iscrowd
=
info
.
find
(
kJsonAnnoIscrowd
);
if
(
itr_iscrowd
==
info
.
end
())
if
(
itr_iscrowd
==
info
.
end
())
RETURN_STATUS_UNEXPECTED
(
"No iscrowd found in segments_info where image_id: "
+
std
::
to_string
(
image_id
));
RETURN_STATUS_UNEXPECTED
(
"No iscrowd found in segments_info where image_id: "
+
std
::
to_string
(
image_id
));
auto
itr_area
=
info
.
find
(
kJsonAnnoArea
);
auto
itr_area
=
info
.
find
(
kJsonAnnoArea
);
if
(
itr_area
==
info
.
end
())
if
(
itr_area
==
info
.
end
())
RETURN_STATUS_UNEXPECTED
(
"No area found in segments_info where image_id: "
+
std
::
to_string
(
image_id
));
RETURN_STATUS_UNEXPECTED
(
"No area found in segments_info where image_id: "
+
std
::
to_string
(
image_id
));
simple_item_map_
[
image_file
].
push_back
(
*
itr_
category_id
);
simple_item_map_
[
image_file
].
push_back
(
category_id
);
simple_item_map_
[
image_file
].
push_back
(
*
itr_iscrowd
);
simple_item_map_
[
image_file
].
push_back
(
*
itr_iscrowd
);
simple_item_map_
[
image_file
].
push_back
(
*
itr_area
);
simple_item_map_
[
image_file
].
push_back
(
*
itr_area
);
}
}
...
@@ -556,6 +562,7 @@ Status CocoOp::CategoriesColumnLoad(nlohmann::json categories_tree) {
...
@@ -556,6 +562,7 @@ Status CocoOp::CategoriesColumnLoad(nlohmann::json categories_tree) {
if
(
itr_id
==
category
.
end
())
RETURN_STATUS_UNEXPECTED
(
"No id found in categories of "
+
annotation_path_
);
if
(
itr_id
==
category
.
end
())
RETURN_STATUS_UNEXPECTED
(
"No id found in categories of "
+
annotation_path_
);
id
=
*
itr_id
;
id
=
*
itr_id
;
label_info
.
push_back
(
id
);
label_info
.
push_back
(
id
);
category_set_
.
insert
(
id
);
auto
itr_name
=
category
.
find
(
kJsonCategoriesName
);
auto
itr_name
=
category
.
find
(
kJsonCategoriesName
);
if
(
itr_name
==
category
.
end
())
if
(
itr_name
==
category
.
end
())
...
...
mindspore/ccsrc/dataset/engine/datasetops/source/coco_op.h
浏览文件 @
aab190fc
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <map>
#include <map>
#include <memory>
#include <memory>
#include <set>
#include <string>
#include <string>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
...
@@ -322,6 +323,7 @@ class CocoOp : public ParallelOp, public RandomAccessOp {
...
@@ -322,6 +323,7 @@ class CocoOp : public ParallelOp, public RandomAccessOp {
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
vector
<
int32_t
>>>
label_index_
;
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
vector
<
int32_t
>>>
label_index_
;
std
::
map
<
std
::
string
,
CoordinateRow
>
coordinate_map_
;
std
::
map
<
std
::
string
,
CoordinateRow
>
coordinate_map_
;
std
::
map
<
std
::
string
,
std
::
vector
<
uint32_t
>>
simple_item_map_
;
std
::
map
<
std
::
string
,
std
::
vector
<
uint32_t
>>
simple_item_map_
;
std
::
set
<
uint32_t
>
category_set_
;
};
};
}
// namespace dataset
}
// namespace dataset
}
// namespace mindspore
}
// namespace mindspore
...
...
tests/ut/data/dataset/testCOCO/annotations/invalid_category_id.json
0 → 100644
浏览文件 @
aab190fc
{
"info"
:
{
"description"
:
"COCO 2017 Dataset"
,
"url"
:
"http://cocodataset.org"
,
"version"
:
"1.0"
,
"year"
:
2017
,
"contributor"
:
"COCO Consortium"
,
"data_created"
:
"2017/09/01"
},
"licenses"
:
[{
"url"
:
"http://creativecommons.org/license/by-nc-sa/2.0/"
,
"id"
:
3
,
"name"
:
"Attribution-Noncommercial License"
}],
"images"
:
[{
"license"
:
3
,
"file_name"
:
"000000391895.jpg"
,
"id"
:
391895
},
{
"license"
:
3
,
"file_name"
:
"000000318219.jpg"
,
"id"
:
318219
},
{
"license"
:
3
,
"file_name"
:
"000000554625.jpg"
,
"id"
:
554625
},
{
"license"
:
3
,
"file_name"
:
"000000574769.jpg"
,
"id"
:
574769
},
{
"license"
:
3
,
"file_name"
:
"000000060623.jpg"
,
"id"
:
60623
},
{
"license"
:
3
,
"file_name"
:
"000000309022.jpg"
,
"id"
:
309022
}],
"annotations"
:
[{
"segmentation"
:
[[
10.0
,
12.0
,
13.0
,
14.0
,
15.0
,
16.0
,
17.0
,
18.0
,
19.0
,
20.0
]],
"category_id"
:
1
,
"iscrowd"
:
0
,
"image_id"
:
391895
,
"bbox"
:
[
10
,
10
,
10
,
10
],
"area"
:
100
,
"id"
:
10000
},
{
"segmentation"
:
[[
20.0
,
22.0
,
23.0
,
24.0
,
25.0
,
26.0
,
27.0
,
28.0
,
29.0
,
30.0
,
31.0
]],
"category_id"
:
2
,
"iscrowd"
:
0
,
"image_id"
:
318219
,
"bbox"
:
[
20
,
20
,
20
,
20
],
"area"
:
400
,
"id"
:
10001
},
{
"segmentation"
:
[[
40.0
,
42.0
,
43.0
,
44.0
,
45.0
,
46.0
,
47.0
,
48.0
,
49.0
,
40.0
,
41.0
,
42.0
]],
"category_id"
:
3
,
"iscrowd"
:
0
,
"image_id"
:
554625
,
"bbox"
:
[
30
,
30
,
30
,
30
],
"area"
:
900
,
"id"
:
10002
},
{
"segmentation"
:
[[
50.0
,
52.0
,
53.0
,
54.0
,
55.0
,
56.0
,
57.0
,
58.0
,
59.0
,
60.0
,
61.0
,
62.0
,
63.0
]],
"category_id"
:
4
,
"iscrowd"
:
0
,
"image_id"
:
574769
,
"bbox"
:
[
40
,
40
,
40
,
40
],
"area"
:
1600
,
"id"
:
10003
},
{
"segmentation"
:
[[
60.0
,
62.0
,
63.0
,
64.0
,
65.0
,
66.0
,
67.0
,
68.0
,
69.0
,
70.0
,
71.0
,
72.0
,
73.0
,
74.0
]],
"category_id"
:
5
,
"iscrowd"
:
0
,
"image_id"
:
60623
,
"bbox"
:
[
50
,
50
,
50
,
50
],
"area"
:
2500
,
"id"
:
10004
},
{
"segmentation"
:
[[
60.0
,
62.0
,
63.0
,
64.0
,
65.0
,
66.0
,
67.0
],[
68.0
,
69.0
,
70.0
,
71.0
,
72.0
,
73.0
,
74.0
]],
"category_id"
:
6
,
"iscrowd"
:
0
,
"image_id"
:
309022
,
"bbox"
:
[
60
,
60
,
60
,
60
],
"area"
:
3600
,
"id"
:
10005
},
{
"segmentation"
:
[[
70.0
,
72.0
,
73.0
,
74.0
,
75.0
]],
"category_id"
:
7
,
"iscrowd"
:
0
,
"image_id"
:
391895
,
"bbox"
:
[
70
,
70
,
70
,
70
],
"area"
:
4900
,
"id"
:
10006
},
{
"segmentation"
:
{
"counts"
:
[
10.0
,
12.0
,
13.0
,
14.0
,
15.0
,
16.0
,
17.0
,
18.0
,
19.0
,
20.0
],
"size"
:
[
200
,
300
]},
"category_id"
:
8
,
"iscrowd"
:
1
,
"image_id"
:
318219
,
"bbox"
:
[
80
,
80
,
80
,
80
],
"area"
:
6400
,
"id"
:
10007
}],
"categories"
:
[{
"supercategory"
:
"person"
,
"id"
:
1
,
"name"
:
"person"
},{
"supercategory"
:
"vehicle"
,
"id"
:
2
,
"name"
:
"bicycle"
},{
"supercategory"
:
"vehicle"
,
"id"
:
3
,
"name"
:
"car"
},{
"supercategory"
:
"vehicle"
,
"id"
:
4
,
"name"
:
"cat"
},{
"supercategory"
:
"vehicle"
,
"id"
:
5
,
"name"
:
"dog"
},{
"supercategory"
:
"vehicle"
,
"id"
:
6
,
"name"
:
"monkey"
}]}
\ No newline at end of file
tests/ut/data/dataset/testCOCO/annotations/train.json
浏览文件 @
aab190fc
{
"info"
:
{
"description"
:
"COCO 2017 Dataset"
,
"url"
:
"http://cocodataset.org"
,
"version"
:
"1.0"
,
"year"
:
2017
,
"contributor"
:
"COCO Consortium"
,
"data_created"
:
"2017/09/01"
},
"licenses"
:
[{
"url"
:
"http://creativecommons.org/license/by-nc-sa/2.0/"
,
"id"
:
3
,
"name"
:
"Attribution-Noncommercial License"
}],
"images"
:
[{
"license"
:
3
,
"file_name"
:
"000000391895.jpg"
,
"id"
:
391895
},
{
"license"
:
3
,
"file_name"
:
"000000318219.jpg"
,
"id"
:
318219
},
{
"license"
:
3
,
"file_name"
:
"000000554625.jpg"
,
"id"
:
554625
},
{
"license"
:
3
,
"file_name"
:
"000000574769.jpg"
,
"id"
:
574769
},
{
"license"
:
3
,
"file_name"
:
"000000060623.jpg"
,
"id"
:
60623
},
{
"license"
:
3
,
"file_name"
:
"000000309022.jpg"
,
"id"
:
309022
}],
"annotations"
:
[{
"segmentation"
:
[[
10.0
,
12.0
,
13.0
,
14.0
,
15.0
,
16.0
,
17.0
,
18.0
,
19.0
,
20.0
]],
"category_id"
:
1
,
"iscrowd"
:
0
,
"image_id"
:
391895
,
"bbox"
:
[
10
,
10
,
10
,
10
],
"area"
:
100
,
"id"
:
10000
},
{
"segmentation"
:
[[
20.0
,
22.0
,
23.0
,
24.0
,
25.0
,
26.0
,
27.0
,
28.0
,
29.0
,
30.0
,
31.0
]],
"category_id"
:
2
,
"iscrowd"
:
0
,
"image_id"
:
318219
,
"bbox"
:
[
20
,
20
,
20
,
20
],
"area"
:
400
,
"id"
:
10001
},
{
"segmentation"
:
[[
40.0
,
42.0
,
43.0
,
44.0
,
45.0
,
46.0
,
47.0
,
48.0
,
49.0
,
40.0
,
41.0
,
42.0
]],
"category_id"
:
3
,
"iscrowd"
:
0
,
"image_id"
:
554625
,
"bbox"
:
[
30
,
30
,
30
,
30
],
"area"
:
900
,
"id"
:
10002
},
{
"segmentation"
:
[[
50.0
,
52.0
,
53.0
,
54.0
,
55.0
,
56.0
,
57.0
,
58.0
,
59.0
,
60.0
,
61.0
,
62.0
,
63.0
]],
"category_id"
:
4
,
"iscrowd"
:
0
,
"image_id"
:
574769
,
"bbox"
:
[
40
,
40
,
40
,
40
],
"area"
:
1600
,
"id"
:
10003
},
{
"segmentation"
:
[[
60.0
,
62.0
,
63.0
,
64.0
,
65.0
,
66.0
,
67.0
,
68.0
,
69.0
,
70.0
,
71.0
,
72.0
,
73.0
,
74.0
]],
"category_id"
:
5
,
"iscrowd"
:
0
,
"image_id"
:
60623
,
"bbox"
:
[
50
,
50
,
50
,
50
],
"area"
:
2500
,
"id"
:
10004
},
{
"segmentation"
:
[[
60.0
,
62.0
,
63.0
,
64.0
,
65.0
,
66.0
,
67.0
],[
68.0
,
69.0
,
70.0
,
71.0
,
72.0
,
73.0
,
74.0
]],
"category_id"
:
6
,
"iscrowd"
:
0
,
"image_id"
:
309022
,
"bbox"
:
[
60
,
60
,
60
,
60
],
"area"
:
3600
,
"id"
:
10005
},
{
"segmentation"
:
[[
70.0
,
72.0
,
73.0
,
74.0
,
75.0
]],
"category_id"
:
7
,
"iscrowd"
:
0
,
"image_id"
:
391895
,
"bbox"
:
[
70
,
70
,
70
,
70
],
"area"
:
4900
,
"id"
:
10006
},
{
"segmentation"
:
{
"counts"
:
[
10.0
,
12.0
,
13.0
,
14.0
,
15.0
,
16.0
,
17.0
,
18.0
,
19.0
,
20.0
],
"size"
:
[
200
,
300
]},
"category_id"
:
8
,
"iscrowd"
:
1
,
"image_id"
:
318219
,
"bbox"
:
[
80
,
80
,
80
,
80
],
"area"
:
6400
,
"id"
:
10007
}],
"categories"
:
[{
"supercategory"
:
"person"
,
"id"
:
1
,
"name"
:
"person"
},{
"supercategory"
:
"vehicle"
,
"id"
:
2
,
"name"
:
"bicycle"
},{
"supercategory"
:
"vehicle"
,
"id"
:
3
,
"name"
:
"car"
},{
"supercategory"
:
"vehicle"
,
"id"
:
4
,
"name"
:
"cat"
},{
"supercategory"
:
"vehicle"
,
"id"
:
5
,
"name"
:
"dog"
},{
"supercategory"
:
"vehicle"
,
"id"
:
6
,
"name"
:
"monkey"
},{
"supercategory"
:
"vehicle"
,
"id"
:
6
,
"name"
:
"monkey"
},{
"supercategory"
:
"vehicle"
,
"id"
:
7
,
"name"
:
"monkey"
}]}
{
"info"
:
{
"description"
:
"COCO 2017 Dataset"
,
"url"
:
"http://cocodataset.org"
,
"version"
:
"1.0"
,
"year"
:
2017
,
"contributor"
:
"COCO Consortium"
,
"data_created"
:
"2017/09/01"
},
"licenses"
:
[{
"url"
:
"http://creativecommons.org/license/by-nc-sa/2.0/"
,
"id"
:
3
,
"name"
:
"Attribution-Noncommercial License"
}],
"images"
:
[{
"license"
:
3
,
"file_name"
:
"000000391895.jpg"
,
"id"
:
391895
},
{
"license"
:
3
,
"file_name"
:
"000000318219.jpg"
,
"id"
:
318219
},
{
"license"
:
3
,
"file_name"
:
"000000554625.jpg"
,
"id"
:
554625
},
{
"license"
:
3
,
"file_name"
:
"000000574769.jpg"
,
"id"
:
574769
},
{
"license"
:
3
,
"file_name"
:
"000000060623.jpg"
,
"id"
:
60623
},
{
"license"
:
3
,
"file_name"
:
"000000309022.jpg"
,
"id"
:
309022
}],
"annotations"
:
[{
"segmentation"
:
[[
10.0
,
12.0
,
13.0
,
14.0
,
15.0
,
16.0
,
17.0
,
18.0
,
19.0
,
20.0
]],
"category_id"
:
1
,
"iscrowd"
:
0
,
"image_id"
:
391895
,
"bbox"
:
[
10
,
10
,
10
,
10
],
"area"
:
100
,
"id"
:
10000
},
{
"segmentation"
:
[[
20.0
,
22.0
,
23.0
,
24.0
,
25.0
,
26.0
,
27.0
,
28.0
,
29.0
,
30.0
,
31.0
]],
"category_id"
:
2
,
"iscrowd"
:
0
,
"image_id"
:
318219
,
"bbox"
:
[
20
,
20
,
20
,
20
],
"area"
:
400
,
"id"
:
10001
},
{
"segmentation"
:
[[
40.0
,
42.0
,
43.0
,
44.0
,
45.0
,
46.0
,
47.0
,
48.0
,
49.0
,
40.0
,
41.0
,
42.0
]],
"category_id"
:
3
,
"iscrowd"
:
0
,
"image_id"
:
554625
,
"bbox"
:
[
30
,
30
,
30
,
30
],
"area"
:
900
,
"id"
:
10002
},
{
"segmentation"
:
[[
50.0
,
52.0
,
53.0
,
54.0
,
55.0
,
56.0
,
57.0
,
58.0
,
59.0
,
60.0
,
61.0
,
62.0
,
63.0
]],
"category_id"
:
4
,
"iscrowd"
:
0
,
"image_id"
:
574769
,
"bbox"
:
[
40
,
40
,
40
,
40
],
"area"
:
1600
,
"id"
:
10003
},
{
"segmentation"
:
[[
60.0
,
62.0
,
63.0
,
64.0
,
65.0
,
66.0
,
67.0
,
68.0
,
69.0
,
70.0
,
71.0
,
72.0
,
73.0
,
74.0
]],
"category_id"
:
5
,
"iscrowd"
:
0
,
"image_id"
:
60623
,
"bbox"
:
[
50
,
50
,
50
,
50
],
"area"
:
2500
,
"id"
:
10004
},
{
"segmentation"
:
[[
60.0
,
62.0
,
63.0
,
64.0
,
65.0
,
66.0
,
67.0
],[
68.0
,
69.0
,
70.0
,
71.0
,
72.0
,
73.0
,
74.0
]],
"category_id"
:
6
,
"iscrowd"
:
0
,
"image_id"
:
309022
,
"bbox"
:
[
60
,
60
,
60
,
60
],
"area"
:
3600
,
"id"
:
10005
},
{
"segmentation"
:
[[
70.0
,
72.0
,
73.0
,
74.0
,
75.0
]],
"category_id"
:
7
,
"iscrowd"
:
0
,
"image_id"
:
391895
,
"bbox"
:
[
70
,
70
,
70
,
70
],
"area"
:
4900
,
"id"
:
10006
},
{
"segmentation"
:
{
"counts"
:
[
10.0
,
12.0
,
13.0
,
14.0
,
15.0
,
16.0
,
17.0
,
18.0
,
19.0
,
20.0
],
"size"
:
[
200
,
300
]},
"category_id"
:
8
,
"iscrowd"
:
1
,
"image_id"
:
318219
,
"bbox"
:
[
80
,
80
,
80
,
80
],
"area"
:
6400
,
"id"
:
10007
}],
"categories"
:
[{
"supercategory"
:
"person"
,
"id"
:
1
,
"name"
:
"person"
},{
"supercategory"
:
"vehicle"
,
"id"
:
2
,
"name"
:
"bicycle"
},{
"supercategory"
:
"vehicle"
,
"id"
:
3
,
"name"
:
"car"
},{
"supercategory"
:
"vehicle"
,
"id"
:
4
,
"name"
:
"cat"
},{
"supercategory"
:
"vehicle"
,
"id"
:
5
,
"name"
:
"dog"
},{
"supercategory"
:
"vehicle"
,
"id"
:
6
,
"name"
:
"monkey"
},{
"supercategory"
:
"vehicle"
,
"id"
:
7
,
"name"
:
"bag"
},{
"supercategory"
:
"vehicle"
,
"id"
:
8
,
"name"
:
"orange"
}]}
\ No newline at end of file
\ No newline at end of file
tests/ut/python/dataset/test_datasets_coco.py
浏览文件 @
aab190fc
...
@@ -22,6 +22,7 @@ KEYPOINT_FILE = "../data/dataset/testCOCO/annotations/key_point.json"
...
@@ -22,6 +22,7 @@ KEYPOINT_FILE = "../data/dataset/testCOCO/annotations/key_point.json"
PANOPTIC_FILE
=
"../data/dataset/testCOCO/annotations/panoptic.json"
PANOPTIC_FILE
=
"../data/dataset/testCOCO/annotations/panoptic.json"
INVALID_FILE
=
"../data/dataset/testCOCO/annotations/invalid.json"
INVALID_FILE
=
"../data/dataset/testCOCO/annotations/invalid.json"
LACKOFIMAGE_FILE
=
"../data/dataset/testCOCO/annotations/lack_of_images.json"
LACKOFIMAGE_FILE
=
"../data/dataset/testCOCO/annotations/lack_of_images.json"
INVALID_CATEGORY_ID_FILE
=
"../data/dataset/testCOCO/annotations/invalid_category_id.json"
def
test_coco_detection
():
def
test_coco_detection
():
data1
=
ds
.
CocoDataset
(
DATA_DIR
,
annotation_file
=
ANNOTATION_FILE
,
task
=
"Detection"
,
data1
=
ds
.
CocoDataset
(
DATA_DIR
,
annotation_file
=
ANNOTATION_FILE
,
task
=
"Detection"
,
...
@@ -150,7 +151,8 @@ def test_coco_panoptic():
...
@@ -150,7 +151,8 @@ def test_coco_panoptic():
def
test_coco_detection_classindex
():
def
test_coco_detection_classindex
():
data1
=
ds
.
CocoDataset
(
DATA_DIR
,
annotation_file
=
ANNOTATION_FILE
,
task
=
"Detection"
,
decode
=
True
)
data1
=
ds
.
CocoDataset
(
DATA_DIR
,
annotation_file
=
ANNOTATION_FILE
,
task
=
"Detection"
,
decode
=
True
)
class_index
=
data1
.
get_class_indexing
()
class_index
=
data1
.
get_class_indexing
()
assert
class_index
==
{
'person'
:
[
1
],
'bicycle'
:
[
2
],
'car'
:
[
3
],
'cat'
:
[
4
],
'dog'
:
[
5
],
'monkey'
:
[
7
]}
assert
class_index
==
{
'person'
:
[
1
],
'bicycle'
:
[
2
],
'car'
:
[
3
],
'cat'
:
[
4
],
'dog'
:
[
5
],
'monkey'
:
[
6
],
'bag'
:
[
7
],
'orange'
:
[
8
]}
num_iter
=
0
num_iter
=
0
for
_
in
data1
.
__iter__
():
for
_
in
data1
.
__iter__
():
num_iter
+=
1
num_iter
+=
1
...
@@ -233,6 +235,14 @@ def test_coco_case_exception():
...
@@ -233,6 +235,14 @@ def test_coco_case_exception():
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
assert
"Invalid node found in json"
in
str
(
e
)
assert
"Invalid node found in json"
in
str
(
e
)
try
:
data1
=
ds
.
CocoDataset
(
DATA_DIR
,
annotation_file
=
INVALID_CATEGORY_ID_FILE
,
task
=
"Detection"
)
for
_
in
data1
.
__iter__
():
pass
assert
False
except
RuntimeError
as
e
:
assert
"category_id can't find in categories"
in
str
(
e
)
try
:
try
:
data1
=
ds
.
CocoDataset
(
DATA_DIR
,
annotation_file
=
INVALID_FILE
,
task
=
"Detection"
)
data1
=
ds
.
CocoDataset
(
DATA_DIR
,
annotation_file
=
INVALID_FILE
,
task
=
"Detection"
)
for
_
in
data1
.
__iter__
():
for
_
in
data1
.
__iter__
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录