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

Version 4.0 #57

Merged
merged 192 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
5b7494c
refactor: remove stats module
Oct 29, 2024
2b6f518
refactor: remove understand ai modules
Oct 29, 2024
8270c70
refactor: remove loader classes
Oct 29, 2024
bb01716
refactor: remove unused exceptions
Oct 29, 2024
4675701
refactor: load package
Oct 29, 2024
b720035
refactor: move _clean_dict() to scene
Oct 29, 2024
20c2cab
refactor: remove scene loader warnings
Oct 29, 2024
eca43db
refactor: remove scene validation
Oct 29, 2024
3b31c2c
refactor: move AttributeType
Oct 29, 2024
141e228
refactor: move raillabel format classes one layer higher
Oct 29, 2024
8d0c91c
test: move tests to reflect src tree
Oct 29, 2024
b891e13
lint: replace isort, black, pydocstyle, pylint with ruff
Oct 29, 2024
1a529cb
lint: include unit test passing in pre-commit
Oct 29, 2024
3f70924
lint: enable ruff E741 rule
Oct 29, 2024
50c9ab6
lint: enable ruff SIM110 rule
Oct 29, 2024
d56c521
lint: enable ruff ANN204 rule
Oct 29, 2024
010d572
lint: enable ruff RUF012 rule
Oct 29, 2024
b7517ef
lint: justify ruff A002 lint
Oct 29, 2024
0a7eb82
lint: justify disabling ruff D417 lint
Oct 29, 2024
3547d49
docs: update changelog
Oct 29, 2024
5eff927
refactor: remove filter functionality
Oct 29, 2024
4f60a01
refactor: remove _REQ_FIELD boilerplate and make sensor for annotatio…
Oct 29, 2024
d970097
lint: justify disabling ruff TRY003 lint
Oct 29, 2024
b807076
lint: justify disabling ruff ANN206 lint
Oct 29, 2024
8fac6db
lint: justify disabling ruff S301 lint
Oct 29, 2024
4b5b42f
lint: justify disabling ruff ANN201 lint
Oct 29, 2024
63257d2
lint: enable ruff ANN001 rule
Oct 29, 2024
0cf34f9
lint: enable ruff ARG003 rule
Oct 29, 2024
ea273c0
lint: enable ruff PERF401 rule
Oct 29, 2024
2c8a11a
lint: justify disabling ruff N802 lint
Oct 29, 2024
95020c5
lint: enable ruff PLW0602 rule
Oct 29, 2024
33a5649
lint: enable ruff A001 rule
Oct 29, 2024
b378f70
lint: enable ruff ANN202 rule
Oct 29, 2024
6f560cd
lint: enable ruff ANN003 rule
Oct 29, 2024
e78c29a
lint: justify disabling ruff INP001 lint
Oct 29, 2024
b48ff16
lint: enable ruff RET504 rule
Oct 29, 2024
27e7ac1
lint: enable ruff SIM102 rule
Oct 29, 2024
042e159
lint: enable ruff F401 rule
Oct 29, 2024
1ee8d64
lint: enable ruff EM102 rule
Oct 29, 2024
02e8698
lint: enable ruff F403 rule
Oct 29, 2024
5e6daeb
lint: enable ruff FA100 rule
Oct 29, 2024
ae1b430
lint: enable ruff TID252 rule
Oct 29, 2024
f22c709
lint: enable ruff N806 rule
Oct 29, 2024
d8a87f0
lint: enable ruff ISC003 rule
Oct 29, 2024
a9e50f2
lint: enable ruff SLF001 rule
Oct 29, 2024
62cecde
lint: enable ruff E721 rule
Oct 29, 2024
207c621
lint: enable ruff C901 rule
Oct 29, 2024
3ecfd0f
lint: add mypy type checking
Oct 29, 2024
021fa7a
chore: set up python venv in lint pipeline
Oct 29, 2024
38114c0
test: fix type annotations for python 3.8 and 3.9
Oct 29, 2024
b9becfc
test: add python 3.8 type annotation support
Oct 29, 2024
faea76b
chore: install pytest for pipelines
Oct 29, 2024
18f02f9
chore: identify pipeline issues with pytest
Oct 29, 2024
b69c5d1
chore: invoke pre-commit pytest via python
Oct 29, 2024
afda380
chore: remove pytest from pre-commit
Oct 29, 2024
35cad80
feat: add JSONTransform
Oct 30, 2024
4a0979f
feat: add JSONCoordinateSystem
Oct 30, 2024
1ef7536
feat: add JSONFrameInterval
Oct 30, 2024
cf37c17
feat: add JSONElementDataPointer
Oct 30, 2024
fb1880b
docs: add field documentation for JSON classes
Oct 30, 2024
2df4b77
feat: add JSONObject
Oct 30, 2024
ee79bca
feat: add JSONAttributes
Oct 31, 2024
6b1161e
feat: add JSON annotations
Nov 4, 2024
4f6e0e3
feat: add JSONStreamCamera
tklockau Nov 4, 2024
3b86427
feat: add JSONStreamRadar
tklockau Nov 4, 2024
183729a
feat: add JSONStreamOther
tklockau Nov 4, 2024
4e261d6
feat: add JSONStreamSync
tklockau Nov 4, 2024
5cf8d78
feat: add JSONObjectData
tklockau Nov 4, 2024
38df9a0
feat: add JSONFrame
tklockau Nov 4, 2024
274ba73
docs: fix JSONFrame docstring
tklockau Nov 4, 2024
7b73544
feat: add JSONMetadata
tklockau Nov 4, 2024
f6b6b71
feat: add JSONScene
tklockau Nov 4, 2024
8a4cb4a
feat: make json classes more accessible
tklockau Nov 4, 2024
3beca64
fix: errors in JSON format classes
tklockau Nov 4, 2024
f40ac8c
feat: Transform.from_json()
tklockau Nov 4, 2024
50ee4aa
refactor: rename Transform fields
tklockau Nov 4, 2024
3017259
feat: FrameInterval.from_json()
tklockau Nov 4, 2024
427f35e
refactor: rename FrameInterval fields
tklockau Nov 4, 2024
e385f0e
feat: IntrinsicsPinhole.from_json()
tklockau Nov 4, 2024
e877c07
docs: move IntrinsicsPinhole field docs below fields
tklockau Nov 4, 2024
1778aea
feat: IntrinsicsRadar.from_json()
tklockau Nov 4, 2024
11bf030
refactor: remove Frame.uid field
tklockau Nov 4, 2024
2f45b00
feat: Point3d.from_json()
tklockau Nov 4, 2024
cd3d7b7
feat: Quaternion.from_json()
tklockau Nov 4, 2024
ea9e925
feat: Point2d.from_json()
tklockau Nov 4, 2024
dab6451
docs: add float to Point field types
tklockau Nov 4, 2024
6ae1039
feat: Size2d.from_json()
tklockau Nov 4, 2024
fee3aff
refactor: delete everything related to fromdict and asdict
tklockau Nov 4, 2024
fb36164
refactor: extract all parent class information from Bbox
tklockau Nov 11, 2024
d751da8
feat: implement Bbox.from_json()
tklockau Nov 11, 2024
1d8431b
feat: implement Bbox.name()
tklockau Nov 11, 2024
dc9146e
feat: implement Cuboid.from_json()
tklockau Nov 11, 2024
e27755b
feat: implement Cuboid.name()
tklockau Nov 11, 2024
a2d6e24
feat: implement Poly2d.from_json()
tklockau Nov 11, 2024
94d4565
feat: implement Poly2d.name()
tklockau Nov 11, 2024
031b819
feat: implement Poly3d.from_json()
tklockau Nov 11, 2024
04f68ac
feat: implement Poly3d.name()
tklockau Nov 11, 2024
87d99f1
feat: implement Seg3d.from_json()
tklockau Nov 11, 2024
4e7b08a
feat: implement Seg3d.name()
tklockau Nov 11, 2024
06c5b77
feat: implement Num.from_dict()
tklockau Nov 11, 2024
cb5afee
feat: implement StreamReference.from_dict()
tklockau Nov 11, 2024
691304e
feat: implement Frame.from_json()
tklockau Nov 11, 2024
e7b4201
refactor: remove unused parent class
Nov 11, 2024
dd864a4
refactor: remove legacy files
Nov 11, 2024
7f3cc6d
feat: implement Object.from_json()
Nov 11, 2024
33d3f7e
feat: implement Camera.from_json()
Nov 11, 2024
995a110
refactor: remove sensor class
Nov 11, 2024
f1fd41e
feat: implement Radar.from_json()
Nov 11, 2024
f0362c9
feat: implement Lidar.from_json()
Nov 11, 2024
6885445
feat: implement GpsImu.from_json()
Nov 11, 2024
a3a9da0
feat: implement OtherSensor.from_json()
Nov 11, 2024
838b7f4
feat: implement Metadata.from_json()
Nov 12, 2024
3f51b48
feat: implement additional parameters in Metadata
Nov 12, 2024
1f4b995
fix: remove deprecated pydantic expression
Nov 12, 2024
6bccf44
feat: implement Scene.from_json() for sensors
Nov 12, 2024
c7dc145
fix: typing for python 3.8 and 3.9
Nov 13, 2024
9c8b7ab
fix: union types in python 3.8 and 3.9 with eval-type-backport
Nov 13, 2024
50b5b00
fix: dependency definition of eval-type-backport
Nov 13, 2024
0fa89ec
refactor: remove unused dependencies
Nov 13, 2024
68b463c
test: extract object uids into separate fixtures
Nov 13, 2024
f63f2ba
feat: implement Scene.from_json() for objects
Nov 13, 2024
64f00ea
feat: implement Scene.from_json() for frames
Nov 13, 2024
db19b75
feat: implement raillabel.load()
Nov 13, 2024
956d9d2
feat: implement FrameInterval.to_json()
Nov 13, 2024
b00df0c
feat: implement Point2d.to_json()
Nov 13, 2024
078d7a9
feat: implement Point3d.to_json()
Nov 13, 2024
97c4d26
feat: implement Size2d.to_json()
Nov 13, 2024
3caefff
feat: implement Size3d.to_json()
Nov 13, 2024
c9214e4
feat: implement Quaternion.to_json()
Nov 13, 2024
738aa43
feat: implement Transform.to_json()
Nov 13, 2024
04b1044
feat: implement _attributes_to_json()
Nov 13, 2024
8e48908
refactor: rename Transform fields
Nov 13, 2024
b1ebe26
feat: implement Bbox.to_json()
Nov 13, 2024
f6bd567
refactor: rename object field to object_uid in Annotation classes
Nov 13, 2024
2fd4a60
refactor: rename all *_uid fields to *_id
Nov 13, 2024
ef1fac6
docs: adapt annotation class object_id description
Nov 13, 2024
1ba0221
refactor: rename sensor field to sensor_id in Annotation classes
Nov 13, 2024
7397672
feat: implement Cuboid.to_json()
Nov 14, 2024
342f627
feat: implement Poly2d.to_json()
Nov 14, 2024
6d354b5
feat: implement Poly3d.to_json()
Nov 14, 2024
6db3bed
feat: implement Seg3d.to_json()
Nov 14, 2024
43db3fc
feat: implement Num.to_json()
Nov 14, 2024
5e6e4c7
feat: implement SensorReference.to_json()
Nov 14, 2024
d1bd3b9
fix: extra fields allowed in json format classes
Nov 14, 2024
07428e1
feat: implement Frame.to_json()
Nov 14, 2024
7d8c225
feat: implement Camera.to_json()
Nov 14, 2024
3807d93
feat: implement Radar.to_json()
Nov 14, 2024
e1c6121
feat: implement Lidar.to_json()
Nov 14, 2024
0060945
feat: implement GpsImu.to_json()
Nov 14, 2024
43d91f9
feat: implement OtherSensor.to_json()
Nov 14, 2024
69e08a8
feat: implement Object.to_json()
Nov 14, 2024
e404739
feat: implement Scene.to_json()
Nov 14, 2024
342bf96
refactor: create parent class for all json format classes
Nov 14, 2024
737a97b
feat: implement raillabel.save()
Nov 14, 2024
4d20c6d
Merge pull request #55 from DSD-DBS/loading_and_saving_redo
unexcellent Nov 14, 2024
dfed561
feat: implement SceneBuilder.empty()
Nov 15, 2024
826f864
feat: implement SceneBuilder.add_object()
Nov 15, 2024
45eef29
refactor: remove type ignore
Nov 15, 2024
ab02190
feat: implement SceneBuilder.add_sensor()
Nov 15, 2024
55554d4
feat: implement SceneBuilder.add_frame()
Nov 15, 2024
252fdb6
test: move raillabel tests one directory up
Nov 16, 2024
ff23260
test: create empty radar fixture
Nov 16, 2024
b7d3f93
feat: implement SceneBuilder.add_bbox()
Nov 16, 2024
3cec05e
feat: implement SceneBuilder.add_cuboid()
Nov 16, 2024
6207011
feat: implement SceneBuilder.add_poly2d()
Nov 16, 2024
2630778
feat: implement SceneBuilder.add_poly3d()
Nov 16, 2024
97a4065
feat: implement SceneBuilder.add_seg3d()
Nov 16, 2024
a059be4
feat: implement FrameIdFilter for include_frame_ids
Nov 16, 2024
e75f336
refactor: limit scope of FrameIdFilter to include frames
Nov 16, 2024
fa8c96c
feat: implement ExcludeFrameIdFilter
Nov 16, 2024
737e31b
feat: implement StartTimeFilter
Nov 16, 2024
82327b5
feat: implement EndTimeFilter
Nov 16, 2024
0453c81
feat: implement IncludeAnnotationIdFilter
Nov 16, 2024
2cc8bd3
feat: implement ExcludeAnnotationIdFilter
Nov 16, 2024
02db99a
feat: implement IncludeAnnotationTypeFilter
Nov 16, 2024
f41ce29
refactor: filter_
Nov 16, 2024
fd3cc1f
feat: implement ExcludeAnnotationTypeFilter
Nov 16, 2024
c565dfc
feat: implement IncludeObjectIdFilter
Nov 16, 2024
c61ba1a
feat: implement ExcludeObjectIdFilter
Nov 16, 2024
a8b5667
feat: implement IncludeObjectTypeFilter
Nov 16, 2024
ad8bb58
feat: implement ExcludeObjectTypeFilter
Nov 16, 2024
17fb336
feat: implement extra field parsing for metadata
tklockau Nov 18, 2024
a0e9989
feat: implement IncludeSensorIdFilter
tklockau Nov 18, 2024
4411337
feat: implement ExcludeSensorIdFilter
tklockau Nov 18, 2024
6e292f2
feat: implement IncludeSensorTypeFilter
tklockau Nov 18, 2024
222ffc0
feat: implement ExcludeSensorTypeFilter
tklockau Nov 18, 2024
61a5b21
feat: implement IncludeAttributesFilter
tklockau Nov 18, 2024
ed6d55d
feat: implement ExcludeAttributesFilter
tklockau Nov 18, 2024
64a3679
docs: update github docs
tklockau Nov 18, 2024
7a71a53
refactor: move filter functionality to Scene.filter()
tklockau Nov 18, 2024
5631f04
docs: update README and CHANGELOG
tklockau Nov 18, 2024
6a6fa70
chore: fix merge conflicts
tklockau Nov 18, 2024
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
28 changes: 10 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,20 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Set up virtual environment
run: |-
python -m venv .venv
source .venv/bin/activate
- name: Upgrade pip
run: |-
python -m pip install -U pip
pip install -U pip
- name: Install packages
run: |-
pip install '.[test]'
ls .venv/bin
- name: Install pre-commit
run: |-
python -m pip install pre-commit types-docutils
pip install pre-commit types-docutils
- name: Run Pre-Commit
run: |-
pre-commit run --all-files
pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Upgrade pip
run: |-
python -m pip install -U pip
- name: Install pylint
run: |-
python -m pip install pylint
- name: Run pylint
run: |-
pylint -dfixme raillabel || exit $(($? & ~24))
36 changes: 22 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,27 @@ repos:
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
- id: ruff-format
name: Run Formatter
- id: ruff
name: Run Linter
args: [ --fix ]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.12.1
hooks:
- id: pydocstyle
exclude: '^tests/'
additional_dependencies:
- pydocstyle[toml]
- id: mypy
name: Run Type Checker
types_or: [python, pyi, toml, yaml]
pass_filenames: false
args: [raillabel]
additional_dependencies:
- "pydantic<3.0.0"

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
Expand Down Expand Up @@ -83,11 +89,13 @@ repos:
- LICENSES/.license_header.txt
- --comment-style
- '..| |'

