Skip to content

Vicomtech/openlabel-scenario-extraction

Repository files navigation

Logo

openlabel-scenario-extraction

This project runs a pipeline that:

  1. starts GraphDB (via Docker),
  2. creates the GraphDB repository if needed,
  3. imports our ontology to GraphDB,
  4. converts ASAM OpenLABEL JSON files (generated from OmegaPRIME) to RDF (Synergies.nq),
  5. detects events/actions with SPARQL (queries_Synergies.nt),
  6. optionally writes those actions/events back into ASAM OpenLABEL files.

Prerequisites

  • Docker
  • Python 3.9+

Configuration (conf.yaml)

Edit conf.yaml before running the pipeline if you need to change paths, ports, or repository names.

  • ontology: base URI, prefix, and the ontology file path.
  • vcd.vcd_path: input ASAM OpenLABELs folder (source JSON files).
  • paths.output_dir: output folder for ASAM OpenLABELs with actions/events.
  • database: GraphDB connection (ip/port/repository).
  • endpoint_url: full GraphDB SPARQL endpoint.
  • api: optional class discovery API (used in preload).
  • thresholds: numerical thresholds used for event/action detection.

Run the pipeline

From the repository root, run:

python .\run_pipeline.py

The script will:

  1. start GraphDB (Docker) if needed,
  2. create the repository if it does not exist,
  3. import the ontology,
  4. ask whether to run preload.py in multiprocessing or sequential mode,
  5. run preload.py and generate Synergies.nq,
  6. pause and ask you to import Synergies.nq manually,
  7. run queries.py and generate queries_Synergies.nt,
  8. pause and ask you to import queries_Synergies.nt manually,
  9. ask if you want to export actions/events back to OpenLABEL.

Preload mode prompt

Before running preload.py, the script asks:

  • Multiprocessing (default): faster, but can fail on low RAM.
  • Sequential: slower, but more stable.

Manual imports in GraphDB

Import Synergies.nq

When the console tells you to import Synergies.nq:

  1. Open GraphDB Workbench.
  2. Go to Import -> Server Files.
  3. Select Synergies.nq and click Import.
  4. Wait for the import to finish.

Preload import

Import queries_Synergies.nt

When the console tells you to import queries:

  1. Open Import -> Server Files again.
  2. Select only queries_Synergies.nt.
  3. Do not select Synergies.nq at this step.
  4. Click Import and wait for it to finish.

Queries import

Export actions/events back to OpenLABELs

At the end, the pipeline asks:

Do you want to export actions/events back to OpenLABELs? [y/N]

If you answer yes, it will create the output files in the folder from: conf.yaml -> paths.output_dir (default: ./output_openlabels/).

This will read the RDF in GraphDB and write the enriched OpenLABELs into paths.output_dir.

Re-run only part of the pipeline (examples)

You can skip steps if you only want to repeat a part:

  • Re-run only preload.py (skip ontology + queries):
    python .\run_pipeline.py --skip-ontology --skip-queries
  • Re-run only queries.py (skip ontology + preload):
    python .\run_pipeline.py --skip-ontology --skip-preload
  • Run without starting Docker (GraphDB already running):
    python .\run_pipeline.py --no-docker
  • Only export OpenLABELs (no pipeline, just write actions/events):
    python .\graphdb_to_vcd_parser.py

Acknowledgements

synergies.svg This package is developed as part of the SYNERGIES project and is funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or European Climate, Infrastructure and Environment Executive Agency (CINEA). Neither the European Union nor the granting authority can be held responsible for them.

funded_by_eu.svg

License

CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

About

Pipeline to extract driving scenarios from OpenLABEL files converted from OmegaPRIME using graph databases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors