diff --git a/.gitignore b/.gitignore index 5d4b4611b..54f37a022 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ data/ !tests/darwin/data darwin_py.egg-info/PKG-INFO -*.png *.jpeg *.jpg *.bpm diff --git a/e2e_tests/cli/convert/test_convert.py b/e2e_tests/cli/test_convert.py similarity index 65% rename from e2e_tests/cli/convert/test_convert.py rename to e2e_tests/cli/test_convert.py index 188d93635..aadbc1612 100644 --- a/e2e_tests/cli/convert/test_convert.py +++ b/e2e_tests/cli/test_convert.py @@ -4,13 +4,14 @@ import orjson as json import pytest +import xml.etree.ElementTree as ET from e2e_tests.helpers import assert_cli, run_cli_command class TestExportCli: this_file_path = Path(dirname(__file__)).absolute() - data_path = (this_file_path / ".." / ".." / "data").resolve() + data_path = (this_file_path / ".." / "data" / "convert").resolve() @pytest.fixture(autouse=True) def config(self) -> None: @@ -33,10 +34,10 @@ def compare_directories(self, path: Path, expected_path: Path) -> None: continue # Compare files - with file.open("r") as f: + with file.open("rb") as f: content = f.read() - with Path(expected_path / file.name).open() as f: + with Path(expected_path / file.name).open("rb") as f: expected_content = f.read() if content != expected_content: @@ -52,6 +53,14 @@ def compare_directories(self, path: Path, expected_path: Path) -> None: [ ("yolo_segmented", data_path / "yolov8/from", data_path / "yolov8/to"), ("yolo", data_path / "yolo/from", data_path / "yolo/to"), + ("cvat", data_path / "cvat/from", data_path / "cvat/to"), + ("pascalvoc", data_path / "pascalvoc/from", data_path / "pascalvoc/to"), + ("nifti", data_path / "nifti/from", data_path / "nifti/to"), + ( + "instance_mask", + data_path / "instance_mask/from", + data_path / "instance_mask/to", + ), pytest.param( "coco", data_path / "coco/from", @@ -87,23 +96,34 @@ def test_darwin_convert( result = run_cli_command( f"darwin convert {format} {str(input_path)} {str(tmp_path)}" ) - if format == "coco": - self.patch_coco(tmp_path / "output.json") + self.patch_format(format, tmp_path) assert_cli(result, 0) self.compare_directories(expectation_path, tmp_path) + def patch_format(self, format: str, path: Path) -> None: + """ + Patch files based on format to match the expected output. + """ + patch_methods = { + "coco": self.patch_coco, + "cvat": self.patch_cvat, + } + patch_method = patch_methods.get(format) + if patch_method: + patch_method(path) + def patch_coco(self, path: Path) -> None: """ Patch coco file to match the expected output, includes changes to year and date_created, wrapped in try except so that format errors are still caught later with correct error messages """ try: - with open(path, "r") as f: + with open(path / "output.json", "r") as f: contents = f.read() temp = json.loads(contents) temp["info"]["year"] = 2023 temp["info"]["date_created"] = "2023/12/05" - with open(path, "w") as f: + with open(path / "output.json", "w") as f: op = json.dumps( temp, option=json.OPT_INDENT_2 | json.OPT_SERIALIZE_NUMPY ).decode("utf-8") @@ -111,6 +131,29 @@ def patch_coco(self, path: Path) -> None: except Exception: print(f"Error patching {path}") + def patch_cvat(self, path: Path) -> None: + """ + Patch cvat file to match the expected output. + """ + try: + tree = ET.parse(path / "output.xml") + root = tree.getroot() + # Adjust the required fields + dumped_elem = root.find(".//meta/dumped") + if dumped_elem is not None: + dumped_elem.text = "2024-10-25 10:33:01.789498+00:00" + created_elem = root.find(".//meta/task/created") + if created_elem is not None: + created_elem.text = "2024-10-25 10:33:01.789603+00:00" + updated_elem = root.find(".//meta/task/updated") + if updated_elem is not None: + updated_elem.text = "2024-10-25 10:33:01.789608+00:00" + tree.write(path / "output.xml") + except ET.ParseError: + print(f"Error parsing XML in {path}") + except Exception as e: + print(f"Error patching {path}: {e}") + if __name__ == "__main__": pytest.main(["-vv", "-s", __file__]) diff --git a/e2e_tests/data/coco/from/base_annotation.json b/e2e_tests/data/convert/coco/from/base_annotation.json similarity index 100% rename from e2e_tests/data/coco/from/base_annotation.json rename to e2e_tests/data/convert/coco/from/base_annotation.json diff --git a/e2e_tests/data/coco/to/output.json b/e2e_tests/data/convert/coco/to/output.json similarity index 100% rename from e2e_tests/data/coco/to/output.json rename to e2e_tests/data/convert/coco/to/output.json diff --git a/e2e_tests/data/convert/cvat/from/000000021295.json b/e2e_tests/data/convert/cvat/from/000000021295.json new file mode 100644 index 000000000..5e428560d --- /dev/null +++ b/e2e_tests/data/convert/cvat/from/000000021295.json @@ -0,0 +1,67 @@ +{ + "version": "2.0", + "schema_ref": "https://darwin-public.s3.eu-west-1.amazonaws.com/darwin_json/2.0/schema.json", + "item": { + "name": "000000021295.jpg", + "path": "/", + "source_info": { + "item_id": "0192c338-2dc8-bb9f-8dde-9c4a8714c957", + "dataset": { + "name": "tmp", + "slug": "tmp", + "dataset_management_url": "https://staging.v7labs.com/datasets/426200/dataset-management" + }, + "team": { + "name": "E2E Testing", + "slug": "e2e-testing" + }, + "workview_url": "https://staging.v7labs.com/workview?dataset=426200&item=0192c338-2dc8-bb9f-8dde-9c4a8714c957" + }, + "slots": [ + { + "type": "image", + "slot_name": "0", + "width": 640, + "height": 427, + "thumbnail_url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/6c554c31-8bf6-4fc7-9f31-394fd775b2a6/thumbnail", + "source_files": [ + { + "file_name": "000000021295.jpg", + "url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/uploads/ade5f1e3-a165-4a07-989f-86ee342499c9" + } + ] + } + ] + }, + "annotations": [ + { + "bounding_box": { + "h": 43.7181, + "w": 71.2665, + "x": 166.0884, + "y": 113.1879 + }, + "id": "46b33c9c-7453-4722-8b43-91bbb3fc247f", + "name": "test_bounding_box_basic", + "properties": [], + "slot_names": [ + "0" + ] + }, + { + "bounding_box": { + "h": 31.7405, + "w": 58.0912, + "x": 360.1248, + "y": 259.913 + }, + "id": "2b7c85ed-74b3-4111-a5d6-073da56d0072", + "name": "test_bounding_box_basic", + "properties": [], + "slot_names": [ + "0" + ] + } + ], + "properties": [] +} \ No newline at end of file diff --git a/e2e_tests/data/convert/cvat/to/output.xml b/e2e_tests/data/convert/cvat/to/output.xml new file mode 100644 index 000000000..66a9982e1 --- /dev/null +++ b/e2e_tests/data/convert/cvat/to/output.xml @@ -0,0 +1 @@ +1.12024-10-25 10:33:01.789498+00:001exported_task_from_darwin1annotation0NoneFalse2024-10-25 10:33:01.789603+00:002024-10-25 10:33:01.789608+00:00111not applicableexample_usernameuser@example.com \ No newline at end of file diff --git a/e2e_tests/data/convert/instance_mask/from/000000021295.json b/e2e_tests/data/convert/instance_mask/from/000000021295.json new file mode 100644 index 000000000..34cac389b --- /dev/null +++ b/e2e_tests/data/convert/instance_mask/from/000000021295.json @@ -0,0 +1,155 @@ +{ + "version": "2.0", + "schema_ref": "https://darwin-public.s3.eu-west-1.amazonaws.com/darwin_json/2.0/schema.json", + "item": { + "name": "000000021295.jpg", + "path": "/", + "source_info": { + "item_id": "0192c338-2dc8-bb9f-8dde-9c4a8714c957", + "team": { + "name": "E2E Testing", + "slug": "e2e-testing" + }, + "dataset": { + "name": "tmp", + "slug": "tmp", + "dataset_management_url": "https://staging.v7labs.com/datasets/426200/dataset-management" + }, + "workview_url": "https://staging.v7labs.com/workview?dataset=426200&item=0192c338-2dc8-bb9f-8dde-9c4a8714c957" + }, + "slots": [ + { + "type": "image", + "slot_name": "0", + "width": 640, + "height": 427, + "thumbnail_url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/6c554c31-8bf6-4fc7-9f31-394fd775b2a6/thumbnail", + "source_files": [ + { + "file_name": "000000021295.jpg", + "url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/uploads/ade5f1e3-a165-4a07-989f-86ee342499c9" + } + ] + } + ] + }, + "annotations": [ + { + "bounding_box": { + "h": 123.8166, + "w": 147.2414, + "x": 105.8307, + "y": 63.5815 + }, + "id": "4f23f7d2-2f83-45bc-927a-d03b9f642619", + "name": "test_polygon_basic", + "polygon": { + "paths": [ + [ + { + "x": 189.4906, + "y": 63.5815 + }, + { + "x": 105.8307, + "y": 182.0439 + }, + { + "x": 249.0564, + "y": 187.3981 + }, + { + "x": 196.1834, + "y": 105.0768 + }, + { + "x": 253.0721, + "y": 99.7226 + } + ] + ] + }, + "properties": [], + "slot_names": [ + "0" + ] + }, + { + "bounding_box": { + "h": 99.05329999999998, + "w": 155.2727, + "x": 201.5376, + "y": 287.1207 + }, + "id": "b4248df6-5390-488a-9190-edfa397458a6", + "name": "test_polygon_basic", + "polygon": { + "paths": [ + [ + { + "x": 247.0486, + "y": 287.1207 + }, + { + "x": 201.5376, + "y": 386.174 + }, + { + "x": 293.8981, + "y": 386.174 + }, + { + "x": 356.8103, + "y": 384.1661 + }, + { + "x": 356.8103, + "y": 329.9545 + }, + { + "x": 319.3307, + "y": 316.569 + } + ] + ] + }, + "properties": [], + "slot_names": [ + "0" + ] + }, + { + "bounding_box": { + "h": 163.3041, + "w": 171.33550000000002, + "x": 338.0705, + "y": 50.1959 + }, + "id": "5092f929-ec75-4eb9-8b56-e6bbc472e272", + "name": "test_polygon_basic", + "polygon": { + "paths": [ + [ + { + "x": 429.7618, + "y": 50.1959 + }, + { + "x": 338.0705, + "y": 212.8307 + }, + { + "x": 509.406, + "y": 213.5 + } + ] + ] + }, + "properties": [], + "slot_names": [ + "0" + ] + } + ], + "properties": [] +} \ No newline at end of file diff --git a/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00000.png b/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00000.png new file mode 100644 index 000000000..32060673f Binary files /dev/null and b/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00000.png differ diff --git a/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00001.png b/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00001.png new file mode 100644 index 000000000..8da257b83 Binary files /dev/null and b/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00001.png differ diff --git a/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00002.png b/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00002.png new file mode 100644 index 000000000..bc1cb483b Binary files /dev/null and b/e2e_tests/data/convert/instance_mask/to/masks/000000021295_00002.png differ diff --git a/e2e_tests/data/convert/nifti/from/hippocampus_001_mpr_1_test_hippo.nii.json b/e2e_tests/data/convert/nifti/from/hippocampus_001_mpr_1_test_hippo.nii.json new file mode 100644 index 000000000..f6f73f88c --- /dev/null +++ b/e2e_tests/data/convert/nifti/from/hippocampus_001_mpr_1_test_hippo.nii.json @@ -0,0 +1,945 @@ +{ + "version": "2.0", + "schema_ref": "https://darwin-public.s3.eu-west-1.amazonaws.com/darwin_json/2.0/schema.json", + "item": { + "name": "hippocampus_001_mpr_1_test_hippo.nii.gz", + "path": "/", + "source_info": { + "item_id": "0192c3d1-a8e2-cac4-0227-1198aebe5193", + "dataset": { + "name": "tmp", + "slug": "tmp", + "dataset_management_url": "https://staging.v7labs.com/datasets/426200/dataset-management" + }, + "team": { + "name": "E2E Testing", + "slug": "e2e-testing" + }, + "workview_url": "https://staging.v7labs.com/workview?dataset=426200&item=0192c3d1-a8e2-cac4-0227-1198aebe5193" + }, + "slots": [ + { + "type": "dicom", + "slot_name": "0", + "width": 35, + "height": 51, + "fps": null, + "thumbnail_url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/thumbnail", + "source_files": [ + { + "file_name": "hippocampus_001_mpr_1_test_hippo.nii.gz", + "url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/uploads/1f943f7e-59c5-4a0f-aee4-e8b6da32c868" + } + ], + "frame_count": 35, + "frame_urls": [ + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/0", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/1", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/2", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/3", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/4", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/5", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/6", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/7", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/8", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/9", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/10", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/11", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/12", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/13", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/14", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/15", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/16", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/17", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/18", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/19", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/20", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/21", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/22", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/23", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/24", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/25", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/26", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/27", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/28", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/29", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/30", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/31", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/32", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/33", + "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/503816e2-99e7-4f63-bd1f-0c034d686ffb/sections/34" + ], + "metadata": { + "shape": [ + 1, + 35, + 51, + 35 + ], + "SeriesInstanceUID": "1.2.826.0.1.3680043.8.498.11241382944719946500563049675416203017", + "affine": "[[-1.0, 0.0, 0.0, 35.0], [0.0, -1.0, 0.0, 51.0], [0.0, 0.0, -1.0, 35.0], [0.0, 0.0, 0.0, 1.0]]", + "colorspace": "RG16", + "original_affine": [ + [ + "1.0", + "0.0", + "0.0", + "1.0" + ], + [ + "0.0", + "1.0", + "0.0", + "1.0" + ], + [ + "0.0", + "0.0", + "1.0", + "1.0" + ], + [ + "0.0", + "0.0", + "0.0", + "1.0" + ] + ], + "pixdim": "(1.0, 1.0, 1.0)" + } + } + ] + }, + "annotations": [ + { + "frames": { + "0": { + "bounding_box": { + "h": 20.7, + "w": 20.699999999999996, + "x": -35.8, + "y": 14.2 + }, + "keyframe": true, + "polygon": { + "paths": [ + [ + { + "x": -24.5, + "y": 14.2 + }, + { + "x": -15.7, + "y": 25.1 + }, + { + "x": -15.1, + "y": 25.4 + }, + { + "x": -35.8, + "y": 34.9 + } + ] + ] + } + }, + "1": { + "bounding_box": { + "h": 20.7, + "w": 20.699999999999996, + "x": -35.8, + "y": 14.2 + }, + "keyframe": false, + "polygon": { + "paths": [ + [ + { + "x": -24.5, + "y": 14.2 + }, + { + "x": -15.7, + "y": 25.1 + }, + { + "x": -15.1, + "y": 25.4 + }, + { + "x": -35.8, + "y": 34.9 + } + ] + ] + } + }, + "2": { + "bounding_box": { + "h": 20.7, + "w": 20.699999999999996, + "x": -35.8, + "y": 14.2 + }, + "keyframe": true, + "polygon": { + "paths": [ + [ + { + "x": -24.5, + "y": 14.2 + }, + { + "x": -15.7, + "y": 25.1 + }, + { + "x": -15.1, + "y": 25.4 + }, + { + "x": -35.8, + "y": 34.9 + } + ] + ] + } + } + }, + "global_sub_types": {}, + "id": "0093f632-ae50-410d-866b-65f6d936f1e2", + "interpolate_algorithm": "linear-1.1", + "interpolated": true, + "name": "test_polygon_basic", + "properties": [], + "ranges": [ + [ + 0, + 3 + ] + ], + "slot_names": [ + "0" + ] + }, + { + "frames": { + "5": { + "bounding_box": { + "h": 8.199999999999996, + "w": 16.3, + "x": -6.7, + "y": 29.1 + }, + "keyframe": true, + "polygon": { + "paths": [ + [ + { + "x": -0.1, + "y": 29.1 + }, + { + "x": -6.7, + "y": 36.1 + }, + { + "x": -2.1, + "y": 36.7 + }, + { + "x": 8.7, + "y": 37.1 + }, + { + "x": 9.6, + "y": 37.3 + } + ] + ] + } + }, + "6": { + "bounding_box": { + "h": 8.199999999999996, + "w": 16.3, + "x": -6.7, + "y": 29.1 + }, + "keyframe": false, + "polygon": { + "paths": [ + [ + { + "x": -0.1, + "y": 29.1 + }, + { + "x": -6.7, + "y": 36.1 + }, + { + "x": -2.1, + "y": 36.7 + }, + { + "x": 8.7, + "y": 37.1 + }, + { + "x": 9.6, + "y": 37.3 + } + ] + ] + } + }, + "7": { + "bounding_box": { + "h": 8.199999999999996, + "w": 16.3, + "x": -6.7, + "y": 29.1 + }, + "keyframe": true, + "polygon": { + "paths": [ + [ + { + "x": -0.1, + "y": 29.1 + }, + { + "x": -6.7, + "y": 36.1 + }, + { + "x": -2.1, + "y": 36.7 + }, + { + "x": 8.7, + "y": 37.1 + }, + { + "x": 9.6, + "y": 37.3 + } + ] + ] + } + } + }, + "global_sub_types": {}, + "id": "25bd342c-530c-40bb-bf14-a0e58cfe243c", + "interpolate_algorithm": "linear-1.1", + "interpolated": true, + "name": "test_polygon_basic", + "properties": [], + "ranges": [ + [ + 5, + 8 + ] + ], + "slot_names": [ + "0" + ] + }, + { + "frames": { + "2": { + "bounding_box": { + "h": 7.499999999999998, + "w": 12.500000000000002, + "x": 6.1, + "y": 11.9 + }, + "keyframe": true, + "polygon": { + "paths": [ + [ + { + "x": 13.2, + "y": 11.9 + }, + { + "x": 6.1, + "y": 18.8 + }, + { + "x": 18.6, + "y": 19.4 + } + ] + ] + } + }, + "3": { + "bounding_box": { + "h": 7.499999999999998, + "w": 12.500000000000002, + "x": 6.1, + "y": 11.9 + }, + "keyframe": false, + "polygon": { + "paths": [ + [ + { + "x": 13.2, + "y": 11.9 + }, + { + "x": 6.1, + "y": 18.8 + }, + { + "x": 18.6, + "y": 19.4 + } + ] + ] + } + }, + "4": { + "bounding_box": { + "h": 7.499999999999998, + "w": 12.500000000000002, + "x": 6.1, + "y": 11.9 + }, + "keyframe": true, + "polygon": { + "paths": [ + [ + { + "x": 13.2, + "y": 11.9 + }, + { + "x": 6.1, + "y": 18.8 + }, + { + "x": 18.6, + "y": 19.4 + } + ] + ] + } + } + }, + "global_sub_types": {}, + "id": "d79bc280-3077-4754-bcdf-b9bff87396ef", + "interpolate_algorithm": "linear-1.1", + "interpolated": true, + "name": "test_polygon_basic", + "properties": [], + "ranges": [ + [ + 2, + 5 + ] + ], + "slot_names": [ + "0" + ] + }, + { + "frames": { + "0": { + "keyframe": true, + "mask": {} + }, + "1": { + "keyframe": true, + "mask": {} + }, + "2": { + "keyframe": true, + "mask": {} + }, + "9": { + "keyframe": true, + "mask": {} + }, + "10": { + "keyframe": true, + "mask": {} + }, + "13": { + "keyframe": true, + "mask": {} + } + }, + "id": "9e26fc7a-75af-4a51-978e-55f95625176d", + "interpolate_algorithm": "linear-1.1", + "name": "test_mask_basic", + "only_keyframes": true, + "properties": [], + "ranges": [ + [ + 0, + 14 + ] + ], + "slot_names": [ + "0" + ] + }, + { + "frames": { + "0": { + "keyframe": true, + "raster_layer": { + "dense_rle": [ + 0, + 478, + 1, + 6, + 0, + 27, + 1, + 10, + 0, + 25, + 1, + 11, + 0, + 23, + 1, + 13, + 0, + 22, + 1, + 13, + 0, + 22, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 13, + 0, + 22, + 1, + 13, + 0, + 22, + 1, + 12, + 0, + 24, + 1, + 11, + 0, + 24, + 1, + 10, + 0, + 26, + 1, + 8, + 0, + 29, + 1, + 4, + 0, + 602 + ], + "mask_annotation_ids_mapping": { + "9e26fc7a-75af-4a51-978e-55f95625176d": 1 + }, + "total_pixels": 1785 + } + }, + "1": { + "keyframe": true, + "raster_layer": { + "dense_rle": [ + 0, + 618, + 1, + 8, + 0, + 25, + 1, + 12, + 0, + 23, + 1, + 13, + 0, + 21, + 1, + 14, + 0, + 21, + 1, + 15, + 0, + 20, + 1, + 15, + 0, + 20, + 1, + 15, + 0, + 20, + 1, + 15, + 0, + 19, + 1, + 15, + 0, + 20, + 1, + 15, + 0, + 20, + 1, + 14, + 0, + 21, + 1, + 14, + 0, + 22, + 1, + 12, + 0, + 23, + 1, + 12, + 0, + 24, + 1, + 10, + 0, + 27, + 1, + 6, + 0, + 636 + ], + "mask_annotation_ids_mapping": { + "9e26fc7a-75af-4a51-978e-55f95625176d": 1 + }, + "total_pixels": 1785 + } + }, + "2": { + "keyframe": true, + "raster_layer": { + "dense_rle": [ + 0, + 763, + 1, + 6, + 0, + 27, + 1, + 9, + 0, + 24, + 1, + 11, + 0, + 24, + 1, + 11, + 0, + 23, + 1, + 12, + 0, + 23, + 1, + 12, + 0, + 23, + 1, + 12, + 0, + 23, + 1, + 12, + 0, + 23, + 1, + 12, + 0, + 23, + 1, + 12, + 0, + 24, + 1, + 11, + 0, + 24, + 1, + 11, + 0, + 25, + 1, + 10, + 0, + 27, + 1, + 8, + 0, + 560 + ], + "mask_annotation_ids_mapping": { + "9e26fc7a-75af-4a51-978e-55f95625176d": 1 + }, + "total_pixels": 1785 + } + }, + "9": { + "keyframe": true, + "raster_layer": { + "dense_rle": [ + 0, + 733, + 1, + 2, + 0, + 31, + 1, + 4, + 0, + 31, + 1, + 4, + 0, + 30, + 1, + 5, + 0, + 30, + 1, + 5, + 0, + 30, + 1, + 5, + 0, + 30, + 1, + 5, + 0, + 30, + 1, + 5, + 0, + 30, + 1, + 5, + 0, + 30, + 1, + 5, + 0, + 30, + 1, + 5, + 0, + 31, + 1, + 4, + 0, + 31, + 1, + 4, + 0, + 32, + 1, + 3, + 0, + 32, + 1, + 3, + 0, + 32, + 1, + 3, + 0, + 33, + 1, + 2, + 0, + 33, + 1, + 2, + 0, + 455 + ], + "mask_annotation_ids_mapping": { + "9e26fc7a-75af-4a51-978e-55f95625176d": 1 + }, + "total_pixels": 1785 + } + }, + "10": { + "keyframe": true, + "raster_layer": { + "dense_rle": [ + 0, + 755, + 1, + 5, + 0, + 28, + 1, + 9, + 0, + 26, + 1, + 9, + 0, + 25, + 1, + 11, + 0, + 24, + 1, + 11, + 0, + 24, + 1, + 11, + 0, + 24, + 1, + 11, + 0, + 25, + 1, + 9, + 0, + 26, + 1, + 9, + 0, + 28, + 1, + 5, + 0, + 710 + ], + "mask_annotation_ids_mapping": { + "9e26fc7a-75af-4a51-978e-55f95625176d": 1 + }, + "total_pixels": 1785 + } + }, + "13": { + "keyframe": true, + "raster_layer": { + "dense_rle": [ + 0, + 790, + 1, + 4, + 0, + 29, + 1, + 8, + 0, + 27, + 1, + 8, + 0, + 26, + 1, + 10, + 0, + 25, + 1, + 10, + 0, + 25, + 1, + 10, + 0, + 25, + 1, + 10, + 0, + 26, + 1, + 8, + 0, + 27, + 1, + 8, + 0, + 29, + 1, + 4, + 0, + 676 + ], + "mask_annotation_ids_mapping": { + "9e26fc7a-75af-4a51-978e-55f95625176d": 1 + }, + "total_pixels": 1785 + } + } + }, + "id": "312acef2-734e-437d-b0ca-71722ef4a38f", + "name": "__raster_layer__", + "only_keyframes": true, + "properties": [], + "ranges": [ + [ + 0, + 35 + ] + ], + "slot_names": [ + "0" + ] + } + ], + "properties": [] +} \ No newline at end of file diff --git a/e2e_tests/data/convert/nifti/to/hippocampus_001_mpr_1_test_hippo_test_mask_basic_m.nii.gz b/e2e_tests/data/convert/nifti/to/hippocampus_001_mpr_1_test_hippo_test_mask_basic_m.nii.gz new file mode 100644 index 000000000..a4b62b5e2 Binary files /dev/null and b/e2e_tests/data/convert/nifti/to/hippocampus_001_mpr_1_test_hippo_test_mask_basic_m.nii.gz differ diff --git a/e2e_tests/data/convert/nifti/to/hippocampus_001_mpr_1_test_hippo_test_polygon_basic.nii.gz b/e2e_tests/data/convert/nifti/to/hippocampus_001_mpr_1_test_hippo_test_polygon_basic.nii.gz new file mode 100644 index 000000000..dcf741bca Binary files /dev/null and b/e2e_tests/data/convert/nifti/to/hippocampus_001_mpr_1_test_hippo_test_polygon_basic.nii.gz differ diff --git a/e2e_tests/data/convert/pascalvoc/from/000000021295.json b/e2e_tests/data/convert/pascalvoc/from/000000021295.json new file mode 100644 index 000000000..dc8e22aae --- /dev/null +++ b/e2e_tests/data/convert/pascalvoc/from/000000021295.json @@ -0,0 +1,81 @@ +{ + "version": "2.0", + "schema_ref": "https://darwin-public.s3.eu-west-1.amazonaws.com/darwin_json/2.0/schema.json", + "item": { + "name": "000000021295.jpg", + "path": "/", + "source_info": { + "item_id": "0192c338-2dc8-bb9f-8dde-9c4a8714c957", + "dataset": { + "name": "tmp", + "slug": "tmp", + "dataset_management_url": "https://staging.v7labs.com/datasets/426200/dataset-management" + }, + "team": { + "name": "E2E Testing", + "slug": "e2e-testing" + }, + "workview_url": "https://staging.v7labs.com/workview?dataset=426200&item=0192c338-2dc8-bb9f-8dde-9c4a8714c957" + }, + "slots": [ + { + "type": "image", + "slot_name": "0", + "width": 640, + "height": 427, + "thumbnail_url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/files/6c554c31-8bf6-4fc7-9f31-394fd775b2a6/thumbnail", + "source_files": [ + { + "file_name": "000000021295.jpg", + "url": "https://staging.v7labs.com/api/v2/teams/e2e-testing/uploads/ade5f1e3-a165-4a07-989f-86ee342499c9" + } + ] + } + ] + }, + "annotations": [ + { + "bounding_box": { + "h": 23.3562, + "w": 87.4362, + "x": 103.2062, + "y": 55.6957 + }, + "id": "754f5f2c-71aa-433c-99dd-e7aae940651c", + "name": "test_bounding_box_basic", + "properties": [], + "slot_names": [ + "0" + ] + }, + { + "bounding_box": { + "h": 76.6564, + "w": 72.4642, + "x": 401.4474, + "y": 128.7588 + }, + "id": "fbcdffcc-d053-46db-b336-4c7e2179cf15", + "name": "test_bounding_box_basic", + "properties": [], + "slot_names": [ + "0" + ] + }, + { + "bounding_box": { + "h": 21.5596, + "w": 117.979, + "x": 187.0491, + "y": 262.9074 + }, + "id": "3325b3b5-add0-47ed-9d71-ccc655e3f3e2", + "name": "test_bounding_box_basic", + "properties": [], + "slot_names": [ + "0" + ] + } + ], + "properties": [] +} \ No newline at end of file diff --git a/e2e_tests/data/convert/pascalvoc/to/000000021295.xml b/e2e_tests/data/convert/pascalvoc/to/000000021295.xml new file mode 100644 index 000000000..d1bb2a6d6 --- /dev/null +++ b/e2e_tests/data/convert/pascalvoc/to/000000021295.xml @@ -0,0 +1 @@ +images000000021295.jpgimages/000000021295.jpgdarwin64042730test_bounding_box_basicUnspecified001035619179test_bounding_box_basicUnspecified00401129474205test_bounding_box_basicUnspecified00187263305284 \ No newline at end of file diff --git a/e2e_tests/data/semantic_mask/from/221b-2.json b/e2e_tests/data/convert/semantic_mask/from/221b-2.json similarity index 100% rename from e2e_tests/data/semantic_mask/from/221b-2.json rename to e2e_tests/data/convert/semantic_mask/from/221b-2.json diff --git a/e2e_tests/data/semantic_mask/to/class_mapping.csv b/e2e_tests/data/convert/semantic_mask/to/class_mapping.csv similarity index 100% rename from e2e_tests/data/semantic_mask/to/class_mapping.csv rename to e2e_tests/data/convert/semantic_mask/to/class_mapping.csv diff --git a/e2e_tests/data/yolo/from/test_input_with_bboxes_and_polys.json b/e2e_tests/data/convert/yolo/from/test_input_with_bboxes_and_polys.json similarity index 100% rename from e2e_tests/data/yolo/from/test_input_with_bboxes_and_polys.json rename to e2e_tests/data/convert/yolo/from/test_input_with_bboxes_and_polys.json diff --git a/e2e_tests/data/yolo/to/darknet.labels b/e2e_tests/data/convert/yolo/to/darknet.labels similarity index 100% rename from e2e_tests/data/yolo/to/darknet.labels rename to e2e_tests/data/convert/yolo/to/darknet.labels diff --git a/e2e_tests/data/yolov8/from/test_input_with_bboxes_and_polys.json b/e2e_tests/data/convert/yolov8/from/test_input_with_bboxes_and_polys.json similarity index 100% rename from e2e_tests/data/yolov8/from/test_input_with_bboxes_and_polys.json rename to e2e_tests/data/convert/yolov8/from/test_input_with_bboxes_and_polys.json diff --git a/e2e_tests/data/yolov8/to/darknet.labels b/e2e_tests/data/convert/yolov8/to/darknet.labels similarity index 100% rename from e2e_tests/data/yolov8/to/darknet.labels rename to e2e_tests/data/convert/yolov8/to/darknet.labels diff --git a/e2e_tests/data/yolo/to/test_input_with_bboxes_and_polys.txt b/e2e_tests/data/yolo/to/test_input_with_bboxes_and_polys.txt deleted file mode 100644 index 93acf7c2f..000000000 --- a/e2e_tests/data/yolo/to/test_input_with_bboxes_and_polys.txt +++ /dev/null @@ -1,5 +0,0 @@ -1 0.37675 0.41677 0.39357999999999993 0.34274 -0 0.74999 0.21733 0.31066000000000005 0.21066 -0 0.7666700000000001 0.60467 0.29866000000000004 0.18266 -0 0.432 0.7526700000000001 0.104 0.09466 -1 0.12866999999999998 0.142 0.12749999999999997 0.10883999999999999 \ No newline at end of file diff --git a/e2e_tests/data/yolov8/to/test_input_with_bboxes_and_polys.txt b/e2e_tests/data/yolov8/to/test_input_with_bboxes_and_polys.txt deleted file mode 100644 index a9bdc66ca..000000000 --- a/e2e_tests/data/yolov8/to/test_input_with_bboxes_and_polys.txt +++ /dev/null @@ -1,5 +0,0 @@ -1 0.30963999999999997 0.49563999999999997 0.29192 0.5335599999999999 0.27406 0.51644 0.31636000000000003 0.48402 0.39442 0.26954 0.39304 0.26539999999999997 0.38148000000000004 0.26539999999999997 0.36394 0.26872 0.32583999999999996 0.28058 0.30169999999999997 0.29202 0.28518 0.30345999999999995 0.27614 0.3125 0.25072 0.34554 0.24181999999999998 0.35952 0.2253 0.39254 0.21259999999999998 0.42432 0.20118 0.45964 0.19996 0.50318 0.20124 0.51842 0.20965999999999999 0.5351 0.22019999999999998 0.53424 0.24525999999999998 0.51428 0.24102 0.50944 0.23086 0.48784 0.22824 0.47776 0.22952 0.43710000000000004 0.24609999999999999 0.38127999999999995 0.26389999999999997 0.3457 0.28042 0.32156 0.30568 0.29884 0.32474000000000003 0.28614 0.33872 0.27978 0.37166000000000005 0.26954 0.39552 0.28954 0.37332 0.28954 0.34872000000000003 0.29710000000000003 0.32838 0.30726 0.31060000000000004 0.31995999999999997 0.29610000000000003 0.33358 0.28122 0.3557 0.26342000000000004 0.39127999999999996 0.25058 0.43178 0.24824000000000002 0.45108 0.24824000000000002 0.47776 0.26058 0.50202 0.36092 0.42338 0.38706 0.35608 0.39216 0.33672 0.3947 0.31512 0.5535399999999999 0.4803 0.5535399999999999 0.45616 0.55216 0.45064 0.53962 0.42557999999999996 0.52946 0.40906 0.51706 0.39336 0.50408 0.38364 0.49492 0.37976 0.46442 0.37848000000000004 0.45033999999999996 0.38224 0.41731999999999997 0.40256000000000003 0.38289999999999996 0.43088 0.38668 0.43592000000000003 0.39056 0.44980000000000003 0.39564 0.47522000000000003 0.3943 0.48022000000000004 0.39064 0.48388 0.38564 0.48522000000000004 0.38064 0.48388 0.37698000000000004 0.48022000000000004 0.37066000000000004 0.4505 0.33586 0.52216 0.31956 0.5511 0.3372 0.55738 0.35662 0.56196 0.39454 0.56688 0.46442 0.56814 0.48663999999999996 0.5638 0.50516 0.5555 0.53708 0.5261399999999999 0.54852 0.50708 0.55226 0.48919999999999997 0.5735399999999999 0.4803 0.5735399999999999 0.45616 0.571 0.446 0.5569400000000001 0.41558 0.5467799999999999 0.39906 0.5327999999999999 0.38127999999999995 0.5139 0.36618 0.49492 0.35975999999999997 0.46442 0.35848 0.44036000000000003 0.36492 0.43019999999999997 0.37 0.39280000000000004 0.39672 0.40446 0.36586 0.41216 0.33672 0.4147 0.31512 0.41554 0.28902 0.4186 0.2882 0.42225999999999997 0.28454 0.42360000000000003 0.27954 0.42225999999999997 0.27454 0.4186 0.27088 0.4148 0.26986 0.40954 0.25294 0.40588 0.24928 0.3958 0.2454 0.38056 0.2454 0.3615 0.24922 0.31583999999999995 0.26326 0.2917 0.2747 0.27518 0.28614 0.24609999999999999 0.31774 0.2245 0.34952 0.20163999999999999 0.3978 0.18124 0.4587 0.17996 0.4803 0.18124 0.51842 0.18384 0.5285 0.19274000000000002 0.5463 0.19894 0.5525 0.20648 0.5551 0.21918 0.5551 0.22926 0.5525 0.25858 0.52828 0.2845 0.55274 0.28416 0.5730599999999999 0.2855 0.5780599999999999 0.28916000000000003 0.58172 0.29416000000000003 0.5830599999999999 0.29916000000000004 0.58172 0.30922000000000005 0.56824 0.32854 0.57536 0.35514 0.5818 0.39454 0.58688 0.46442 0.58814 0.50246 0.5791799999999999 0.51516 0.57282 0.52152 0.56774 0.5544 0.53614 0.56584 0.5170800000000001 0.57226 0.48919999999999997 -0 0.59466 0.112 0.9053199999999999 0.112 0.9053199999999999 0.32265999999999995 0.59466 0.32265999999999995 -0 0.61734 0.51334 0.916 0.51334 0.916 0.696 0.61734 0.696 -0 0.38 0.7053400000000001 0.484 0.7053400000000001 0.484 0.8 0.38 0.8 -1 0.19241999999999998 0.12534 0.19094 0.1118 0.18688 0.10773999999999999 0.18134 0.10624 0.17492 0.10726000000000001 0.1736 0.10112 0.16688 0.09440000000000001 0.15734 0.09292 0.14912 0.09573999999999999 0.146 0.09886 0.1362 0.08906 0.13066 0.08758 0.1118 0.09306 0.09876 0.10526 0.09445999999999999 0.10640000000000001 0.08774 0.11312 0.07174 0.14112 0.06492 0.16666 0.06492 0.184 0.0664 0.18954 0.07046 0.1936 0.07866 0.19641999999999998 0.09354000000000001 0.1936 0.09934 0.18913999999999997 0.10646 0.19494 0.112 0.19641999999999998 0.11754 0.19494 0.12294 0.18954 0.12984 0.17432 0.13312000000000002 0.1776 0.13866 0.17908000000000002 0.1482 0.1776 0.15134 0.17448 0.15734 0.17642 0.16288 0.17493999999999998 0.1736 0.16419999999999998 0.1856 0.1482 0.19241999999999998 0.12534