From c3e24d10e44678d19bd57880bfad4a391646e2e2 Mon Sep 17 00:00:00 2001 From: Tobias Klockau Date: Wed, 4 Oct 2023 15:41:09 +0200 Subject: [PATCH] docs: delete old docs pages --- .../howtos/1 Validating Annotation Files.rst | 75 ------------------- .../howtos/2 Loading Annotation Files.rst | 25 ------- .../howtos/3 Saving Annotation Files.rst | 32 -------- docs/source/howtos/4 Filtering Scenes.rst | 50 ------------- 4 files changed, 182 deletions(-) delete mode 100644 docs/source/howtos/1 Validating Annotation Files.rst delete mode 100644 docs/source/howtos/2 Loading Annotation Files.rst delete mode 100644 docs/source/howtos/3 Saving Annotation Files.rst delete mode 100644 docs/source/howtos/4 Filtering Scenes.rst diff --git a/docs/source/howtos/1 Validating Annotation Files.rst b/docs/source/howtos/1 Validating Annotation Files.rst deleted file mode 100644 index 52d4a31..0000000 --- a/docs/source/howtos/1 Validating Annotation Files.rst +++ /dev/null @@ -1,75 +0,0 @@ -.. - Copyright DB Netz AG and contributors - SPDX-License-Identifier: Apache-2.0 - -============================= -1 Validating Annotation Files -============================= - -Some annotation files might not fit the valid schema, depending on their source and editing history. To check whether a JSON file is a valid RailLabel annotation file, the raillabel.validate() method can be used. This checks the JSON file against a given schema and returns whether the data is valid and any potential incompatibilities with the schema. - -.. code-block:: python - - import raillabel - - valid_data = { - "openlabel": { - "metadata": { - "schema_version": "1.0.0" - } - } - } - - raillabel.validate(valid_data) - -.. code-block:: python - - Returns: (True, []) - -.. code-block:: python - - import raillabel - - invalid_data = { - "openlabel": { - "metadata": { - "schema_version": "1.0.0" - }, - "invalid_field": "foo" - } - } - - raillabel.validate(invalid_data) - -.. code-block:: python - - Returns: (False, ["$.openlabel: Additional properties are not allowed ('invalid_field' was unexpected)"]) - -By default, the OpenLABEL JSON schema is used for validation. However, the method can validate data with any schema. - -.. code-block:: python - - import raillabel - - data = { - "openlabel": { - "metadata": { - "schema_version": "2.0.0" - } - } - } - - raillabel.validate(data, "path/to/schema.json") - -The method returns a tuple of two elements. The first element is a boolean marking if the data validates against the schema. The second is a list of strings with each string being an error in the data. This example shows how to present the results of the method to a user. - -.. code-block:: python - - is_data_valid, warnings = raillabel.validate(data) - - if is_data_valid: - do_something() - - else: - for w in warnings: - print(w) diff --git a/docs/source/howtos/2 Loading Annotation Files.rst b/docs/source/howtos/2 Loading Annotation Files.rst deleted file mode 100644 index 75539b4..0000000 --- a/docs/source/howtos/2 Loading Annotation Files.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. - Copyright DB Netz AG and contributors - SPDX-License-Identifier: Apache-2.0 - -========================== -2 Loading Annotation Files -========================== - -Loading annotation files into a raillabel.Scene is done with ``raillabel.load()``. - -.. code-block:: python - - import raillabel - scene = raillabel.load('path/to/file.json') - -The method can itself identify if the file is from a supported format and then choose the correct loader-class. - -Validation -========== -If the data should be validated before beeing loaded, the ``validate`` parameter can be set to True. If the data is not valid, a ``raillabel.SchemaError`` is raised with all errors included. - -.. code-block:: python - - import raillabel - scene = raillabel.load('path/to/file.json', validate=True) diff --git a/docs/source/howtos/3 Saving Annotation Files.rst b/docs/source/howtos/3 Saving Annotation Files.rst deleted file mode 100644 index e79d4ca..0000000 --- a/docs/source/howtos/3 Saving Annotation Files.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. - Copyright DB Netz AG and contributors - SPDX-License-Identifier: Apache-2.0 - -========================= -3 Saving Annotation Files -========================= - -If changes have been made to an annotation file or a file should be copied, it can be saved via the ``raillabel.save()`` method. - -.. code-block:: python - - import raillabel - - scene = raillabel.load('path/to/file.json') - scene.frames['0'].stream_stamps['lidar'].timestamp += 37 - raillabel.save(scene, 'path/to/file.json') - -By default, the JSON file is saved as compact as possible with no linebreaks or indents. This can be changed by setting ``prettify_json=True`` as an argument. The indent size used is 4 spaces. - -Validation -========== - -If the data should be validated after beeing saved, the ``validate`` parameter can be set to True. If the data is not valid, a ``raillabel.SchemaError`` is raised with all errors included and the data is not saved. - -.. code-block:: python - - import raillabel - - scene = raillabel.load('path/to/file.json') - scene.frames['0'].stream_stamps['lidar'].timestamp += 37 - raillabel.save(scene, 'path/to/file.json', validate=True) diff --git a/docs/source/howtos/4 Filtering Scenes.rst b/docs/source/howtos/4 Filtering Scenes.rst deleted file mode 100644 index 277da5c..0000000 --- a/docs/source/howtos/4 Filtering Scenes.rst +++ /dev/null @@ -1,50 +0,0 @@ -.. - Copyright DB Netz AG and contributors - SPDX-License-Identifier: Apache-2.0 - -================== -4 Filtering Scenes -================== - -The annotations of a scene can be filtered by many criteria. This functionality is provided by ``raillabel.filter()``. This method takes a scene and filter arguments and returns a copy of the scene with filters applied. - -.. code-block:: python - - import raillabel - import decimal - - scene = raillabel.load('path/to/file.json') - - scene_with_only_trains = raillabel.filter( - scene, - include_object_types=['train'] - ) - scene_without_bboxs = raillabel.filter( - scene, - exclude_annotation_types=['bbox'] - ) - cut_scene_with_only_red_trains = raillabel.filter( - scene, - start_timestamp=decimal.Decimal('1587349200.004200000'), - exclude_frames=[4, 2], - include_object_types=['train'], - include_attributes={ - 'color': 'red' - } - ) - scene_with_annotations_with_an_attribute = raillabel.filter( - scene, - include_attributes={ # All annotations with the color - 'color': None # attribute will be included, - } # regardless of color value. - ) - -Most filter categories have an include and exclude parameter (i.e ``include_object_types`` and ``exclude_object_types``). When include is set, all annotations, that meet the criterium are *included* into the filtered scene. Excluded parameters are *excluded* from the scene. These two parameters are mutually exclusive and can not both be set. - -.. code-block:: python - - invalid_scene = raillabel.filter( - scene, - include_object_types=['person'], # Will raise a ValueError due - exclude_object_types=['train'] # to mutual exclusivity. - )