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

Prepare UI for attributes configuration #4506

Closed
wants to merge 5 commits into from

Conversation

azhiv
Copy link
Contributor

@azhiv azhiv commented Mar 24, 2022

Motivation and context

This PR allows attributes mapping that belong to certain labels (model and task) with ability to pre-map attributes based on their names.
The values returned from nuclio function are also processed during inference to filter out attributes with incompatible types/values.

How has this been tested?

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below)
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT

@azhiv
Copy link
Contributor Author

azhiv commented Mar 24, 2022

@nmanovic @bsekachev Can you please review the approach for automapping label attributes? This is a follow up PR for functionality developed in scope of #3917
@mikhail-treskin

@nmanovic
Copy link
Contributor

@azhiv , is it ready? If so, please remove 'draft' mode. Also could you please look at linter issues?

Indeed I believe the problem with copyright header: Copyright (C) 2019-2021 Intel Corporation. Need to update the year: Copyright (C) 2019-2022 Intel Corporation. If you setup all VS code extensions, it will be updated automatically for files, which you touch. See the list of extensions here: https://openvinotoolkit.github.io/cvat/docs/contributing/development-environment/

image

@nmanovic nmanovic requested a review from klakhov March 25, 2022 11:38
@nmanovic
Copy link
Contributor

@klakhov , could you please look at the PR?

@azhiv azhiv marked this pull request as ready for review March 29, 2022 06:03
@azhiv azhiv requested a review from bsekachev as a code owner March 29, 2022 06:03
@azhiv
Copy link
Contributor Author

azhiv commented Mar 29, 2022

@klakhov I just finished the implementation, can you please trigger the approval checks?

@klakhov
Copy link
Contributor

klakhov commented Mar 29, 2022

Hey, great work! That feature looks nice to me.

But while testing this pr I've encountered detection error
image
I've created a label named label1 with some attributes, and mapped face-detection-0205 label face and it's attributes to my label attrs. Then when i'm trying to annotate image Cant read property 'find' of undefined occurs. It happens on line 1089, where model.attributes[data.label].find is called. I suppose the problem here is that data.label is my label1 and not model's face

Also, could you please update CHANGELOG.md with a link to your pr in Added section and update cvat-ui package version with npm version minor?

@azhiv
Copy link
Contributor Author

azhiv commented Mar 29, 2022

@klakhov A big thanks for your feedback! In fact I missed this case during testing, focusing only on "positive" test cases. I'll fix this issue.
BTW is there a proper place to add tests for this logic?

@klakhov
Copy link
Contributor

klakhov commented Mar 29, 2022

@azhiv Currently we don't test 'AI tools' functionality due to CI reasons, so it's better to check as many cases as possible manually

@azhiv
Copy link
Contributor Author

azhiv commented Mar 31, 2022

@klakhov I fixed the issue that you pointed out, and added a small usability enhancement (attributes are automapped during labels selection even if the label names differ). Could you please review the changes?

Copy link
Contributor

@klakhov klakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, the issue seems to be fixed.

But it seems we have the same problem with attributes. If attribute name is different from model's, even though I mapped them, after annotation is completed my attributes are set to default. I think we should cover this case too.
image

As you can see on my screenshot, if I'm using label1(with attrs gender, age) everything works fine, and if I'm using label2(with attrs gender123, age123) they are defaulted.
image

@azhiv
Copy link
Contributor Author

azhiv commented Mar 31, 2022

@klakhov I also noticed this behaviour, but the reason for that is empty attributes array received from the BE
Screenshot 2022-03-31 at 07 08 09

I asked @mikhail-treskin, he needs time to investigate this.

@klakhov
Copy link
Contributor

klakhov commented Apr 1, 2022

@azhiv Alright, let us know if you can figure something out 🙂

@azhiv
Copy link
Contributor Author

azhiv commented Apr 7, 2022

@klakhov Please help me to understand the requirements.
Here's the label setup I use for testing:
Screenshot 2022-04-07 at 15 40 39

When I run the automatic annotation against the following configuration:
Screenshot 2022-04-07 at 15 41 12

I get the following result:
Screenshot 2022-04-07 at 15 39 22

The two non-mapped attributes gain default values which is fine, but the first one's value - Adult - is not in the list of allowed ones - [1, 2, 3].

So the question is - what value is attribute1 expected to hold in this scenario? The way it works now doesn't seem correct.

Check the attributes returned by nuclio function call and reject those that
have either incompatible types or values.
The code in lambda_manager didn't account for attributes mappings that had
different names thus returning an empty set of attributes because it couldn't
find the correct match. Fix this by getting proper mapping from `attrMapping`
property of the input data.
@bsekachev
Copy link
Member

@azhiv

So the question is - what value is attribute1 expected to hold in this scenario? The way it works now doesn't seem correct.

I believe if serverless response for an attribute value is out of specification, we should just ignore it. Maybe to show a single warning message in case when we run serverless function on one frame.

@klakhov
Copy link
Contributor

klakhov commented Apr 11, 2022

@azhiv , I would agree with @bsekachev, if we have an attribute value that we are not expected to have, it shouldnt be written into mapped value. It would be great to see warning message about such situation just to let user see what happened.

