Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vilhub opened this issue Feb 20, 2025 · 1 comment
Closed
Labels
question Further information is requested

Comments

@vilhub
Copy link

vilhub commented Feb 20, 2025

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!

@azhavoro azhavoro added the question Further information is requested label Feb 21, 2025
@azhavoro
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants