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

Add tfds:uc_merced and tfds:eurosat download #914

Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(<https://github.com/openvinotoolkit/datumaro/pull/897>)
- Refactor merge code
(<https://github.com/openvinotoolkit/datumaro/pull/901>, <https://github.com/openvinotoolkit/datumaro/pull/906>)
- Add tfds:uc_merced and tfds:eurosat download
(<https://github.com/openvinotoolkit/datumaro/pull/914>)

### Bug fixes
- Add UserWarning if an invalid media_type comes to image statistics computation
Expand Down
29 changes: 28 additions & 1 deletion datumaro/components/extractor_tfds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2021-2022 Intel Corporation
# Copyright (C) 2021-2023 Intel Corporation
#
# SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -313,6 +313,31 @@ def __call__(self, tfds_example: Any) -> str:
),
)

_EUROSAT_ADAPTER = _TfdsAdapter(
category_transformers=[_SetLabelCategoriesFromClassLabelFeature("label")],
data_transformers=[
_SetImageFromImageFeature("image"),
_AddLabelFromClassLabelFeature("label"),
],
id_generator=_GenerateIdFromFilenameFeature("filename"),
metadata=TfdsDatasetMetadata(
human_name="EuroSAT", default_output_format="imagenet_txt", media_type=Image
),
)


_UC_MERCED_ADAPTER = _TfdsAdapter(
category_transformers=[_SetLabelCategoriesFromClassLabelFeature("label")],
data_transformers=[
_SetImageFromImageFeature("image"),
_AddLabelFromClassLabelFeature("label"),
],
id_generator=_GenerateIdFromFilenameFeature("filename"),
metadata=TfdsDatasetMetadata(
human_name="UCMerced", default_output_format="imagenet_txt", media_type=Image
),
)


def _voc_save_pose_names(
tfds_builder: tfds.core.DatasetBuilder,
Expand Down Expand Up @@ -369,6 +394,8 @@ def _evolve_adapter_meta(adapter: _TfdsAdapter, **kwargs):
"imagenet_v2": _evolve_adapter_meta(_IMAGENET_ADAPTER, human_name="ImageNetV2"),
"mnist": _MNIST_ADAPTER,
"voc/2012": _evolve_adapter_meta(_VOC_ADAPTER, human_name="PASCAL VOC 2012"),
"eurosat": _evolve_adapter_meta(_EUROSAT_ADAPTER, human_name="EuroSAT"),
"uc_merced": _evolve_adapter_meta(_UC_MERCED_ADAPTER, human_name="UCMerced"),
}

# Assign the TFDS catalog page as the documentation URL for all datasets.
Expand Down