Skip to content

About

DriveForge — a 3DGS-powered synthetic data engine for autonomous driving. Reconstruct real driving scenes with DriveStudio/OmniRe, insert traffic-sign Gaussian assets in a web editor, render trajectory-conditioned multi-camera sequences with depth/masks/2D-3D annotations, and relight them with Cosmos-Transfer2.5.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

DriveForge

A 3DGS-powered synthetic-data engine for autonomous driving.

Insert traffic signs into reconstructed driving scenes and render RGB, depth, instance masks and 2D/3D annotations — without retraining the background.

License: Apache-2.0 Python Frontend

DriveForge editor

Table of contents

Features

  • Immutable scenes: reconstructed backgrounds (DriveStudio / OmniRe) are never modified; signs are separate Gaussian layers referenced by a versioned scene graph.
  • Web editor: inspect the ground point cloud and ego trajectory, click to place signs that snap to the ground plane, edit with a transform gizmo, undo/redo.
  • Asset pipeline: create signs from a 2D image (auto-crop, shape detection) → textured mesh → cached Gaussian asset.
  • Renderer: unified Gaussian composer with background, dynamic actors and signs; GPU (gsplat) and NumPy CPU reference backends.
  • Ground truth: RGB, depth, instance masks, 2D/3D boxes and reproducibility manifest per frame.
  • Relighting / harmonization: classical GPU-batched harmonization and an optional Cosmos-Transfer2.5 video-diffusion stage.

Screenshots

Scene editing: ground point cloud, ego trajectory, placed signs, gizmo Synthesize dialog
Editor Synthesize
Create a sign asset from a 2D image
New sign

Rendered outputs (left to right: RGB with inserted signs, depth, instance mask):

Render outputs

Architecture

flowchart LR
    subgraph IN[Inputs]
        LOG[Driving logs + calibration<br/>NuPlan]
        IMG[Sign images / templates]
    end
    subgraph CORE[Python packages]
        REC[packages.reconstruction<br/>DriveStudio adapter, ground extractor,<br/>trajectory / scene exporter]
        AST[packages.assets<br/>mesh generator, mesh to Gaussian,<br/>asset library + cache]
        SG[packages.scene<br/>scene graph, ground alignment]
        RND[packages.rendering<br/>Gaussian composer, trajectory renderer,<br/>annotation + output writer]
        REL[packages.relighting<br/>classical / Cosmos-Transfer2.5]
    end
    subgraph APP[Applications]
        API[apps.api - FastAPI<br/>scenes, assets, jobs]
        UI[apps.editor - React + Three.js<br/>3D scene editor]
    end
    DATA[(data/<br/>scenes, assets, outputs,<br/>jobs, checkpoints)]
    DS[[third_party/drivestudio]]
    LOG --> REC --> DATA
    IMG --> AST --> DATA
    DS -.-> REC
    DS -.-> RND
    UI <-->|REST /api| API
    API --> SG
    API --> RND
    API --> REL
    SG --> RND
    DATA --> RND --> OUT[RGB / depth / masks /<br/>2D+3D annotations / manifest]
    OUT --> REL --> VID[Harmonized / relit video]
Loading

The browser is a scene-authoring tool (point clouds + meshes for responsive interaction); the Python backend is the reference renderer for final data. The editor only talks to the REST API, which orchestrates background jobs (one at a time) over the file-based data/ store.

Typical data flow: reconstruct → create assets → place signs (editor, saved as scene.json) → synthesize (render job) → harmonize / relight (video). Full design: PRD.md (end-to-end diagram, coordinate contracts) and docs/relighting_design.md.

Quick start

Requirements: Python ≥ 3.10, Node.js ≥ 18 (editor), optional CUDA GPU (CPU fallback is available), ffmpeg via imageio-ffmpeg.

