Skip to content

Commit

Permalink
Merge pull request #25 from DSD-DBS/uai_loading_fix
Browse files Browse the repository at this point in the history
Uai loading fix
  • Loading branch information
tklockau authored Jul 24, 2023
2 parents 7d22280 + 6dc2997 commit ca6bf26
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ Release
- Raillabel schema is now more restrictive regarding intrinsic calibration
- Support for understand.ai t4 format
- Renaming of raillabel.format.Frame.data to frame_data

### 2.2.1
- Fixed bug, that prevented loading a understand ai file via raillabel.load()
- Made the project_id field in the understand ai files less restrictive
3 changes: 3 additions & 0 deletions raillabel/format_loaders/loader_raillabel_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def supports(self, data: dict) -> bool:
If True, the Loader class is suitable for the data.
"""

if "openlabel" not in data or "metadata" not in data["openlabel"]:
return False

if "subschema_version" in data["openlabel"]["metadata"]:
return (
"openlabel" in data
Expand Down
3 changes: 2 additions & 1 deletion raillabel/format_loaders/loader_understand_ai_t4.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def load(self, data: dict, validate: bool = True) -> uai_format.Scene:
The loaded scene with the data.
"""

self.warnings = []

if validate:
self.validate(data)

Expand All @@ -69,7 +71,6 @@ def supports(self, data: dict) -> bool:
return (
"metadata" in data
and "project_id" in data["metadata"]
and data["metadata"]["project_id"] == "trains_4"
and "coordinateSystems" in data
and "frames" in data
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_supports_true(json_data, loader):

def test_supports_false(json_data, loader):
data = json_data["understand_ai_real_life"]
data["metadata"]["project_id"] = "invalid"
del data["metadata"]["project_id"]
assert not loader.supports(data)


Expand Down
30 changes: 30 additions & 0 deletions tests/test_raillabel/test_load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright DB Netz AG and contributors
# SPDX-License-Identifier: Apache-2.0

import os
import sys
from pathlib import Path

import pytest

sys.path.insert(1, str(Path(__file__).parent.parent.parent))

import raillabel


def test_load_raillabel(json_paths):
data_path = json_paths["openlabel_v1_short"]
scene = raillabel.load(data_path)
assert len(scene.frames) != 0


def test_load_uai(json_paths):
data_path = json_paths["understand_ai_t4_short"]
scene = raillabel.load(data_path)
assert len(scene.frames) != 0


# Executes the test if the file is called
if __name__ == "__main__":
os.system("clear")
pytest.main([__file__, "--disable-pytest-warnings", "--cache-clear"])

0 comments on commit ca6bf26

Please sign in to comment.