cvat-ai / cvat

Annotate better with CVAT, the industry-leading data engine for machine learning. Used and trusted by teams at any scale, for data of any scale.
https://cvat.ai
MIT License
12.4k stars 2.98k forks source link

Uploading annotations using Python high-level API #6887

Closed hetfmt closed 1 year ago

hetfmt commented 1 year ago

My actions before raising this issue

I have a number of images and matching polygon annotations. I would like to get these into CVAT, and have create a "task" and uploaded a couple of images using a modified version of the the example given in: https://opencv.github.io/cvat/docs/api_sdk/sdk/highlevel-api/

Now I would like to add some annotations to the images, but this is where my problem starts:

The "task.get_meta()" contains the names of the files I have added, but does not contain the generated image-ID's. And the "annotations" structure contains an image ID, but does not contain the original file name:

{'shapes': [{'attributes': [],
             'elements': [],
             'frame': 0,
             'group': 0,
             'id': <assigned_image_id>, 
             ...

Is it possible to find matched "file name" and "image ID" information, or how do I ensure that my annotations are attached to the correct image?

Or am doing it completely wrong? Right now, for each image I have a JSON-file that contains my existing annotations. Should I rather create a task and upload images/annotations in a different way?

Thanks.

zhiltsov-max commented 1 year ago

Hi, the task.get_meta() function returns the file names in the same order as the files are available in the task. Please use the list indices (0-based) as frame ids in the annotations you're sending.