git clone --recurse-submodules <repo-url> DriveForge && cd DriveForge
# or, if already cloned (third_party/drivestudio tracks public upstream main; NuPlan
# adaptations come from patches/drivestudio/, applied by scripts/nuplan/apply_drivestudio_patches.sh):
git -c protocol.file.allow=always submodule update --init

pip install -e . pytest imageio-ffmpeg      # numpy, scipy, pillow, pydantic, fastapi, httpx, opencv, torch (CPU ok)
export DRIVESTUDIO_DATA_ROOT=<drivestudio>/data/nuplan/processed/mini   # optional; defaults to submodule or ../drivestudio

The repo ships 7 published demo scenes (data/scenes/ with checkpoints and sign assets), so the editor works out of the box. To reconstruct your own scene, the source data is the processed NuPlan scene from DriveStudio's run_demo.md.

./launch_app.sh                                            # one-click: API (:8000) + editor (:5173)
python scripts/reconstruct_scene.py --source nuplan      # or --source synthetic  -> data/scenes/<id>
python scripts/create_sign_asset.py my_sign --template circular --label 60
python scripts/render_scene.py data/scenes/<id> scene.json out/ --width 320
python scripts/validate_output.py out/

See tutorial.md for a step-by-step walkthrough.

Data layout

All data lives under data/ (override the root with DRIVEFORGE_DATA):

dir content
data/scenes/<scene_id>/ 3DGS reconstruction results (exported background, trajectory, calibration, scene.json)
data/outputs/<scene_id>/<name>_<hash8>/ 3DGS synthesis output: rgb/, depth/, instance_masks/, annotations/, videos/<cam>_relit.mp4, manifest.json
data/assets/, data/asset_cache/ sign assets and their built meshes / Gaussians
data/jobs/ render / synthesis job records
data/checkpoints/<release>/<scene_id>/ permanent published checkpoints, config.yaml, training_provenance.json
data/runtime/python/ optional persisted Python packages for the matching Python/OS runtime; prefer a reproducible Docker image

<hash8> is the hash of the scene content, so re-rendering an unchanged scene overwrites the same output dir.

Permanent assets and temporary experiments

data/ is the authoritative persistent store. nvme_tmp/driveforge_runs/<experiment>/ is disposable training/evaluation scratch space: it may disappear after a reboot. Never publish a scene whose runtime checkpoint is only on NVMe.

After accepting an experiment, export its scenes, then archive their checkpoints:

python -m scripts.nuplan.archive_app_assets --data data
python -m scripts.nuplan.archive_app_assets --data data --verify-only

The current archive command publishes into checkpoints/g8/, checks checkpoint SHA256, copies configuration/provenance, and updates all three scene references. It is safe to rerun on an already archived scene; it refuses a conflicting checkpoint instead of overwriting it. Paths in dynamics.json, reconstruction/drivestudio_checkpoint.json, and the manifest's checkpoint/config fields are relative to the scene root, not the JSON file or shell working directory. Moving the whole data/ tree preserves these references. Historical source/provenance paths and training log_dir are audit records, not runtime inputs; do not resume training into the archive.

launch_app.sh verifies scene file hashes and checkpoint references/hashes before starting services. This reads large files from persistent storage and can increase startup latency. It also adds <DRIVEFORGE_DATA>/runtime/python to PYTHONPATH when present. Keep Python/PyTorch/CUDA, Node and the runtime image available after reboot; persisted packages do not replace a compatible interpreter or a healthy GPU driver. NVMe caches must always be reconstructible from permanent assets; no automatic NVMe cache is currently implemented. See harness.md for experiment and release rules.

Web editor

./launch_app.sh [start|stop|restart|status]    # default: restart; logs in /tmp/driveforge_{api,web}.log
# env: API_PORT=8000 WEB_PORT=5173 HOST=0.0.0.0 PYTHON=<python> LOG_DIR=/tmp

Open http://<host>:5173 (Vite proxies /api to the backend). Manual start: uvicorn apps.api.main:app_factory --factory --port 8000 and cd apps/editor && npm install && npm run dev.

