# opendrivelab/driveagi architecture

> Architecture diagram of the GitHub repository opendrivelab/driveagi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/opendrivelab/driveagi
- Repository: https://github.com/opendrivelab/driveagi

## Overview

##### Main Components
- Data Source & Ingestion:
– External sources such as YouTube (for “OpenDV-YouTube”) and potentially other driving data repositories.
– A “Data Acquisition” node responsible for downloading the raw driving videos.
- Configuration Management:
– A dedicated “Configuration Module” that uses JSON files (download.json, video2img.json) to parameterize downloads and conversions.
- Data Processing & Preprocessing Pipeline:
– A “Video Download Manager” module (e.g., driven by the youtube_download.py script) that handles acquiring video data.
– A “Frame Extraction Module” that converts videos into consecutive images (video2img.py, frame_extraction.py in utils) and performs meta preprocessing (via meta_preprocess.py).
– Utility libraries (found under opendv/utils such as cmd2caption.py, download.py, easydict.py) that encapsulate common functions.
- Data Storage / Dataset Preparation:
– An output or “Dataset Storage” module representing the processed images and metadata that feed into training pipelines for models like Vista or GenAD.
- Integration with Research Sub-Projects:
– Nodes or connectors representing how this data pipeline supports larger research efforts such as Vista (for future prediction), GenAD (for the OpenDV dataset), DriveLM (language based trajectory prediction), and even OpenScene or the OpenLane-V2 update.

##### Relationships & Data Flow
- Next, indicate that the video downloading process uses configuration inputs (JSON files) to guide download parameters.
– The “Video Download Manager” hands off the video to the “Frame Extraction Module” where the video is transformed (using video2img.py, frame_extraction.py).
– The “Meta Preprocessing” script further processes associated metadata.
- After preprocessing, the output connects to the “Dataset Storage”… which in turn is used by the autonomous driving research components.
- Optionally, if there are extension points (e.g., language annotation via cmd2caption.py), represent these as additional processing nodes.

##### Architectural Patterns & Technologies
- Modular Design: Separate scripts and utilities encapsulate specific tasks (e.g., downloading, frame extraction, metadata preprocessing).
- Pipeline/Workflow: Emphasize the sequential nature of video acquisition → processing → dataset generation.
- Config-Driven: Represent the use of configuration files to allow flexible changes in parameters.
- Technology Stack: Although the project is implemented in Python (as deduced from the file types and scripts), annotate where needed to indicate libraries, standard utilities, and external dependencies (for example, YouTube API interactions).

##### Final Overview
– Begin with external driving video sources (YouTube, other repositories).
– Next, show the download manager that uses configuration files.
– Then, branch out into parallel or sequential processing modules (frame extraction, meta preprocessing, utility processing).
– Conclude with the storage of processed images and metadata that feed into the larger DriveAGI research components (represented by nodes for Vista, GenAD, DriveLM, OpenScene, OpenLane-V2).
– Optional: Include integration points/placeholders for potential API endpoints or data-sharing interfaces if the processed output is later consumed by training frameworks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Sources
    subgraph "External Sources"
        YT["YouTube"]:::external
        Repo["Driving Data Repos"]:::external
    end

    %% Configuration Files
    subgraph "Configuration Files"
        Config1["download.json"]:::config
        Config2["video2img.json"]:::config
    end

    %% Data Processing Pipeline
    DataAcq["Video Download Manager"]:::process
    FEScript["Frame Extraction: video2img.py"]:::process
    FEUtil["Frame Extraction: frame_extraction.py"]:::process
    MetaPre["Meta Preprocessing Module"]:::process
    Storage["Dataset Storage"]:::storage

    %% Utility Functions
    subgraph "Utility Functions"
        UtilityCmd["Utility: cmd2caption.py"]:::utility
        UtilityDownload["Utility: download.py"]:::utility
        UtilityEasy["Utility: easydict.py"]:::utility
    end

    %% Research Modules
    subgraph "Research Modules"
        Vista["Vista"]:::research
        GenAD["GenAD"]:::research
        DriveLM["DriveLM"]:::research
        OpenScene["OpenScene"]:::research
        OpenLane["OpenLane-V2"]:::research
    end

    %% Data Flow
    YT -->|"source"| DataAcq
    Repo -->|"source"| DataAcq
    Config1 -.->|"config"| DataAcq
    Config2 -.->|"config"| DataAcq
    DataAcq -->|"video download"| FEScript
    FEScript -->|"processing"| FEUtil
    FEUtil -->|"frame sequence"| MetaPre
    MetaPre -->|"data output"| Storage
    Storage -->|"feeds"| Vista
    Storage -->|"feeds"| GenAD
    Storage -->|"feeds"| DriveLM
    Storage -->|"feeds"| OpenScene
    Storage -->|"feeds"| OpenLane

    %% Utility Integration (dashed lines)
    FEScript ---|"uses"| UtilityCmd
    FEScript ---|"uses"| UtilityDownload
    FEScript ---|"uses"| UtilityEasy
    MetaPre ---|"uses"| UtilityCmd
    MetaPre ---|"uses"| UtilityDownload
    MetaPre ---|"uses"| UtilityEasy

    %% Click Events
    click DataAcq "https://github.com/opendrivelab/driveagi/blob/main/opendv/scripts/youtube_download.py"
    click Config1 "https://github.com/opendrivelab/driveagi/blob/main/opendv/configs/download.json"
    click Config2 "https://github.com/opendrivelab/driveagi/blob/main/opendv/configs/video2img.json"
    click FEScript "https://github.com/opendrivelab/driveagi/blob/main/opendv/scripts/video2img.py"
    click FEUtil "https://github.com/opendrivelab/driveagi/blob/main/opendv/utils/frame_extraction.py"
    click MetaPre "https://github.com/opendrivelab/driveagi/blob/main/opendv/scripts/meta_preprocess.py"
    click UtilityCmd "https://github.com/opendrivelab/driveagi/blob/main/opendv/utils/cmd2caption.py"
    click UtilityDownload "https://github.com/opendrivelab/driveagi/blob/main/opendv/utils/download.py"
    click UtilityEasy "https://github.com/opendrivelab/driveagi/blob/main/opendv/utils/easydict.py"

    %% Styles
    classDef external fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef process fill:#FFDAB9,stroke:#000,stroke-width:1px;
    classDef config fill:#FFE4E1,stroke:#000,stroke-width:1px,stroke-dasharray: 5,5;
    classDef storage fill:#E6FFE6,stroke:#000,stroke-width:1px;
    classDef research fill:#E6E6FF,stroke:#000,stroke-width:1px;
    classDef utility fill:#F0E68C,stroke:#000,stroke-width:1px;
```
