1

I'm trying to use the CVAT API to create labeling tasks and attach image data from AWS S3 to the tasks. However, I find it impossible to assign segments to a labeling task while creating the task or after creating the task. When I use the UI to create tasks, they are subsequently shown in the "Tasks" section. When I use API requests, they are somehow registered, but not shown in the UI, and no data seems to be attached to them. I have tried various routes from the CVAT OpenAPI docs, but none of them seem to offer the capabilities that I need.

naraghi
  • 430
  • 1
  • 6
  • 18

2 Answers2

0

I was able to do it in the end by inspecting the network traffic in the browser and copying the POST-requests made when creating a task.

naraghi
  • 430
  • 1
  • 6
  • 18
0

Per https://github.com/opencv/cvat/issues/6012, here is code that creates a CVAT task from S3:

import time
from http import HTTPStatus

from cvat_sdk import make_client
from cvat_sdk.api_client import ApiClient, Configuration
from cvat_sdk.core.proxies.tasks import ResourceType


def low_level_client(ip, user, password):
    host = f"http://{ip}:8080"
    return ApiClient(Configuration(host, username=user, password=password))


def create_task_low_level(api_client, spec, data):
    task, task_response = api_client.tasks_api.create(spec)
    assert task_response.status == HTTPStatus.CREATED
    api_client.tasks_api.create_data(task.id, data)
    for i in range(10):
        status = api_client.tasks_api.retrieve_status(task.id)[0]
        if status.state.value == "Finished":
            break
        time.sleep(1)
    return task


ip = "1.2.3.4"
manifest = "da787e7156274df9a4fcc63e48acb28f.jsonl" 
filenames = [
    "OK01R_left_2023-03-31T08:27:49.501349+00:00.jpg",
    "OK01R_right_2023-03-31T08:27:50.358855+00:00.jpg",
]
images_and_manifest = filenames + [manifest]
storage_id = 4                 
data = dict(
    image_quality=75,
    use_cache=True,
    cloud_storage_id=storage_id,
    server_files=images_and_manifest,
)
user = "user"
password = "secret"
spec = {"name": "task1", "labels": [{"name": "car"}]}
with low_level_client(ip, user, password) as api_client:
    task = create_task_low_level(api_client, spec, data)
mherzog
  • 1,085
  • 1
  • 12
  • 24