-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add regression task dataset format (#44)
- Loading branch information
1 parent
264eb47
commit c7ced3a
Showing
8 changed files
with
81 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,3 +223,19 @@ def test_multitask_ic_multilabel_and_image_matting(self): | |
self.assertTrue(np.array_equal(dataset_manifest.images[0].labels['task2'][0], img_0_matting, equal_nan=True)) | ||
self.assertEqual(dataset_manifest.images[1].labels['task1'], [0, 1]) | ||
self.assertTrue(np.array_equal(dataset_manifest.images[1].labels['task2'][0], img_1_matting, equal_nan=True)) | ||
|
||
def test_image_regression_manifest(self): | ||
image_regression_manifest = { | ||
"images": [{"id": 1, "file_name": "[email protected]"}, | ||
{"id": 2, "file_name": "[email protected]"}], | ||
"annotations": [ | ||
{"id": 1, "image_id": 1, "target": 1.0}, | ||
{"id": 2, "image_id": 2, "target": 2.0}, | ||
] | ||
} | ||
|
||
dataset_manifest = TestCases.get_manifest(DatasetTypes.IMAGE_REGRESSION, 0) | ||
self.assertIsInstance(dataset_manifest, DatasetManifest) | ||
self.assertEqual(len(dataset_manifest.images), 2) | ||
self.assertEqual(dataset_manifest.images[0].labels, [image_regression_manifest["annotations"][0]["target"]]) | ||
self.assertEqual(dataset_manifest.images[1].labels, [image_regression_manifest["annotations"][1]["target"]]) |
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 |
---|---|---|
|
@@ -201,13 +201,40 @@ class TestCases: | |
] | ||
}] | ||
|
||
image_regression_manifest_dicts = [ | ||
{ | ||
"images": [{"id": 1, "file_name": "[email protected]"}, | ||
{"id": 2, "file_name": "[email protected]"}], | ||
"annotations": [ | ||
{"id": 1, "image_id": 1, "target": 1.0}, | ||
{"id": 2, "image_id": 2, "target": 2.0}, | ||
] | ||
}, | ||
{ | ||
"images": [{"id": 1, "file_name": "[email protected]"}, | ||
{"id": 2, "file_name": "[email protected]"}], | ||
"annotations": [ | ||
{"id": 1, "image_id": 1, "target": 3.0}, | ||
{"id": 2, "image_id": 2, "target": 4.0}, | ||
] | ||
}, | ||
{ | ||
"images": [{"id": 1, "file_name": "[email protected]"}, | ||
{"id": 2, "file_name": "[email protected]"}], | ||
"annotations": [ | ||
{"id": 1, "image_id": 1, "target": 5.0}, | ||
{"id": 2, "image_id": 2, "target": 6.0}, | ||
], | ||
}] | ||
|
||
manifest_dict_by_data_type = { | ||
DatasetTypes.IC_MULTILABEL: ic_manifest_dicts, | ||
DatasetTypes.IC_MULTICLASS: ic_manifest_dicts, | ||
DatasetTypes.OD: od_manifest_dicts, | ||
DatasetTypes.IMCAP: cap_manifest_dicts, | ||
DatasetTypes.IMAGE_TEXT_MATCHING: image_text_manifest_dicts, | ||
DatasetTypes.IMAGE_MATTING: image_matting_manifest_dicts | ||
DatasetTypes.IMAGE_MATTING: image_matting_manifest_dicts, | ||
DatasetTypes.IMAGE_REGRESSION: image_regression_manifest_dicts | ||
} | ||
|
||
@staticmethod | ||
|
@@ -600,7 +627,7 @@ def test_spawn_multitask_manifest(self): | |
|
||
class TestCocoGeneration(unittest.TestCase): | ||
def test_coco_generation(self): | ||
for data_type in [DatasetTypes.IC_MULTICLASS, DatasetTypes.IC_MULTILABEL, DatasetTypes.OD, DatasetTypes.IMCAP]: | ||
for data_type in [DatasetTypes.IC_MULTICLASS, DatasetTypes.IC_MULTILABEL, DatasetTypes.OD, DatasetTypes.IMCAP, DatasetTypes.IMAGE_REGRESSION]: | ||
for i in range(len(TestCases.manifest_dict_by_data_type[data_type])): | ||
manifest = TestCases.get_manifest(data_type, i) | ||
coco_dict = manifest.generate_coco_annotations() | ||
|
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