Programmatically insert task annotations
See original GitHub issueHello,
I’m trying to integrate an external tool to automate some operations using CVAT API. I’m already able to perform most of the operations such as authenticating, creating tasks, listing tasks, uploading videos to tasks and label definitions/configurations to tasks.
But I’m currently struggling with uploading annotations into a task.
I already have a parser that converts from my annotation format to the format described on the endpoint /tasks/{id}/annotations
in the /api/swagger
docs, if I get my converted annotations json and use the PUT /tasks/{id}/annotations
route on the swagger Try it out function it returns me 200 and creates the annotations just fine.
But when using my python tool it returns me 200 and the annotation is not getting created in the task.
Am I missing a header?
Here’s my HTTP debug logs:
HTTP/1.1 PUT http://MY_HOST:8080/api/v1/tasks/56/annotations
Content-Type: application/json
Accept: application/json
Authorization: Basic f644b969c47f732b0110c33729e7505b143fdf1f
X-CSRFToken: lj6cPpfmjBw6knp1TpwRPyRAtYZUnOI4DCmlhwHAyHTzdp88Ov86u1xoO4nJrMm4
Cookie: csrftoken=lj6cPpfmjBw6knp1TpwRPyRAtYZUnOI4DCmlhwHAyHTzdp88Ov86u1xoO4nJrMm4; sessionid=ee907kwqz1yuf5mtrcqw1mmvzij6qjdk
Content-Length: 2710
{"version": 1, "tags": [], "shapes": [{"type": "points", "occluded": false, "label_id": 3603, "points": [0, 0, 0, 0], "group": 0, "frame": 0, "attributes": [{"spec_id": 24944, "value": "89"}, {"spec_id": 24945, "value": "1624"}]}], "tracks": [{"frame": 88, "label_id": 3612, "group": 0, "shapes": [{"type": "rectangle", "frame": 88, "occluded": false, "outside": false, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}, {"type": "rectangle", "frame": 529, "occluded": false, "outside": true, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}], "attributes": [{"spec_id": 25005, "value": ""}, {"spec_id": 25008, "value": "1570530132.277753"}, {"spec_id": 25004, "value": "True"}, {"spec_id": 25002, "value": "None"}, {"spec_id": 25003, "value": "5"}, {"spec_id": 25006, "value": "3"}, {"spec_id": 25007, "value": "1570530113.930426"}]}, {"frame": 602, "label_id": 3667, "group": 0, "shapes": [{"type": "rectangle", "frame": 602, "occluded": false, "outside": false, "points": [400.0, 600.0, 1050.0, 1050.0], "attributes": []}, {"type": "rectangle", "frame": 1114, "occluded": false, "outside": true, "points": [400.0, 600.0, 1050.0, 1050.0], "attributes": []}], "attributes": [{"spec_id": 25390, "value": ""}, {"spec_id": 25393, "value": "1570530156.657058"}, {"spec_id": 25389, "value": "True"}, {"spec_id": 25387, "value": "None"}, {"spec_id": 25388, "value": "3"}, {"spec_id": 25391, "value": "5"}, {"spec_id": 25392, "value": "1570530135.343988"}]}, {"frame": 723, "label_id": 3641, "group": 0, "shapes": [{"type": "rectangle", "frame": 723, "occluded": false, "outside": false, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}, {"type": "rectangle", "frame": 1087, "occluded": false, "outside": true, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}], "attributes": [{"spec_id": 25208, "value": ""}, {"spec_id": 25211, "value": "1570530155.551199"}, {"spec_id": 25207, "value": "True"}, {"spec_id": 25205, "value": "None"}, {"spec_id": 25206, "value": "5"}, {"spec_id": 25209, "value": "3"}, {"spec_id": 25210, "value": "1570530140.370748"}]}, {"frame": 1210, "label_id": 3624, "group": 0, "shapes": [{"type": "rectangle", "frame": 1210, "occluded": false, "outside": false, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}, {"type": "rectangle", "frame": 1609, "occluded": false, "outside": true, "points": [950.0, 500.0, 1350.0, 1100.0], "attributes": []}], "attributes": [{"spec_id": 25089, "value": ""}, {"spec_id": 25092, "value": "1570530177.316677"}, {"spec_id": 25088, "value": "True"}, {"spec_id": 25086, "value": "None"}, {"spec_id": 25087, "value": "5"}, {"spec_id": 25090, "value": "3"}, {"spec_id": 25091, "value": "1570530160.678561"}]}]}
HTTP/1.1 200
Date: Fri, 21 Feb 2020 11:08:40 GMT
Server: Apache
Content-Length: 47
Vary: Accept,Origin,Cookie
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
X-Frame-Options: SAMEORIGIN
Connection: close
Content-Type: application/json
b'{"version":0,"tags":[],"shapes":[],"tracks":[]}'
Here’s a snippet of my generic method for sending requests to CVAT API, it’s currently working for the other routes.
# ...
if data:
data = json.dumps(data)
prepped_request = Request(
method=method,
url=endpoint_url,
headers=headers,
data=data,
params=params,
files=files,
cookies=cookies
)
# ...
response = session.send(prepped_request)
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top GitHub Comments
Ok I found
/tasks/{id}/status
If I put a
time.sleep(10)
between creating the task + uploading the video for a task and uploading the annotations it works… is there any way for me to poll on the task to check if it’s ready to receive the annotations upload?