Workflow:

  1. Pick a scene in the top bar. The ego trajectory is drawn as red pose arrows.
  2. Assets panel → select a sign → click the ground. Signs snap to the estimated ground plane, stand upright (z along the ground normal) and face the camera. Edit in Properties (gizmo W/E/R, Delete, Ctrl+D, Ctrl+Z/Ctrl+Y, Ctrl+S). The Instances list has × per instance and Clear all (one undo step).
  3. Synthesize: renders the 3DGS frames (background + dynamic actors + signs, RGB / depth / masks / annotations) to data/outputs/<scene>/render_<hash8>/. The dialog closes automatically at 100 %.
  4. Generate Video: harmonizes the signs with the background (classical, GPU-batched with CPU fallback, about 20 s for 300 frames) and writes only videos/<cam>_relit.mp4.
  5. The bottom-left player shows the newest video of the scene from disk (survives page reloads; job state is restored from localStorage). Clear deletes the scene's generated videos (frames are kept).

API: POST /api/render-jobs, POST /api/synthesis-jobs (render_job_id, harmonize, default true), GET /api/jobs/{id}, GET|DELETE /api/scenes/{id}/videos, GET /api/scenes/{id}/outputs/{name}/videos/{camera}, GET /api/scenes/{id}/trajectory. Jobs run one at a time.

Tests

pytest tests/unit tests/integration        # integration uses the demo scene (skips if absent)
pytest -m smoke                            # video-verified smoke tests -> artifacts/smoke/*.mp4 (decoded back and checked)

Smoke videos: trajectory, ground point cloud, asset turntable/distance, composition, transform updates, occlusion, multi-sign, annotation overlay, depth/instance masks, camera pan, render-sequence output, API preview, demo-data sign insertion.

Backends

ReferenceCpuRasterizer (default, no GPU) and DriveStudioRasterizer (gsplat; needs CUDA + a DriveStudio environment). Select via packages.rendering.drivestudio_renderer.load_renderer.

GPU rendering with a trained DriveStudio checkpoint

python scripts/reconstruct_scene.py --source checkpoint --checkpoint <work_dir> --data-root <processed_scene_root>
python scripts/render_scene.py <scene_dir> <scene.json> <out_dir> --frame-end 300 --width 960 --backend drivestudio

The scene gets a dynamics.json, so vehicles/pedestrians from the checkpoint are rendered per frame (--no-dynamics at reconstruction time keeps only the static background). render_scene.py shows a progress bar. python scripts/ablate_background.py --checkpoint <work_dir> scores background-only renders against real images. Approximations: deformable MLP skipped, DC-only color, flat sky, no Affine color correction.

Relighting + defect repair (Cosmos-Transfer2.5)

Post-process a render dir into rgb_relit/<cam>/, videos/<cam>_relit.mp4 and a manifest relighting block (originals untouched):

python scripts/relight_video.py out/ --preset night --mode repair --seed 1 --runner fake      # CPU stand-in (pipeline test only)
COSMOS_ROOT=/opt/cosmos-transfer2.5 python scripts/relight_video.py out/ --preset dusk --runner local   # real model, GPU host
python scripts/relight_video.py out/ --dry-run      # only write chunk spec JSONs
python scripts/ablate_relight.py out/ --runner fake # controls / mode / sign-restore ablation table