- repo: https://github.com/fsfe/reuse-tool
rev: v4.0.3
hooks:
- id: reuse

- repo: https://github.com/qoomon/git-conventional-commits
rev: v2.1.1
rev: v2.6.7
hooks:
- id: conventional-commits
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Release
- ```frame_data``` can only contain ```Num``` instances
- ```object_data``` can not contain ```Num``` instances anymore
- Major restructuring of the project directories
- ```FrameInterval.from_frame_uids()```: create ```FrameIntervals``` by providing a list of frame uids
- ```FrameInterval.from_frame_ids()```: create ```FrameIntervals``` by providing a list of frame uids
- ```Object.object_data_pointers()```: generate ```ElementDataPointers```
- ```Scene.frame_intervals()```, ```Object.frame_intervals()```: generate ```FrameIntervals```
- ```Object.asdict()``` now provides also frame intervals and object data pointers, if the frames from the scene are provided
Expand All @@ -92,3 +92,25 @@ Release

## 3.3.0
- Introduce support for Python 3.13

# 4.0.0
New Major changes to RailLabel! Over the time two major use cases for this package have crystalized. The first one are the users of the data sets published by Deutsche Bahn. The second one are the contractors providing the annotations. Since the two groups have vastly different requirements for this package, we decided to split it accordingly.

If you just want to work with out data, then you are in luck. You can just continue using this package with even more focus on your needs.

If you are building raillabel scenes yourself or want to manipulate the data in a safe way, then the [raillabel_providerkit](https://github.com/DSD-DBS/raillabel-providerkit) is for you. All functionality you may be missing in this new raillabel version will be provided over there with even better APIs.

Functionality, that has been **moved** to the `raillabel_providerkit`:
- loading annotations in formats other than raillabel itself
- validating the content of files

Other breaking changes:
- the `fromdict()` and `asdict()` methods in `raillabel.format` classes have been replaced with `from_json()` and `to_json` respectively
- `raillabel.format.FrameInterval` fields have been changed by `frame_start -> start` and `frame_end -> end` to make it more concise
- all uid fields of classes have been removed (like `raillabel.format.Frame.uid`) have been removed to avoid redundant information
- `raillabel.format.Sensor` has been removed in favor of the different sensor type classes `raillabel.format.Camera`, `raillabel.format.Lidar`, `raillabel.format.Radar` and `raillabel.format.GpsImu`
- `raillabel.filter()` has been removed in favor of `raillabel.Scene.filter()` with different input arguments

New features:
- `raillabel.json_format` has been introduced as an interface between the JSON format and the `raillabel` classes
- `raillabel.scene_builder.SceneBuilder` is now available to easily build scenes for testing purposes
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ The key differences are:
etc.
- For classes that are not builtin (e.g. `Iterable`),
`import collections.abc as cabc` and then use them like `cabc.Iterable`.
- Use [PEP-604-style unions], e.g. `int | float` instead of
- Use [PEP-604-style unions], e.g. `float` instead of
`t.Union[int, float]`.
- Use `... | None` (with `None` always as the last union member) instead of
`t.Optional[...]` and always explicitly annotate where `None` is possible.
Expand Down
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,44 @@ pip install -e '.[docs,test]'
pre-commit install
```

# Usage

The first step in using `raillabel` is downloading a desired dataset (like [OSDaR23](https://data.fid-move.de/dataset/osdar23)). You can then load any scene by running
```python
import raillabel

scene = raillabel.load("path/to/annotation_file.json")
```

This returns a [`raillabel.Scene`](https://dsd-dbs.github.io/raillabel/code/raillabel.html#raillabel.Scene), which is the root class for the annotations.

If a file is too extensive for your use-case you can filter out certain parts of a scene like this
```python
from raillabel.filter import (
IncludeObjectTypeFilter,
ExcludeAnnotationTypeFilter,
StartTimeFilter, ExcludeFrameIdFilter,
IncludeAttributesFilter
)

scene_with_only_trains = scene.filter([IncludeObjectTypeFilter(["rail_vehicle"])])

scene_without_bboxs = scene.filter([ExcludeAnnotationTypeFilter(["bbox"])])

cut_scene_with_only_red_trains = scene.filter([
StartTimeFilter("1587349200.004200000"),
ExcludeFrameIdFilter([2, 4]),
IncludeObjectTypeFilter(["rail_vehicle"]),
IncludeAttributesFilter({"color": "red"}),
])
```
An overview of all available filters can be found [here](https://dsd-dbs.github.io/raillabel/code/raillabel.filter.html#module-raillabel.filter).

If you then want to save your changes, then use
```python
raillabel.save(cut_scene_with_only_red_trains, "/path/to/target.json")
```

# Contributing

We'd love to see your bug reports and improvement suggestions! Please take a
Expand Down
4 changes: 1 addition & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@
rst_epilog = """
.. |Project| replace:: {project}
.. |Version| replace:: {version}
""".format(
project=project, version=version
)
""".format(project=project, version=version)


# -- Options for copy-button -------------------------------------------------
Expand Down
20 changes: 0 additions & 20 deletions docs/source/howto.rst

This file was deleted.

75 changes: 0 additions & 75 deletions docs/source/howtos/1 Validating Annotation Files.rst

This file was deleted.

25 changes: 0 additions & 25 deletions docs/source/howtos/2 Loading Annotation Files.rst

This file was deleted.

32 changes: 0 additions & 32 deletions docs/source/howtos/3 Saving Annotation Files.rst

This file was deleted.

Loading
Loading