fix incorrect solution

main
kirill.sizov 5 years ago
parent d7be0429fd
commit cbcb62048a

@ -14,7 +14,6 @@ from cvat.apps.engine.frame_provider import FrameProvider
from cvat.apps.engine.models import AttributeType, ShapeType from cvat.apps.engine.models import AttributeType, ShapeType
from datumaro.util import cast from datumaro.util import cast
from datumaro.util.image import ByteImage, Image from datumaro.util.image import ByteImage, Image
from datumaro.components.extractor import DatasetItem
from .annotation import AnnotationManager, TrackManager from .annotation import AnnotationManager, TrackManager
@ -436,8 +435,9 @@ class TaskData:
def _get_filename(path): def _get_filename(path):
return osp.splitext(path)[0] return osp.splitext(path)[0]
def match_frame(self, path, root_hint=None): def match_frame(self, path, root_hint=None, path_has_ext=True):
path = self._get_filename(path) if path_has_ext:
path = self._get_filename(path)
match = self._frame_mapping.get(path) match = self._frame_mapping.get(path)
if not match and root_hint and not path.startswith(root_hint): if not match and root_hint and not path.startswith(root_hint):
path = osp.join(root_hint, path) path = osp.join(root_hint, path)
@ -612,7 +612,7 @@ def match_dm_item(item, task_data, root_hint=None):
if frame_number is None and item.has_image: if frame_number is None and item.has_image:
frame_number = task_data.match_frame(item.id + item.image.ext, root_hint) frame_number = task_data.match_frame(item.id + item.image.ext, root_hint)
if frame_number is None: if frame_number is None:
frame_number = task_data.match_frame(item.id, root_hint) frame_number = task_data.match_frame(item.id, root_hint, path_has_ext=False)
if frame_number is None: if frame_number is None:
frame_number = cast(item.attributes.get('frame', item.id), int) frame_number = cast(item.attributes.get('frame', item.id), int)
if frame_number is None and is_video: if frame_number is None and is_video:
@ -652,7 +652,7 @@ def import_dm_annotations(dm_dataset, task_data):
for item in dm_dataset: for item in dm_dataset:
frame_number = task_data.abs_frame_id( frame_number = task_data.abs_frame_id(
match_dm_item(DatasetItem(id=item.id + '.'), task_data, root_hint=root_hint)) match_dm_item(item, task_data, root_hint=root_hint))
# do not store one-item groups # do not store one-item groups
group_map = {0: 0} group_map = {0: 0}

@ -441,7 +441,7 @@ def load(file_object, annotations):
elif el.tag == 'image': elif el.tag == 'image':
image_is_opened = True image_is_opened = True
frame_id = annotations.abs_frame_id(match_dm_item( frame_id = annotations.abs_frame_id(match_dm_item(
DatasetItem(id=el.attrib['name'], DatasetItem(id=osp.splitext(el.attrib['name'])[0],
attributes={'frame': el.attrib['id']} attributes={'frame': el.attrib['id']}
), ),
task_data=annotations task_data=annotations

@ -5,7 +5,7 @@
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from datumaro.components.dataset import Dataset from datumaro.components.dataset import Dataset
from datumaro.components.extractor import AnnotationType, Transform, DatasetItem from datumaro.components.extractor import AnnotationType, Transform
from pyunpack import Archive from pyunpack import Archive
from cvat.apps.dataset_manager.bindings import (CvatTaskDataExtractor, from cvat.apps.dataset_manager.bindings import (CvatTaskDataExtractor,
@ -48,7 +48,7 @@ def _import(src_file, task_data):
for item in dataset: for item in dataset:
frame_number = task_data.abs_frame_id( frame_number = task_data.abs_frame_id(
match_dm_item(DatasetItem(id=item.id + '.'), task_data, root_hint=root_hint)) match_dm_item(item, task_data, root_hint=root_hint))
for ann in item.annotations: for ann in item.annotations:
if ann.type != AnnotationType.polygon: if ann.type != AnnotationType.polygon:

@ -40,7 +40,7 @@ def _import(src_file, task_data):
for frame in frames: for frame in frames:
frame_info = None frame_info = None
try: try:
frame_id = match_dm_item(DatasetItem(id=frame + '.'), task_data, frame_id = match_dm_item(DatasetItem(id=frame), task_data,
root_hint=root_hint) root_hint=root_hint)
frame_info = task_data.frame_info[frame_id] frame_info = task_data.frame_info[frame_id]
except Exception: # nosec except Exception: # nosec

Loading…
Cancel
Save