Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/zm/fix-dataset-downloading' into…
Browse files Browse the repository at this point in the history
… zm/fix-dataset-downloading
  • Loading branch information
zhiltsov-max committed May 17, 2024
2 parents 4471aa9 + 2a67f2e commit de2c805
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
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>)
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>)
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

0 comments on commit de2c805

Please sign in to comment.