From cc4b3f31190d0b59b778165fa2fac6bd9aa5eaf5 Mon Sep 17 00:00:00 2001 From: Anastasia Yasakova Date: Tue, 1 Jun 2021 14:08:25 +0300 Subject: [PATCH] Fix incorrect attribute import in tracks (#3229) * add fixes * remove comments * fix return value in filter_track_shapes * update changelog --- CHANGELOG.md | 1 + cvat/apps/dataset_manager/annotation.py | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecdd74176..74f6647a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Project page requests took a long time and did many DB queries () - Fixed Python 3.6 support () +- Incorrect attribute import in tracks () ### Security diff --git a/cvat/apps/dataset_manager/annotation.py b/cvat/apps/dataset_manager/annotation.py index f8e7522aa..95c127c60 100644 --- a/cvat/apps/dataset_manager/annotation.py +++ b/cvat/apps/dataset_manager/annotation.py @@ -86,9 +86,6 @@ class AnnotationIR: drop_count += 1 else: break - # Need to leave the last shape if all shapes are outside - if drop_count == len(shapes): - drop_count -= 1 return shapes[drop_count:] @@ -103,8 +100,12 @@ class AnnotationIR: if scoped_shapes: if not scoped_shapes[0]['keyframe']: segment_shapes.insert(0, scoped_shapes[0]) - if not scoped_shapes[-1]['keyframe']: + if not scoped_shapes[-1]['keyframe'] and \ + scoped_shapes[-1]['outside']: segment_shapes.append(scoped_shapes[-1]) + elif stop + 1 < len(interpolated_shapes) and \ + interpolated_shapes[stop + 1]['outside']: + segment_shapes.append(interpolated_shapes[stop + 1]) # Should delete 'interpolation_shapes' and 'keyframe' keys because # Track and TrackedShape models don't expect these fields @@ -113,7 +114,8 @@ class AnnotationIR: shape.pop('keyframe', None) track['shapes'] = segment_shapes - track['frame'] = track['shapes'][0]['frame'] + if 0 < len(segment_shapes): + track['frame'] = track['shapes'][0]['frame'] return track def slice(self, start, stop): @@ -123,8 +125,13 @@ class AnnotationIR: for t in self.tags if self._is_shape_inside(t, start, stop)] splitted_data.shapes = [deepcopy(s) for s in self.shapes if self._is_shape_inside(s, start, stop)] - splitted_data.tracks = [self._slice_track(t, start, stop) - for t in self.tracks if self._is_track_inside(t, start, stop)] + splitted_tracks = [] + for t in self.tracks: + if self._is_track_inside(t, start, stop): + track = self._slice_track(t, start, stop) + if 0 < len(track['shapes']): + splitted_tracks.append(track) + splitted_data.tracks = splitted_tracks return splitted_data -- GitLab