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

LambdaFunction does not map attrs of skeleton sublabels #8213

Closed
2 tasks done
josiahls opened this issue Jul 23, 2024 · 1 comment · Fixed by #8251
Closed
2 tasks done

LambdaFunction does not map attrs of skeleton sublabels #8213

josiahls opened this issue Jul 23, 2024 · 1 comment · Fixed by #8251
Labels
bug Something isn't working

Comments

@josiahls
Copy link

josiahls commented Jul 23, 2024

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Steps to Reproduce

  1. Create skeleton
  2. Add confidence attr to individual points
  3. Have nuclio function return a skeleton with keypoints that have confidence sublabels
  4. CVAT ui, the confidence labels will be unchanged / have the default values.

Expected Behavior

nuclio functions should be able to return skeletons with sublabels that have attrbibutes.

Possible Solution

Update views.py:
https://github.com/josiahls/cvat/blob/patch-1/cvat/apps/lambda_manager/views.py

def update_mapping(_mapping, _model_labels, _db_labels):
    logger.debug("Starting update_mapping with _mapping: %s, _model_labels: %s, _db_labels: %s", _mapping, _model_labels, _db_labels)
    copy = deepcopy(_mapping)
    
    for model_label_name, mapping_item in copy.items():
        try:
            logger.debug("Processing model_label_name: %s", model_label_name)
            md_label = next(filter(lambda x: x['name'] == model_label_name, _model_labels))
            db_label = next(filter(lambda x: x.name == mapping_item['name'], _db_labels))
            mapping_item.setdefault('attributes', {})
            mapping_item['md_label'] = md_label
            mapping_item['db_label'] = db_label
            
            logger.debug("Mapped md_label: %s to db_label: %s", md_label, db_label)

            if md_label['type'] == 'skeleton' and db_label.type == 'skeleton':
                mapping_item['sublabels'] = update_mapping(
                    mapping_item['sublabels'],
                    md_label['sublabels'],
                    db_label.sublabels.all()
                )
                logger.debug("Updated sublabels for label: %s", model_label_name)

                # Ensure sublabel attributes are also mapped
                for sub_md_label in md_label['sublabels']:
                    sub_md_name = sub_md_label['name']
                    sub_db_label = next(filter(lambda x: x.name == sub_md_name, db_label.sublabels.all()), None)
                    if sub_db_label:
                        sublabel_attr_mapping = {
                            attr['name']: attr['name'] for attr in sub_md_label['attributes']
                        }
                        mapping_item['sublabels'][sub_md_name]['attributes'] = sublabel_attr_mapping
                        logger.debug("Mapped sublabel attributes for sublabel: %s - %s", sub_md_name, sublabel_attr_mapping)
        except Exception as e:
            logger.error("Error processing label: %s, Error: %s", model_label_name, e)
    
    logger.debug("Finished update_mapping with result: %s", copy)
    return copy

Context

nulcio autolabelling for skeletons that have keypoints with attributes.

Environment

git log -2
commit c99b4503b3d6b2f04413cc8d5dd666bab1e40ece (HEAD -> patch-1, origin/patch-1)
Merge: d931645b1 ab636fb14
Author: josiahls <josiahls@users.noreply.github.com>
Date:   Fri May 31 14:59:42 2024 -0400

    Merge branch 'cvat-ai:develop' into patch-1

commit ab636fb1455a49bb820ee697c394b9dc82d66830 (origin/develop, origin/HEAD)
Author: Boris Sekachev <boris.sekachev@yandex.ru>
Date:   Fri May 31 10:38:44 2024 +0300

    Squashed `zoom:image` and `send:exception` client events (#7953)
@josiahls josiahls added the bug Something isn't working label Jul 23, 2024
@bsekachev
Copy link
Member

Hello, may you send a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants