From f7b47fe8e09d2413f23d381f4f095b12ac19810d Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 17 May 2024 10:01:46 +0300 Subject: [PATCH] Fixed object count in analytics for skeletons and tracks (#7883) ### Motivation and context ### How has this been tested? ### Checklist - [x] I submit my changes into the `develop` branch - [x] I have created a changelog fragment - [ ] I have updated the documentation accordingly - [ ] I have added tests to cover my changes - [ ] I have linked related issues (see [GitHub docs]( https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)) - [ ] I have increased versions of npm packages if it is necessary ([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning), [cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning), [cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning) and [cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning)) ### License - [x] I submit _my code changes_ under the same [MIT License]( https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern. ## Summary by CodeRabbit - **Bug Fixes** - Corrected an issue where analytics reported an incorrect count of objects for skeleton tracks/shapes. - Fixed a bug where the analytic report consistently showed one less object for tracks than the actual count. - **Improvements** - Enhanced filtering logic for shapes and tracks in analytics, improving the accuracy of annotation speed metrics. --- ...000_boris_fixed_analytics_for_skeletons.md | 4 ++++ ...034_boris_fixed_analytics_for_skeletons.md | 4 ++++ .../primary_metrics/annotation_speed.py | 22 ++++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 changelog.d/20240510_095000_boris_fixed_analytics_for_skeletons.md create mode 100644 changelog.d/20240510_095034_boris_fixed_analytics_for_skeletons.md diff --git a/changelog.d/20240510_095000_boris_fixed_analytics_for_skeletons.md b/changelog.d/20240510_095000_boris_fixed_analytics_for_skeletons.md new file mode 100644 index 00000000000..195fbb45e3d --- /dev/null +++ b/changelog.d/20240510_095000_boris_fixed_analytics_for_skeletons.md @@ -0,0 +1,4 @@ +### Fixed + +- Analytic reports incorrect count of objects for a skeleton track/shape + () diff --git a/changelog.d/20240510_095034_boris_fixed_analytics_for_skeletons.md b/changelog.d/20240510_095034_boris_fixed_analytics_for_skeletons.md new file mode 100644 index 00000000000..23de54ca9d0 --- /dev/null +++ b/changelog.d/20240510_095034_boris_fixed_analytics_for_skeletons.md @@ -0,0 +1,4 @@ +### Fixed + +- Analytic reports incorrect number of objects for a track (always less by 1) + () diff --git a/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py b/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py index b8fee146594..a3a0d3afbd9 100644 --- a/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py +++ b/cvat/apps/analytics_report/report/primary_metrics/annotation_speed.py @@ -18,7 +18,7 @@ PrimaryMetricBase, ) from cvat.apps.dataset_manager.task import merge_table_rows -from cvat.apps.engine.models import SourceType +from cvat.apps.engine.models import ShapeType, SourceType class JobAnnotationSpeedExtractor(DataExtractorBase): @@ -75,20 +75,21 @@ def get_tags_count(): def get_shapes_count(): return ( - self._db_obj.labeledshape_set.filter(parent=None) - .exclude(source=SourceType.FILE) + self._db_obj.labeledshape_set.exclude(source=SourceType.FILE) + .exclude( + type=ShapeType.SKELETON + ) # skeleton's points are already counted as objects .count() ) def get_track_count(): db_tracks = ( - self._db_obj.labeledtrack_set.filter(parent=None) - .exclude(source=SourceType.FILE) + self._db_obj.labeledtrack_set.exclude(source=SourceType.FILE) .values( "id", - "source", "trackedshape__id", "trackedshape__frame", + "trackedshape__type", "trackedshape__outside", ) .order_by("id", "trackedshape__frame") @@ -101,6 +102,7 @@ def get_track_count(): "shapes": [ "trackedshape__id", "trackedshape__frame", + "trackedshape__type", "trackedshape__outside", ], }, @@ -109,12 +111,16 @@ def get_track_count(): count = 0 for track in db_tracks: + if track["shapes"] and track["shapes"][0]["type"] == ShapeType.SKELETON: + # skeleton's points are already counted as objects + continue + if len(track["shapes"]) == 1: count += self._db_obj.segment.stop_frame - track["shapes"][0]["frame"] + 1 for prev_shape, cur_shape in zip(track["shapes"], track["shapes"][1:]): - if prev_shape["outside"] is not True: - count += cur_shape["frame"] - prev_shape["frame"] + if not prev_shape["outside"]: + count += cur_shape["frame"] - prev_shape["frame"] + 1 return count