Skip to content

New annotation format guide : "Label is not registered for this task" #9127

Closed
@vilhub

Description

@vilhub

Hi all!

When following the instructions for adding a new annotation format, at the bottom there is a snippet to import labeled shapes, however when trying to run this

shape = task_data.LabeledShape(
  type="rectangle",
  points=[0, 0, 100, 100],
  occluded=False,
  attributes=[],
  label="car",
  outside=False,
  frame=0,
)
task_data.add_shape(shape)

I get

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/**/cvat/cvat/apps/dataset_manager/bindings.py", line 683, in add_shape
    imported_shape = self._import_shape(shape)
  File "/**/cvat/cvat/apps/dataset_manager/bindings.py", line 606, in _import_shape
    label_id = self._get_label_id(_shape.pop('label'), parent_label_id)
  File "/**/cvat/cvat/apps/dataset_manager/bindings.py", line 109, in _get_label_id
    raise ValueError("Label {!r} is not registered for this task".format(label_name))
ValueError: Label 'car' is not registered for this task

After scouring the code for a bit, I didn't find an easy way of adding labels like task_data.add_label. It seems pretty much all other annotation formats rely on datumaro and the label handling seems to be done by it.

I could add the label "manually" to task_data._label_mapping to prevent the failure above, but since _label_mapping is a private member variable I don't think that's the intended way, and there might be side effects that I'm unaware about.

What's the "official" way to do this?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions