|
|
|
|
@ -2779,6 +2779,84 @@ class TaskAnnotationAPITestCase(JobAnnotationAPITestCase):
|
|
|
|
|
elif annotation_format_name == "MASK":
|
|
|
|
|
self.assertTrue(zipfile.is_zipfile(content))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _run_coco_annotation_upload_test(self, user):
|
|
|
|
|
def generate_coco_anno():
|
|
|
|
|
return b"""{
|
|
|
|
|
"categories": [
|
|
|
|
|
{
|
|
|
|
|
"id": 1,
|
|
|
|
|
"name": "car",
|
|
|
|
|
"supercategory": ""
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"id": 2,
|
|
|
|
|
"name": "person",
|
|
|
|
|
"supercategory": ""
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"images": [
|
|
|
|
|
{
|
|
|
|
|
"coco_url": "",
|
|
|
|
|
"date_captured": "",
|
|
|
|
|
"flickr_url": "",
|
|
|
|
|
"license": 0,
|
|
|
|
|
"id": 0,
|
|
|
|
|
"file_name": "test_1.jpg",
|
|
|
|
|
"height": 720,
|
|
|
|
|
"width": 1280
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"annotations": [
|
|
|
|
|
{
|
|
|
|
|
"category_id": 1,
|
|
|
|
|
"id": 1,
|
|
|
|
|
"image_id": 0,
|
|
|
|
|
"iscrowd": 0,
|
|
|
|
|
"segmentation": [
|
|
|
|
|
[]
|
|
|
|
|
],
|
|
|
|
|
"area": 17702.0,
|
|
|
|
|
"bbox": [
|
|
|
|
|
574.0,
|
|
|
|
|
407.0,
|
|
|
|
|
167.0,
|
|
|
|
|
106.0
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}"""
|
|
|
|
|
|
|
|
|
|
response = self._get_annotation_formats(user)
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
supported_formats = response.data
|
|
|
|
|
self.assertTrue(isinstance(supported_formats, list) and supported_formats)
|
|
|
|
|
|
|
|
|
|
coco_format = None
|
|
|
|
|
for f in response.data:
|
|
|
|
|
if f["name"] == "COCO":
|
|
|
|
|
coco_format = f
|
|
|
|
|
break
|
|
|
|
|
self.assertTrue(coco_format)
|
|
|
|
|
loader = coco_format["loaders"][0]
|
|
|
|
|
|
|
|
|
|
task, _ = self._create_task(user, user)
|
|
|
|
|
|
|
|
|
|
content = io.BytesIO(generate_coco_anno())
|
|
|
|
|
content.seek(0)
|
|
|
|
|
|
|
|
|
|
uploaded_data = {
|
|
|
|
|
"annotation_file": content,
|
|
|
|
|
}
|
|
|
|
|
response = self._upload_api_v1_tasks_id_annotations(task["id"], user, uploaded_data, "format={}".format(loader["display_name"]))
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
|
|
|
|
|
|
|
|
|
|
response = self._upload_api_v1_tasks_id_annotations(task["id"], user, {}, "format={}".format(loader["display_name"]))
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
|
|
|
|
|
|
|
|
|
response = self._get_api_v1_tasks_id_annotations(task["id"], user)
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
|
|
def test_api_v1_tasks_id_annotations_admin(self):
|
|
|
|
|
self._run_api_v1_tasks_id_annotations(self.admin, self.assignee,
|
|
|
|
|
self.assignee)
|
|
|
|
|
@ -2801,6 +2879,9 @@ class TaskAnnotationAPITestCase(JobAnnotationAPITestCase):
|
|
|
|
|
def test_api_v1_tasks_id_annotations_dump_load_no_auth(self):
|
|
|
|
|
self._run_api_v1_tasks_id_annotations_dump_load(self.user, self.assignee, None)
|
|
|
|
|
|
|
|
|
|
def test_api_v1_tasks_id_annotations_upload_coco_user(self):
|
|
|
|
|
self._run_coco_annotation_upload_test(self.user)
|
|
|
|
|
|
|
|
|
|
class ServerShareAPITestCase(APITestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.client = APIClient()
|
|
|
|
|
|