Skip to content

Commit 7b85e96

Browse files
sooahleexyunchuwonjuleee
authored
Mergeback 1.9.0 to develop (#1604)
<!-- Contributing guide: https://github.com/openvinotoolkit/datumaro/blob/develop/CONTRIBUTING.md --> ### Summary <!-- Resolves #111 and #222. Depends on #1000 (for series of dependent commits). This PR introduces this capability to make the project better in this and that. - Added this feature - Removed that feature - Fixed the problem #1234 --> ### How to test <!-- Describe the testing procedure for reviewers, if changes are not fully covered by unit tests or manual testing can be complicated. --> ### Checklist <!-- Put an 'x' in all the boxes that apply --> - [ ] I have added unit tests to cover my changes.​ - [ ] I have added integration tests to cover my changes.​ - [ ] I have added the description of my changes into [CHANGELOG](https://github.com/openvinotoolkit/datumaro/blob/develop/CHANGELOG.md).​ - [ ] I have updated the [documentation](https://github.com/openvinotoolkit/datumaro/tree/develop/docs) accordingly ### License - [ ] I submit _my code changes_ under the same [MIT License](https://github.com/openvinotoolkit/datumaro/blob/develop/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern. - [ ] I have updated the license header for each file (see an example below). ```python # Copyright (C) 2024 Intel Corporation # # SPDX-License-Identifier: MIT ``` --------- Co-authored-by: Yunchu Lee <[email protected]> Co-authored-by: Wonju Lee <[email protected]>
1 parent 7dd7ad2 commit 7b85e96

File tree

12 files changed

+350
-33
lines changed

12 files changed

+350
-33
lines changed

3rd-party.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7518,5 +7518,22 @@ Apache-2.0
75187518
See the License for the specific language governing permissions and
75197519
limitations under the License.
75207520
-------------------------------------------------------------
7521+
portalocker
7522+
7523+
BSD-3-Clause
7524+
7525+
Copyright 2022 Rick van Hattem
7526+
7527+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7528+
7529+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7530+
7531+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7532+
7533+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
7534+
7535+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7536+
7537+
-------------------------------------------------------------
75217538

75227539
* Other names and brands may be claimed as the property of others.

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## \[unreleased\]
8+
## \[Q3 2024 Release 1.9.0\]
99
### New features
1010
- Add a new CLI command: datum format
1111
(<https://github.com/openvinotoolkit/datumaro/pull/1570>)
12+
- Support language dataset for DmTorchDataset
13+
(<https://github.com/openvinotoolkit/datumaro/pull/1592>)
1214

1315
### Enhancements
1416
- Change _Shape to Shape and add comments for subclasses of Shape
1517
(<https://github.com/openvinotoolkit/datumaro/pull/1568>)
18+
- Fix `kitti_raw` importer and exporter for dimensions (height, width, length) in meters
19+
(<https://github.com/openvinotoolkit/datumaro/pull/1596>)
1620

1721
### Bug fixes
22+
- Fix KITTI-3D importer and exporter
23+
(<https://github.com/openvinotoolkit/datumaro/pull/1596>)
1824

1925
## Q3 2024 Release 1.8.0
2026
### New features

docs/source/docs/release_notes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ Release Notes
44
.. toctree::
55
:maxdepth: 1
66

7+
v1.9.0 (2024 Q3)
8+
----------------
9+
10+
New features
11+
^^^^^^^^^^^^
12+
- Add a new CLI command: datum format
13+
- Support language dataset for DmTorchDataset
14+
15+
Enhancements
16+
^^^^^^^^^^^^
17+
- Change _Shape to Shape and add comments for subclasses of Shape
18+
19+
Bug fixes
20+
^^^^^^^^^
21+
- Fix KITTI-3D importer and exporter
22+
723
v1.8.0 (2024 Q3)
824
----------------
925

requirements-core.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ json-stream
6464

6565
# TabularValidator
6666
nltk
67+
68+
# torch converter for language
69+
portalocker

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def parse_requirements(filename=CORE_REQUIREMENTS_FILE):
8585
extras_require={
8686
"tf": ["tensorflow"],
8787
"tfds": ["tensorflow-datasets<4.9.3"],
88-
"torch": ["torch", "torchvision"],
88+
"torch": ["torch", "torchvision", "torchtext==0.16.0"],
8989
"default": DEFAULT_REQUIREMENTS,
9090
},
9191
ext_modules=ext_modules,

src/datumaro/plugins/data_formats/kitti_raw/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2021-2023 Intel Corporation
1+
# Copyright (C) 2021-2024 Intel Corporation
22
#
33
# SPDX-License-Identifier: MIT
44

@@ -182,7 +182,7 @@ def _parse_attr(cls, value):
182182
@classmethod
183183
def _parse_track(cls, track_id, track, categories):
184184
common_attrs = {k: cls._parse_attr(v) for k, v in track["attributes"].items()}
185-
scale = [track["scale"][k] for k in ["w", "h", "l"]]
185+
scale = [track["scale"][k] for k in ["h", "w", "l"]]
186186
label = categories[AnnotationType.label].find(track["label"])[0]
187187

188188
kf_occluded = False

src/datumaro/plugins/data_formats/kitti_raw/exporter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2021 Intel Corporation
1+
# Copyright (C) 2021-2024 Intel Corporation
22
#
33
# SPDX-License-Identifier: MIT
44

@@ -339,16 +339,16 @@ def _create_tracklets(self, subset):
339339
if not track:
340340
track = {
341341
"objectType": label,
342-
"h": ann.scale[1],
343-
"w": ann.scale[0],
342+
"h": ann.scale[0],
343+
"w": ann.scale[1],
344344
"l": ann.scale[2],
345345
"first_frame": frame_id,
346346
"poses": [],
347347
"finished": 1, # keep last
348348
}
349349
tracks[track_id] = track
350350
else:
351-
if [track["w"], track["h"], track["l"]] != ann.scale:
351+
if [track["h"], track["w"], track["l"]] != ann.scale:
352352
# Tracks have fixed scale in the format
353353
raise DatasetExportError(
354354
"Item %s: mismatching track shapes, "

src/datumaro/plugins/framework_converter.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2023 Intel Corporation
1+
# Copyright (C) 2023-2024 Intel Corporation
22
#
33
# SPDX-License-Identifier: MIT
44

@@ -17,6 +17,7 @@
1717
"detection": AnnotationType.bbox,
1818
"instance_segmentation": AnnotationType.polygon,
1919
"semantic_segmentation": AnnotationType.mask,
20+
"tabular": [AnnotationType.label, AnnotationType.caption],
2021
}
2122

2223

@@ -88,7 +89,10 @@ def _gen_item(self, idx: int):
8889
if ann.type == TASK_ANN_TYPE[self.task]
8990
]
9091
label = mask_tools.merge_masks((mask, label_id) for mask, label_id in masks)
91-
92+
elif self.task == "tabular":
93+
label = [
94+
ann.as_dict() for ann in item.annotations if ann.type in TASK_ANN_TYPE[self.task]
95+
]
9296
return image, label
9397

9498

@@ -103,15 +107,58 @@ def __init__(
103107
task: str,
104108
transform: Optional[Callable] = None,
105109
target_transform: Optional[Callable] = None,
110+
target: Optional[str] = None,
111+
tokenizer: Optional[tuple[Callable, Callable]] = None,
112+
vocab: Optional[tuple[Callable, Callable]] = None,
106113
):
107114
super().__init__(dataset=dataset, subset=subset, task=task)
108115

109116
self.transform = transform
110117
self.target_transform = target_transform
111118

119+
if self.task == "tabular":
120+
if not isinstance(target, dict):
121+
raise ValueError(
122+
"Target should be a dictionary with 'input' and 'output' keys."
123+
)
124+
self.input_target = target.get("input")
125+
self.output_target = target.get("output")
126+
if not self.input_target:
127+
raise ValueError(
128+
"Please provide target column for tabular task which is used for input"
129+
)
130+
131+
if not (tokenizer and vocab):
132+
raise ValueError("Both tokenizer and vocab must be provided for tabular task")
133+
self.tokenizer = tokenizer
134+
self.vocab = vocab
135+
112136
def __getitem__(self, idx):
113137
image, label = self._gen_item(idx)
114138

139+
if self.task == "tabular":
140+
text = image()[self.input_target]
141+
142+
if self.output_target:
143+
src_tokenizer, tgt_tokenizer = self.tokenizer
144+
src_vocab, tgt_vocab = self.vocab
145+
src_tokens = src_tokenizer(text)
146+
src_token_ids = src_vocab(src_tokens)
147+
148+
label_text = label[0]["caption"].split(f"{self.output_target}:")[-1]
149+
tgt_tokens = tgt_tokenizer(label_text)
150+
tgt_token_ids = tgt_vocab(tgt_tokens)
151+
152+
return torch.tensor(src_token_ids, dtype=torch.long), torch.tensor(
153+
tgt_token_ids, dtype=torch.long
154+
)
155+
else:
156+
tokens = self.tokenizer(text)
157+
token_ids = self.vocab(tokens)
158+
return torch.tensor(token_ids, dtype=torch.long), torch.tensor(
159+
label[0]["label"], dtype=torch.long
160+
)
161+
115162
if len(image.shape) == 2:
116163
image = np.expand_dims(image, axis=-1)
117164

src/datumaro/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.9.0rc0"
1+
__version__ = "1.9.0"

tests/integration/cli/test_kitti_raw_format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ def test_can_convert_to_kitti_raw(self):
3333
annotations=[
3434
Cuboid3d(
3535
position=[1, 2, 3],
36-
scale=[7.95, -3.62, -1.03],
36+
scale=[-3.62, 7.95, -1.03],
3737
label=1,
3838
attributes={"occluded": False, "track_id": 1},
3939
),
4040
Cuboid3d(
4141
position=[1, 1, 0],
42-
scale=[8.34, 23.01, -0.76],
42+
scale=[23.01, 8.34, -0.76],
4343
label=0,
4444
attributes={"occluded": False, "track_id": 2},
4545
),
@@ -65,7 +65,7 @@ def test_can_convert_to_kitti_raw(self):
6565
annotations=[
6666
Cuboid3d(
6767
position=[0, 1, 0],
68-
scale=[8.34, 23.01, -0.76],
68+
scale=[23.01, 8.34, -0.76],
6969
rotation=[1, 1, 3],
7070
label=0,
7171
attributes={"occluded": True, "track_id": 2},
@@ -92,7 +92,7 @@ def test_can_convert_to_kitti_raw(self):
9292
annotations=[
9393
Cuboid3d(
9494
position=[1, 2, 3],
95-
scale=[-9.41, 13.54, 0.24],
95+
scale=[13.54, -9.41, 0.24],
9696
label=1,
9797
attributes={"occluded": False, "track_id": 3},
9898
)

0 commit comments

Comments
 (0)