@azhiv
Copy link
Contributor Author

azhiv commented Apr 13, 2022

There's a bunch of lambda manager tests that failed as a result of my recent changes. I was able to localize the problem, but I'd like to get sure and rerun the tests locally before I push the corrected code. How can lambda manager tests be executed in my local environment? This one test_api_v2_lambda_requests_create_empty_mapping for example.

@azhiv
Copy link
Contributor Author

azhiv commented Apr 13, 2022

@bsekachev @klakhov Thanks for your feedback!
Should the gained attribute be rejected as a result of check_attr_value?

Screenshot 2022-04-13 at 18 58 20

@merchantbreeze
Copy link

It's a nice work I need!
It's vaild on the jobs page with AI Tools, but when I used the Automatic annotation with your example model, I've encountered detection error.
QQ截图20220519223209
QQ截图20220519223240
Here is the logs in cvat

2022-05-19 14:32:30,258 DEBG 'rqworker_low' stderr output:
DEBUG - 2022-05-19 14:32:30,258 - worker - Handling failed execution of job 953d039f-1148-44e3-922b-07e8d5e7a576

2022-05-19 14:32:30,260 DEBG 'rqworker_low' stderr output:
ERROR - 2022-05-19 14:32:30,260 - worker - Traceback (most recent call last):
  File "/home/django/cvat/apps/lambda_manager/views.py", line 197, in invoke
    mapped_attributes = attr_mapping[func_label].get("attributes")
KeyError: 'face'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/rq/worker.py", line 936, in perform_job
    rv = job.perform()
  File "/opt/venv/lib/python3.8/site-packages/rq/job.py", line 684, in perform
    return self.func(*self.args, **self.kwargs)
  File "/home/django/cvat/apps/lambda_manager/views.py", line 618, in __call__
    LambdaJob._call_detector(function, db_task, labels, quality,
  File "/home/django/cvat/apps/lambda_manager/views.py", line 468, in _call_detector
    annotations = function.invoke(db_task, data={
  File "/home/django/cvat/apps/lambda_manager/views.py", line 241, in invoke
    raise ValidationError(
django.core.exceptions.ValidationError: ["`openvino-omz-face-detection-0205` lambda function was called without mandatory argument: 'face'"]
Traceback (most recent call last):
  File "/home/django/cvat/apps/lambda_manager/views.py", line 197, in invoke
    mapped_attributes = attr_mapping[func_label].get("attributes")
KeyError: 'face'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/rq/worker.py", line 936, in perform_job
    rv = job.perform()
  File "/opt/venv/lib/python3.8/site-packages/rq/job.py", line 684, in perform
    self._result = self._execute()
  File "/opt/venv/lib/python3.8/site-packages/rq/job.py", line 690, in _execute
    return self.func(*self.args, **self.kwargs)
  File "/home/django/cvat/apps/lambda_manager/views.py", line 618, in __call__
    LambdaJob._call_detector(function, db_task, labels, quality,
  File "/home/django/cvat/apps/lambda_manager/views.py", line 468, in _call_detector
    annotations = function.invoke(db_task, data={
  File "/home/django/cvat/apps/lambda_manager/views.py", line 241, in invoke
    raise ValidationError(
django.core.exceptions.ValidationError: ["`openvino-omz-face-detection-0205` lambda function was called without mandatory argument: 'face'"]

2022-05-19 14:32:30,260 DEBG 'rqworker_low' stderr output:
DEBUG - 2022-05-19 14:32:30,260 - worker - Invoking exception handler <function rq_handler at 0x7f446a60bee0>

2022-05-19 14:32:30,273 DEBG 'rqworker_low' stderr output:
DEBUG - 2022-05-19 14:32:30,273 - worker - Sent heartbeat to prevent worker timeout. Next one should arrive within 480 seconds.

2022-05-19 14:32:30,273 DEBG 'rqworker_low' stderr output:
DEBUG - 2022-05-19 14:32:30,273 - worker - Sent heartbeat to prevent worker timeout. Next one should arrive within 480 seconds.

2022-05-19 14:32:30,274 DEBG 'rqworker_low' stderr output:
DEBUG - 2022-05-19 14:32:30,274 - worker - *** Listening on low...

2022-05-19 14:32:30,275 DEBG 'rqworker_low' stderr output:
DEBUG - 2022-05-19 14:32:30,275 - worker - Sent heartbeat to prevent worker timeout. Next one should arrive within 480 seconds.

It seems like an error about attribute dict, key 'face' is not exist in the dict so we got a KeyError.

@merchantbreeze
Copy link

merchantbreeze commented May 24, 2022

I have solved it.I found that the respond method of Automatic Annotation is different with AI Tool in jobs page, the attrsMapping is missing from the args, so we can't get it.

@bsekachev
Copy link
Member

Hi @azhiv

Thank you for the contribution.
We've finished the patch and merged it to our current CVAT fork: https://github.com/cvat-ai/cvat

You can see corresponding commit here :)

@azhiv
Copy link
Contributor Author

azhiv commented Jul 20, 2022

@bsekachev Great news, at last! Thanks for sharing.

@azhiv azhiv closed this Jul 25, 2022
@nmanovic nmanovic mentioned this pull request Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants