Fix frame step export for image tasks (#1615)

* use absolute frame numbers in interface

* update changelog

Co-authored-by: Nikita Manovich <40690625+nmanovic@users.noreply.github.com>
main
zhiltsov-max 6 years ago committed by GitHub
parent 2c70e8a401
commit 1fb7e5bf6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-
### Fixed
- Problem with exported frame stepped image task (<https://github.com/opencv/cvat/issues/1613>)
- Fixed dataset filter item representation for imageless dataset items (<https://github.com/opencv/cvat/pull/1593>)
- Fixed interpreter crash when trying to import `tensorflow` with no AVX instructions available (<https://github.com/opencv/cvat/pull/1567>)
- Kibana wrong working time calculation with new annotation UI use (<https://github.com/opencv/cvat/pull/1654>)
@ -85,6 +86,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A problem with mask to polygons conversion when polygons are too small (<https://github.com/opencv/cvat/pull/1581>)
- Unable to upload video with uneven size (<https://github.com/opencv/cvat/pull/1594>)
- Fixed an issue with `z_order` having no effect on segmentations (<https://github.com/opencv/cvat/pull/1589>)
### Security
- Permission group whitelist check for analytics view (<https://github.com/opencv/cvat/pull/1608>)
## [1.0.0-beta.2] - 2020-04-30

@ -97,16 +97,21 @@ class TaskData:
def _get_immutable_attribute_id(self, label_id, attribute_name):
return self._get_attribute_id(label_id, attribute_name, 'immutable')
def abs_frame_id(self, relative_id):
return relative_id * self._frame_step + self._db_task.data.start_frame
def rel_frame_id(self, absolute_id):
return (absolute_id - self._db_task.data.start_frame) // self._frame_step
def _init_frame_info(self):
if hasattr(self._db_task.data, 'video'):
self._frame_info = {frame: {
"path": "frame_{:06d}".format(
self._db_task.data.start_frame + frame * self._frame_step),
"path": "frame_{:06d}".format(self.abs_frame_id(frame)),
"width": self._db_task.data.video.width,
"height": self._db_task.data.video.height,
} for frame in range(self._db_task.data.size)}
else:
self._frame_info = {db_image.frame: {
self._frame_info = {self.rel_frame_id(db_image.frame): {
"path": db_image.path,
"width": db_image.width,
"height": db_image.height,
@ -193,8 +198,7 @@ class TaskData:
def _export_tracked_shape(self, shape):
return TaskData.TrackedShape(
type=shape["type"],
frame=self._db_task.data.start_frame +
shape["frame"] * self._frame_step,
frame=self.abs_frame_id(shape["frame"]),
label=self._get_label_name(shape["label_id"]),
points=shape["points"],
occluded=shape["occluded"],
@ -210,8 +214,7 @@ class TaskData:
return TaskData.LabeledShape(
type=shape["type"],
label=self._get_label_name(shape["label_id"]),
frame=self._db_task.data.start_frame +
shape["frame"] * self._frame_step,
frame=self.abs_frame_id(shape["frame"]),
points=shape["points"],
occluded=shape["occluded"],
z_order=shape.get("z_order", 0),
@ -221,8 +224,7 @@ class TaskData:
def _export_tag(self, tag):
return TaskData.Tag(
frame=self._db_task.data.start_frame +
tag["frame"] * self._frame_step,
frame=self.abs_frame_id(tag["frame"]),
label=self._get_label_name(tag["label_id"]),
group=tag.get("group", 0),
attributes=self._export_attributes(tag["attributes"]),
@ -232,7 +234,7 @@ class TaskData:
frames = {}
def get_frame(idx):
frame_info = self._frame_info[idx]
frame = self._db_task.data.start_frame + idx * self._frame_step
frame = self.abs_frame_id(idx)
if frame not in frames:
frames[frame] = TaskData.Frame(
idx=idx,
@ -299,8 +301,7 @@ class TaskData:
def _import_tag(self, tag):
_tag = tag._asdict()
label_id = self._get_label_id(_tag.pop('label'))
_tag['frame'] = (int(_tag['frame']) -
self._db_task.data.start_frame) // self._frame_step
_tag['frame'] = self.rel_frame_id(int(_tag['frame']))
_tag['label_id'] = label_id
_tag['attributes'] = [self._import_attribute(label_id, attrib)
for attrib in _tag['attributes']
@ -316,8 +317,7 @@ class TaskData:
def _import_shape(self, shape):
_shape = shape._asdict()
label_id = self._get_label_id(_shape.pop('label'))
_shape['frame'] = (int(_shape['frame']) -
self._db_task.data.start_frame) // self._frame_step
_shape['frame'] = self.rel_frame_id(int(_shape['frame']))
_shape['label_id'] = label_id
_shape['attributes'] = [self._import_attribute(label_id, attrib)
for attrib in _shape['attributes']
@ -327,14 +327,13 @@ class TaskData:
def _import_track(self, track):
_track = track._asdict()
label_id = self._get_label_id(_track.pop('label'))
_track['frame'] = (min(int(shape.frame) for shape in _track['shapes']) -
self._db_task.data.start_frame) // self._frame_step
_track['frame'] = self.rel_frame_id(
min(int(shape.frame) for shape in _track['shapes']))
_track['label_id'] = label_id
_track['attributes'] = []
_track['shapes'] = [shape._asdict() for shape in _track['shapes']]
for shape in _track['shapes']:
shape['frame'] = (int(shape['frame']) - \
self._db_task.data.start_frame) // self._frame_step
shape['frame'] = self.rel_frame_id(int(shape['frame']))
_track['attributes'] = [self._import_attribute(label_id, attrib)
for attrib in shape['attributes']
if self._get_immutable_attribute_id(label_id, attrib.name)]
@ -567,7 +566,7 @@ def import_dm_annotations(dm_dataset, task_data):
label_cat = dm_dataset.categories()[datumaro.AnnotationType.label]
for item in dm_dataset:
frame_number = match_frame(item, task_data)
frame_number = task_data.abs_frame_id(match_frame(item, task_data))
# do not store one-item groups
group_map = {0: 0}

@ -40,7 +40,7 @@ def _import(src_file, task_data):
for item in dataset:
item = item.wrap(id=int(item.id) - 1) # NOTE: MOT frames start from 1
frame_id = match_frame(item, task_data)
frame_number = task_data.abs_frame_id(match_frame(item, task_data))
for ann in item.annotations:
if ann.type != datumaro.AnnotationType.bbox:
@ -57,7 +57,7 @@ def _import(src_file, task_data):
outside=False,
keyframe=False,
z_order=ann.z_order,
frame=frame_id,
frame=frame_number,
attributes=[],
)

Loading…
Cancel
Save