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

[Datumaro] Allow recursive search in importers #1290

Merged
merged 1 commit into from
Mar 20, 2020
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
9 changes: 3 additions & 6 deletions datumaro/datumaro/plugins/coco_format/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from datumaro.components.extractor import Importer
from datumaro.util.log_utils import logging_disabled

from .format import CocoTask, CocoPath
from .format import CocoTask


class CocoImporter(Importer):
Expand Down Expand Up @@ -55,11 +55,8 @@ def find_subsets(path):
if path.endswith('.json') and osp.isfile(path):
subset_paths = [path]
else:
subset_paths = glob(osp.join(path, '*_*.json'))

if osp.basename(osp.normpath(path)) != CocoPath.ANNOTATIONS_DIR:
path = osp.join(path, CocoPath.ANNOTATIONS_DIR)
subset_paths += glob(osp.join(path, '*_*.json'))
subset_paths = glob(osp.join(path, '**', '*_*.json'),
recursive=True)

subsets = defaultdict(dict)
for subset_path in subset_paths:
Expand Down
8 changes: 1 addition & 7 deletions datumaro/datumaro/plugins/cvat_format/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

from datumaro.components.extractor import Importer

from .format import CvatPath


class CvatImporter(Importer):
EXTRACTOR_NAME = 'cvat'
Expand Down Expand Up @@ -49,9 +47,5 @@ def find_subsets(path):
if path.endswith('.xml') and osp.isfile(path):
subset_paths = [path]
else:
subset_paths = glob(osp.join(path, '*.xml'))

if osp.basename(osp.normpath(path)) != CvatPath.ANNOTATIONS_DIR:
path = osp.join(path, CvatPath.ANNOTATIONS_DIR)
subset_paths += glob(osp.join(path, '*.xml'))
subset_paths = glob(osp.join(path, '**', '*.xml'), recursive=True)
return subset_paths
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ def find_subsets(path):
if path.endswith('.tfrecord') and osp.isfile(path):
subset_paths = [path]
else:
subset_paths = glob(osp.join(path, '*.tfrecord'))
subset_paths = glob(osp.join(path, '**', '*.tfrecord'),
recursive=True)
return subset_paths
2 changes: 1 addition & 1 deletion datumaro/datumaro/plugins/yolo_format/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ def find_configs(path):
if path.endswith('.data') and osp.isfile(path):
config_paths = [path]
else:
config_paths = glob(osp.join(path, '*.data'))
config_paths = glob(osp.join(path, '**', '*.data'), recursive=True)
return config_paths