Skip to content

Commit 50482ea

Browse files
committed
Add tests for the issue and datumaro dataset examples
1 parent 0c9b525 commit 50482ea

File tree

12 files changed

+622
-0
lines changed

12 files changed

+622
-0
lines changed

datumaro/components/media.py

+7
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,13 @@ def __init__(self, path: str, extra_images: Optional[List[Image]] = None):
501501

502502
self.extra_images: List[Image] = extra_images or []
503503

504+
def __eq__(self, other: object) -> bool:
505+
return (
506+
isinstance(other, __class__)
507+
and self.path == other.path
508+
and set(self.extra_images) == set(other.extra_images)
509+
)
510+
504511

505512
class MultiframeImage(MediaElement):
506513
def __init__(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"info": {},
3+
"categories": {
4+
"label": {
5+
"labels": [
6+
{ "name": "cat0", "parent": "", "attributes": ["x", "y"] },
7+
{ "name": "cat1", "parent": "", "attributes": ["x", "y"] },
8+
{ "name": "cat2", "parent": "", "attributes": ["x", "y"] },
9+
{ "name": "cat3", "parent": "", "attributes": ["x", "y"] },
10+
{ "name": "cat4", "parent": "", "attributes": ["x", "y"] }
11+
],
12+
"attributes": ["a", "b", "score"]
13+
},
14+
"mask": {
15+
"colormap": [
16+
{ "label_id": 0, "r": 0, "g": 0, "b": 0 },
17+
{ "label_id": 1, "r": 128, "g": 0, "b": 0 },
18+
{ "label_id": 2, "r": 0, "g": 128, "b": 0 },
19+
{ "label_id": 3, "r": 128, "g": 128, "b": 0 },
20+
{ "label_id": 4, "r": 0, "g": 0, "b": 128 }
21+
]
22+
},
23+
"points": {
24+
"items": [
25+
{ "label_id": 0, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
26+
{ "label_id": 1, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
27+
{ "label_id": 2, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
28+
{ "label_id": 3, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
29+
{ "label_id": 4, "labels": ["cat1", "cat2"], "joints": [[0, 1]] }
30+
]
31+
}
32+
},
33+
"items": [
34+
{ "id": "42", "annotations": [] },
35+
{
36+
"id": "43",
37+
"annotations": [],
38+
"image": { "path": "43.qq", "size": [2, 4] }
39+
}
40+
]
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"info": {},
3+
"categories": {
4+
"label": {
5+
"labels": [
6+
{ "name": "cat0", "parent": "", "attributes": ["x", "y"] },
7+
{ "name": "cat1", "parent": "", "attributes": ["x", "y"] },
8+
{ "name": "cat2", "parent": "", "attributes": ["x", "y"] },
9+
{ "name": "cat3", "parent": "", "attributes": ["x", "y"] },
10+
{ "name": "cat4", "parent": "", "attributes": ["x", "y"] }
11+
],
12+
"attributes": ["a", "b", "score"]
13+
},
14+
"mask": {
15+
"colormap": [
16+
{ "label_id": 0, "r": 0, "g": 0, "b": 0 },
17+
{ "label_id": 1, "r": 128, "g": 0, "b": 0 },
18+
{ "label_id": 2, "r": 0, "g": 128, "b": 0 },
19+
{ "label_id": 3, "r": 128, "g": 128, "b": 0 },
20+
{ "label_id": 4, "r": 0, "g": 0, "b": 128 }
21+
]
22+
},
23+
"points": {
24+
"items": [
25+
{ "label_id": 0, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
26+
{ "label_id": 1, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
27+
{ "label_id": 2, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
28+
{ "label_id": 3, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
29+
{ "label_id": 4, "labels": ["cat1", "cat2"], "joints": [[0, 1]] }
30+
]
31+
}
32+
},
33+
"items": [
34+
{
35+
"id": "1",
36+
"annotations": [
37+
{
38+
"id": 6,
39+
"type": "cuboid_3d",
40+
"attributes": { "occluded": true },
41+
"group": 6,
42+
"label_id": 0,
43+
"position": [1.0, 2.0, 3.0],
44+
"rotation": [2.0, 2.0, 4.0],
45+
"scale": [1.0, 3.0, 4.0]
46+
}
47+
]
48+
},
49+
{ "id": "42", "annotations": [], "attr": { "a1": 5, "a2": "42" } }
50+
]
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"info": {},
3+
"categories": {
4+
"label": {
5+
"labels": [
6+
{ "name": "cat0", "parent": "", "attributes": ["x", "y"] },
7+
{ "name": "cat1", "parent": "", "attributes": ["x", "y"] },
8+
{ "name": "cat2", "parent": "", "attributes": ["x", "y"] },
9+
{ "name": "cat3", "parent": "", "attributes": ["x", "y"] },
10+
{ "name": "cat4", "parent": "", "attributes": ["x", "y"] }
11+
],
12+
"attributes": ["a", "b", "score"]
13+
},
14+
"mask": {
15+
"colormap": [
16+
{ "label_id": 0, "r": 0, "g": 0, "b": 0 },
17+
{ "label_id": 1, "r": 128, "g": 0, "b": 0 },
18+
{ "label_id": 2, "r": 0, "g": 128, "b": 0 },
19+
{ "label_id": 3, "r": 128, "g": 128, "b": 0 },
20+
{ "label_id": 4, "r": 0, "g": 0, "b": 128 }
21+
]
22+
},
23+
"points": {
24+
"items": [
25+
{ "label_id": 0, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
26+
{ "label_id": 1, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
27+
{ "label_id": 2, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
28+
{ "label_id": 3, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
29+
{ "label_id": 4, "labels": ["cat1", "cat2"], "joints": [[0, 1]] }
30+
]
31+
}
32+
},
33+
"items": [
34+
{
35+
"id": "100",
36+
"annotations": [
37+
{
38+
"id": 1,
39+
"type": "caption",
40+
"attributes": {},
41+
"group": 0,
42+
"caption": "hello"
43+
},
44+
{
45+
"id": 2,
46+
"type": "caption",
47+
"attributes": {},
48+
"group": 5,
49+
"caption": "world"
50+
},
51+
{
52+
"id": 3,
53+
"type": "label",
54+
"attributes": { "x": 1, "y": "2" },
55+
"group": 0,
56+
"label_id": 2
57+
},
58+
{
59+
"id": 4,
60+
"type": "bbox",
61+
"attributes": { "score": 1.0 },
62+
"group": 0,
63+
"label_id": 4,
64+
"z_order": 1,
65+
"bbox": [1.0, 2.0, 3.0, 4.0]
66+
},
67+
{
68+
"id": 5,
69+
"type": "bbox",
70+
"attributes": { "a": 1.5, "b": "text" },
71+
"group": 5,
72+
"label_id": null,
73+
"z_order": 0,
74+
"bbox": [5.0, 6.0, 7.0, 8.0]
75+
},
76+
{
77+
"id": 5,
78+
"type": "points",
79+
"attributes": { "x": 1, "y": "2" },
80+
"group": 0,
81+
"label_id": 0,
82+
"points": [1.0, 2.0, 2.0, 0.0, 1.0, 1.0],
83+
"z_order": 4,
84+
"visibility": [2, 2, 2]
85+
},
86+
{
87+
"id": 5,
88+
"type": "mask",
89+
"attributes": { "x": 1, "y": "2" },
90+
"group": 0,
91+
"label_id": 3,
92+
"rle": { "counts": "06", "size": [2, 3] },
93+
"z_order": 2
94+
}
95+
],
96+
"image": { "path": "100.jpg", "size": [10, 6] }
97+
},
98+
{
99+
"id": "21",
100+
"annotations": [
101+
{
102+
"id": 0,
103+
"type": "caption",
104+
"attributes": {},
105+
"group": 0,
106+
"caption": "test"
107+
},
108+
{
109+
"id": 0,
110+
"type": "label",
111+
"attributes": {},
112+
"group": 0,
113+
"label_id": 2
114+
},
115+
{
116+
"id": 42,
117+
"type": "bbox",
118+
"attributes": {},
119+
"group": 42,
120+
"label_id": 5,
121+
"z_order": 0,
122+
"bbox": [1.0, 2.0, 3.0, 4.0]
123+
}
124+
]
125+
}
126+
]
127+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"info": {},
3+
"categories": {
4+
"label": {
5+
"labels": [
6+
{ "name": "cat0", "parent": "", "attributes": ["x", "y"] },
7+
{ "name": "cat1", "parent": "", "attributes": ["x", "y"] },
8+
{ "name": "cat2", "parent": "", "attributes": ["x", "y"] },
9+
{ "name": "cat3", "parent": "", "attributes": ["x", "y"] },
10+
{ "name": "cat4", "parent": "", "attributes": ["x", "y"] }
11+
],
12+
"attributes": ["a", "b", "score"]
13+
},
14+
"mask": {
15+
"colormap": [
16+
{ "label_id": 0, "r": 0, "g": 0, "b": 0 },
17+
{ "label_id": 1, "r": 128, "g": 0, "b": 0 },
18+
{ "label_id": 2, "r": 0, "g": 128, "b": 0 },
19+
{ "label_id": 3, "r": 128, "g": 128, "b": 0 },
20+
{ "label_id": 4, "r": 0, "g": 0, "b": 128 }
21+
]
22+
},
23+
"points": {
24+
"items": [
25+
{ "label_id": 0, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
26+
{ "label_id": 1, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
27+
{ "label_id": 2, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
28+
{ "label_id": 3, "labels": ["cat1", "cat2"], "joints": [[0, 1]] },
29+
{ "label_id": 4, "labels": ["cat1", "cat2"], "joints": [[0, 1]] }
30+
]
31+
}
32+
},
33+
"items": [
34+
{
35+
"id": "2",
36+
"annotations": [
37+
{
38+
"id": 11,
39+
"type": "polyline",
40+
"attributes": {},
41+
"group": 0,
42+
"label_id": null,
43+
"points": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0],
44+
"z_order": 1
45+
},
46+
{
47+
"id": 12,
48+
"type": "polygon",
49+
"attributes": {},
50+
"group": 0,
51+
"label_id": null,
52+
"points": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0],
53+
"z_order": 4
54+
}
55+
]
56+
}
57+
]
58+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"info": {},
3+
"categories": {
4+
"label": {
5+
"labels": [{ "name": "cat", "parent": "", "attributes": [] }],
6+
"attributes": ["occluded"]
7+
},
8+
"points": { "items": [] }
9+
},
10+
"items": [
11+
{
12+
"id": "0000000000",
13+
"annotations": [
14+
{
15+
"id": 0,
16+
"type": "cuboid_3d",
17+
"attributes": { "occluded": false },
18+
"group": 0,
19+
"label_id": 0,
20+
"position": [0.84, -0.22, 0.64],
21+
"rotation": [0.0, 0.0, 0.0],
22+
"scale": [1.0, 1.0, 1.0]
23+
}
24+
],
25+
"attr": { "frame": 0 },
26+
"point_cloud": { "path": "0000000000.pcd" }
27+
},
28+
{
29+
"id": "0000000001",
30+
"annotations": [],
31+
"attr": { "frame": 1 },
32+
"point_cloud": { "path": "0000000001.pcd" }
33+
},
34+
{
35+
"id": "0000000002",
36+
"annotations": [],
37+
"attr": { "frame": 2 },
38+
"point_cloud": { "path": "0000000002.pcd" }
39+
}
40+
]
41+
}

0 commit comments

Comments
 (0)