Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for wrong attribute import in tracks #3279

Merged
merged 6 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions cvat/apps/dataset_manager/tests/assets/annotations.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,49 @@
}
]
},
"CVAT for video 1.1 attributes in tracks": {
"version": 0,
nmanovic marked this conversation as resolved.
Show resolved Hide resolved
"tags": [],
"shapes": [],
"tracks": [
{
"frame": 0,
"label_id": null,
"group": 0,
"source": "manual",
"shapes": [
{
"type": "polygon",
"occluded": false,
"z_order": 0,
"points": [25.04, 13.7, 35.85, 20.2, 16.65, 19.8],
"frame": 1,
"outside": false,
"attributes": []
}
],
"attributes": []
},
{
"frame": 8,
"label_id": null,
"group": 1,
"source": "manual",
"shapes": [
{
"type": "rectangle",
"occluded": true,
"z_order": 0,
"points": [5.54, 3.5, 19.64, 11.19],
"frame": 1,
"outside": false,
"attributes": []
}
],
"attributes": []
}
]
},
"WiderFace 1.0": {
"version": 0,
"tags": [],
Expand Down
13 changes: 13 additions & 0 deletions cvat/apps/dataset_manager/tests/assets/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,18 @@
]
}
]
},
"many jobs": {
nmanovic marked this conversation as resolved.
Show resolved Hide resolved
"name": "many jobs",
"overlap": 0,
"segment_size": 5,
"owner_id": 1,
"labels": [
{
"name": "car",
"color": "#2080c0",
"attributes": []
}
]
}
}
46 changes: 46 additions & 0 deletions cvat/apps/dataset_manager/tests/test_rest_api_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,52 @@ def test_api_v1_check_widerface_with_all_attributes(self):
extractor = CvatTaskDataExtractor(task_data, include_images=include_images)
data_from_task_before_upload = Dataset.from_extractors(extractor)

# dump annotations
url = self._generate_url_dump_tasks_annotations(task_id)
data = {
"format": dump_format_name,
"action": "download",
}
with TestDir() as test_dir:
file_zip_name = osp.join(test_dir, f'{test_name}_{dump_format_name}.zip')
self._download_file(url, data, self.admin, file_zip_name)
self._check_downloaded_file(file_zip_name)

# remove annotations
self._remove_annotations(url, self.admin)

# upload annotations
url = self._generate_url_upload_tasks_annotations(task_id, upload_format_name)
with open(file_zip_name, 'rb') as binary_file:
self._upload_file(url, binary_file, self.admin)

# equals annotations
task_ann = TaskAnnotation(task_id)
task_ann.init_from_db()
task_data = TaskData(task_ann.ir_data, Task.objects.get(pk=task_id))
extractor = CvatTaskDataExtractor(task_data, include_images=include_images)
data_from_task_after_upload = Dataset.from_extractors(extractor)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract this fragment into a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added function for this.

compare_datasets(self, data_from_task_before_upload, data_from_task_after_upload)\

def test_api_v1_check_attribute_import_in_tracks(self):
test_name = self._testMethodName
dump_format_name = "CVAT for video 1.1"
upload_format_name = "CVAT 1.1"

for include_images in (False, True):
with self.subTest():
# create task with annotations
images = self._generate_task_images(13)
task = self._create_task(tasks["many jobs"], images)
self._create_annotations(task, f'{dump_format_name} attributes in tracks', "default")

task_id = task["id"]
task_ann = TaskAnnotation(task_id)
task_ann.init_from_db()
task_data = TaskData(task_ann.ir_data, Task.objects.get(pk=task_id))
extractor = CvatTaskDataExtractor(task_data, include_images=include_images)
data_from_task_before_upload = Dataset.from_extractors(extractor)

# dump annotations
url = self._generate_url_dump_tasks_annotations(task_id)
data = {
Expand Down