-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hierarchical labeling * add empty line to the end of json/remove duplicated test Co-authored-by: Wonju Lee <wonju.lee@intel.com>
- Loading branch information
Showing
12 changed files
with
332 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"info": {}, | ||
"categories": { | ||
"label": { | ||
"label_groups": [ | ||
{ | ||
"name": "manmade", | ||
"group_type": "exclusive", | ||
"labels": ["car", "bicycle"] | ||
}, | ||
{ | ||
"name": "empty_group", | ||
"group_type": "empty", | ||
"labels": ["tom", "mary"] | ||
} | ||
], | ||
"labels": [ | ||
{ | ||
"name": "car", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "bicycle", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "tom", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "mary", | ||
"parent": "", | ||
"attributes": [] | ||
} | ||
], | ||
"attributes": [] | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"id": "c", | ||
"annotations": [ | ||
{ | ||
"id": 0, | ||
"type": "label", | ||
"attributes": { | ||
"score": 1.0 | ||
}, | ||
"group": 0, | ||
"label_id": 1 | ||
}, | ||
{ | ||
"id": 0, | ||
"type": "label", | ||
"attributes": { | ||
"score": 1.0 | ||
}, | ||
"group": 0, | ||
"label_id": 3 | ||
} | ||
], | ||
"image": { | ||
"path": "../tests/assets/datumaro_dataset/images/test/c.jpg", | ||
"size": [ | ||
10, | ||
5 | ||
] | ||
}, | ||
"media": { | ||
"path": "../tests/assets/datumaro_dataset/images/test/c.jpg" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"info": {}, | ||
"categories": { | ||
"label": { | ||
"label_groups": [ | ||
{ | ||
"name": "manmade", | ||
"group_type": "exclusive", | ||
"labels": ["car", "bicycle"] | ||
}, | ||
{ | ||
"name": "empty_group", | ||
"group_type": "empty", | ||
"labels": ["tom", "mary"] | ||
} | ||
], | ||
"labels": [ | ||
{ | ||
"name": "car", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "bicycle", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "tom", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "mary", | ||
"parent": "", | ||
"attributes": [] | ||
} | ||
], | ||
"attributes": [] | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"id": "a", | ||
"annotations": [ | ||
{ | ||
"id": 0, | ||
"type": "label", | ||
"attributes": { | ||
"score": 1.0 | ||
}, | ||
"group": 0, | ||
"label_id": 0 | ||
} | ||
], | ||
"image": { | ||
"path": "../tests/assets/datumaro_dataset/images/train/a.jpg" | ||
}, | ||
"media": { | ||
"path": "../tests/assets/datumaro_dataset/images/train/a.jpg" | ||
} | ||
}, | ||
{ | ||
"id": "b", | ||
"annotations": [ | ||
{ | ||
"id": 0, | ||
"type": "label", | ||
"group": 0, | ||
"label_id": 0 | ||
}, | ||
{ | ||
"id": 1, | ||
"type": "label", | ||
"group": 0, | ||
"label_id": 1 | ||
}, | ||
{ | ||
"id": 2, | ||
"type": "label", | ||
"group": 0, | ||
"label_id": 2 | ||
}, | ||
{ | ||
"id": 3, | ||
"type": "label", | ||
"group": 0, | ||
"label_id": 5 | ||
} | ||
], | ||
"image": { | ||
"path": "../tests/assets/datumaro_dataset/images/train/b.jpg", | ||
"size": [ | ||
2, | ||
8 | ||
] | ||
}, | ||
"media": { | ||
"path": "../tests/assets/datumaro_dataset/images/train/b.jpg" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"info": {}, | ||
"categories": { | ||
"label": { | ||
"label_groups": [ | ||
{ | ||
"name": "manmade", | ||
"group_type": "exclusive", | ||
"labels": ["car", "bicycle"] | ||
}, | ||
{ | ||
"name": "empty_group", | ||
"group_type": "empty", | ||
"labels": ["tom", "mary"] | ||
} | ||
], | ||
"labels": [ | ||
{ | ||
"name": "car", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "bicycle", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "tom", | ||
"parent": "", | ||
"attributes": [] | ||
}, | ||
{ | ||
"name": "mary", | ||
"parent": "", | ||
"attributes": [] | ||
} | ||
], | ||
"attributes": [] | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"id": "d", | ||
"annotations": [], | ||
"image": { | ||
"path": "../tests/assets/datumaro_dataset/images/validation/d.png" | ||
}, | ||
"media": { | ||
"path": "../tests/assets/datumaro_dataset/images/validation/d.png" | ||
} | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (C) 2019-2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
import tempfile | ||
from unittest.case import TestCase | ||
|
||
import numpy as np | ||
|
||
from datumaro.components.annotation import AnnotationType, Label, LabelCategories | ||
from datumaro.components.extractor import DatasetItem | ||
from datumaro.components.media import Image | ||
from datumaro.components.project import Dataset | ||
|
||
from .requirements import Requirements, mark_requirement | ||
|
||
|
||
class LabelingTest(TestCase): | ||
@mark_requirement(Requirements.DATUM_GENERAL_REQ) | ||
def test_label_group(self): | ||
label_categories = LabelCategories() | ||
label_categories.add("car", parent="") | ||
label_categories.add("bicycle", parent="") | ||
|
||
label_categories.add_label_group("manmade", ["car", "bicycle"], group_type="exclusive") | ||
|
||
dataset = Dataset.from_iterable( | ||
[ | ||
DatasetItem( | ||
id=0, | ||
subset="train", | ||
media=Image(data=np.ones((10, 6, 3))), | ||
annotations=[ | ||
Label( | ||
0, | ||
id=0, | ||
), | ||
Label( | ||
1, | ||
id=1, | ||
), | ||
], | ||
), | ||
], | ||
categories={ | ||
AnnotationType.label: label_categories, | ||
}, | ||
) | ||
|
||
with tempfile.TemporaryDirectory() as temp_home: | ||
dataset.export(temp_home, format="datumaro") | ||
dataset_imported = Dataset.import_from(temp_home, format="datumaro") | ||
|
||
self.assertEqual(len(dataset_imported.categories()[AnnotationType.label].label_groups), 1) |