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

Fixed object count in analytics for skeletons and tracks #7883

Merged
merged 7 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Analytic reports incorrect count of objects for a skeleton track/shape
(<https://github.com/cvat-ai/cvat/pull/7883>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add angle brackets around the link for consistency.

-  (<https://github.com/cvat-ai/cvat/pull/7883>)
+  (<https://github.com/cvat-ai/cvat/pull/7883>)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Analytic reports incorrect number of objects for a track (always less by 1)
(<https://github.com/cvat-ai/cvat/pull/7883>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add angle brackets around the link for consistency.

-  (<https://github.com/cvat-ai/cvat/pull/7883>)
+  (<https://github.com/cvat-ai/cvat/pull/7883>)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
(<https://github.com/cvat-ai/cvat/pull/7883>)

Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Expand All @@ -101,6 +102,7 @@ def get_track_count():
"shapes": [
"trackedshape__id",
"trackedshape__frame",
"trackedshape__type",
"trackedshape__outside",
],
},
Expand All @@ -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

Expand Down
Loading