Presets: day_sunny, overcast, dusk, night, rain, fog. Modes: harmonize, repair (defect mask lowers control weights). Runners: local (subprocess in $COSMOS_ROOT), ssh, http, fake. Config: configs/relighting.yaml; GPU host setup: scripts/setup_cosmos.sh. API: POST /api/relight-jobs (render_job_id, preset, mode, seed), GET /api/relight-jobs/{id}; editor has a Relight / Harmonize panel with before/after slider. Sign faces are restored from the original pixels and clips failing validation fall back to the original frames (status: fallback_original). Hardware: Cosmos-Transfer2.5 needs an Ampere+ GPU (A100/H100/RTX30+; driver >= 570). Set up the env on a GPU host (scripts/setup_cosmos.sh, CUDA 12.8 base) and run runner: local there, or point ssh/http at that host. Weights are gated on Hugging Face (HF_TOKEN). Small GPU? --scope roi (sign-centred patch only) or --vram-gb N auto-selects a lighter tier and degrades on OOM; see docs/relighting_design.md §11. Status: the real Cosmos model has not been run; everything else is tested with the fake runner. Design: docs/relighting_design.md.

Asset management: create signs from 2D images

Editor: Assets panel → + New sign → upload a PNG/JPEG/WebP (auto-crop removes the background, the shape is detected, size follows the image aspect) → adjust name / shape / class id / size → Create asset (mesh + Gaussians are built immediately). × deletes an asset (blocked with 409 while a scene uses it).

API: GET /api/asset-templates (circular, triangular, triangular_down, rectangular, octagonal, diamond), POST /api/assets/analyze (preview, stores nothing), POST /api/assets (texture_b64, auto_crop, convert, overwrite; asset_id/template_id optional with an image; 409 on duplicate id), DELETE /api/assets/{id}. Code: packages/assets/image_ingest.py, AssetLibrary.create_from_image. Limits: sign faces are flat textured boards on a pole; shape detection covers the six templates (uncertain cases are flagged in warnings).

Smoke test with internet images (Wikimedia Commons, real uvicorn server): python scripts/smoke_assets_internet.py --images <dir>.

Rendering: the editor's Synthesize button opens a panel to pick mono (front camera) or surround8 (all cameras, needs a multi-camera rig), set the frame range and resolution and start the job; a progress bar tracks it. API: GET /api/scenes/{id}/render-options, POST /api/render-jobs with camera_mode, frame_start/end/step, outputs. See Web editor for the full flow.

Render backend: DRIVEFORGE_RENDERER=auto|gpu|cpu (default auto: gsplat on CUDA when installed, otherwise the NumPy reference rasterizer; GPU is ~500x faster and matches the reference within 1e-3). Install with pip install gsplat --index-url https://docs.gsplat.studio/whl/pt21cu121. DRIVEFORGE_RENDER_WORKERS sets the number of concurrent render threads (default 8 on GPU, 1 on CPU); output is bit-identical to serial rendering.

Repository layout

apps/api/          FastAPI backend (routes, schemas, job service)
apps/editor/       React + Three.js web editor (Vite, Vitest)
packages/          core libraries: common, reconstruction, assets, scene, rendering, relighting
scripts/           CLI tools (reconstruct, render, relight, validate, NuPlan training helpers)
configs/           YAML configs (reconstruction, rendering, relighting, DriveStudio overrides)
docs/              design docs and README images
tests/             unit, integration and smoke tests
third_party/       DriveStudio (git submodule)
launch_app.sh      one-click launcher for API + editor

Documentation

Contributing

Issues and pull requests are welcome.

  1. Fork, create a feature branch, keep changes focused.
  2. Run pytest tests/unit tests/integration and, for editor changes, cd apps/editor && npm test.
  3. Describe what changed and why in the PR; update docs when behavior changes.

License

Released under the Apache License 2.0.

Acknowledgements

Built on DriveStudio (reconstruction and Gaussian rendering), gsplat and NVIDIA Cosmos-Transfer2.5 (optional relighting). Demo data: nuPlan.

About

DriveForge — a 3DGS-powered synthetic data engine for autonomous driving. Reconstruct real driving scenes with DriveStudio/OmniRe, insert traffic-sign Gaussian assets in a web editor, render trajectory-conditioned multi-camera sequences with depth/masks/2D-3D annotations, and relight them with Cosmos-Transfer2.5.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors