Skip to content

Commit

Permalink
feat: datumaro 1.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Inhyuk Andy Cho <andy.inhyuk.jo@intel.com>
  • Loading branch information
cih9088 committed Apr 18, 2023
1 parent bbbeb4e commit 862f086
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def _convert_anns(item: DatasetItemEntityWithID):
dm.DatasetItem(
id=item.id_,
subset="train",
media=dm.Image(path=item.media.path, size=(item.media.height, item.media.width)),
media=dm.Image.from_file(path=item.media.path, size=(item.media.height, item.media.width))
if item.media.path
else dm.Image.from_numpy(
data=getattr(item.media, "_Image__data"), size=(item.media.height, item.media.width)
),
annotations=_convert_anns(item),
)
for item in otx_dataset
Expand Down
2 changes: 2 additions & 0 deletions otx/core/data/caching/storage_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import List, Optional

from datumaro.components.dataset import Dataset as DatumDataset
from datumaro.components.progress_reporting import SimpleProgressReporter

from otx.core.file import OTX_CACHE

Expand Down Expand Up @@ -85,6 +86,7 @@ def get_file_hash(file):
save_media=True,
image_ext=scheme,
num_workers=num_workers,
progress_reporter=SimpleProgressReporter(0, 10),
)

cache_paths = []
Expand Down
8 changes: 5 additions & 3 deletions otx/core/data/manager/dataset_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# pylint: disable=invalid-name
import os
from typing import List, Tuple, Union
from typing import List, Optional, Tuple, Union

import datumaro
from datumaro.components.dataset import Dataset, DatasetSubset
Expand Down Expand Up @@ -73,9 +73,11 @@ def get_data_format(data_root: str) -> str:
return data_format

@staticmethod
def get_image_path(data_item: DatasetItem) -> str:
def get_image_path(data_item: DatasetItem) -> Optional[str]:
"""Returns the path of image."""
return data_item.media.path
if hasattr(data_item.media, "path"):
return data_item.media.path
return None

@staticmethod
def export_dataset(dataset: Dataset, output_dir: str, data_format: str, save_media=True):
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ natsort>=6.0.0
prettytable
protobuf>=3.20.0
pyyaml
datumaro==1.0.0rc1
datumaro==1.2.0rc3
psutil
scipy>=1.8
bayesian-optimization>=1.2.0
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/core/data/manager/test_dataset_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_get_image_path(self, task, subset):
random_data = DatasetManager.get_image_path(
generate_datumaro_dataset_item(item_id="0", subset=subset, task=task)
)
assert random_data is not None
assert random_data is None

@e2e_pytest_unit
@pytest.mark.parametrize("task", AVAILABLE_TASKS)
Expand Down

0 comments on commit 862f086

Please sign in to comment.