CARLA Dataset (Target)
A large-scale driving dataset captured from CARLA simulator, containing RGB images and depth maps with camera parameters for autonomous driving research.
Tar File Structure
This dataset is stored in WebDataset format for efficient streaming and loading.
Sharding Strategy
- 3 scenes per shard: Each
.tarfile contains exactly 3 complete scenes - 93 frames per scene: Each scene is a video sequence of 93 consecutive frames
- ~279 frames per tar: 3 scenes × 93 frames = 279 frames per shard
Repository Structure
carla-dataset/
├── Town01/
│ ├── vehicle/
│ │ ├── carla-stage2-000000.tar ← Scenes 1-3
│ │ ├── carla-stage2-000001.tar ← Scenes 4-6
│ │ └── ...
│ └── pedestrian/
│ └── ...
├── Town02/
│ └── ...
├── Town03/
│ └── ...
├── Town04/
│ └── ...
├── Town05/
│ └── ...
└── Town06/
└── ...
Shard Contents (WebDataset format)
Each tar file contains samples with the following files per frame:
{scene_id}_{frame_idx:03d}.rgb.png ← RGB image (1280×704)
{scene_id}_{frame_idx:03d}.depth.npy ← Depth map (numpy array, 704×1280)
{scene_id}_{frame_idx:03d}.camera.json ← Camera parameters + matched reference frames
{scene_id}_{frame_idx:03d}.metadata.json ← Scene info (scene_id, frame_id, town, actor_type)
Key Format: {scene_id}_{frame_idx:03d} (e.g., scene_001_000, scene_001_001, ..., scene_001_092)
Data Format
Each sample contains:
rgb: PIL.Image (1280×704) - RGB imagedepth: np.ndarray (704, 1280) - Depth mapcamera: dict containing:intrinsic: Camera intrinsic matrixextrinsic: Camera extrinsic matrixmatched_references: List of reference image IDs accumulated along the trajectory
metadata: dict containing:scene_id: Unique scene identifierframe_id: Frame index within the scene (0-92)town: CARLA town name (Town01-Town06)actor_type: Type of actor being followed ("vehicle" or "pedestrian")
Camera JSON with Reference Frame Mapping
Each camera.json contains camera parameters and matched reference frames:
{
"intrinsic": { ... },
"extrinsic": { ... },
"carla_transform": { ... },
"matched_references": ["subset_0/0001", "subset_0/0042", "subset_0/0083"]
}
Reference Accumulation: As the camera moves through the scene, reference frames are accumulated:
- Frame 0:
[ref_A]- first reference encountered - Frame 20:
[ref_A, ref_B]- new reference added - Frame 40:
[ref_A, ref_B, ref_C]- another reference added - ...
This allows each target frame to know which reference images are relevant based on position and viewing angle.
Dataset Statistics
Dataset Summary
| Town | Mode | Scenes | Images | Avg Images/Scene |
|---|---|---|---|---|
| Town01 | pedestrian | 520 | 48,360 | 93.0 |
| Town01 | vehicle | 490 | 45,570 | 93.0 |
| Town01 | TOTAL | 1,010 | 93,930 | 93.0 |
| Town02 | pedestrian | 509 | 47,337 | 93.0 |
| Town02 | vehicle | 500 | 46,500 | 93.0 |
| Town02 | TOTAL | 1,009 | 93,837 | 93.0 |
| Town03 | pedestrian | 500 | 46,500 | 93.0 |
| Town03 | vehicle | 500 | 46,500 | 93.0 |
| Town03 | TOTAL | 1,000 | 93,000 | 93.0 |
| Town04 | pedestrian | 500 | 46,500 | 93.0 |
| Town04 | vehicle | 530 | 49,290 | 93.0 |
| Town04 | TOTAL | 1,030 | 95,790 | 93.0 |
| Town05 | pedestrian | 500 | 46,500 | 93.0 |
| Town05 | vehicle | 500 | 46,500 | 93.0 |
| Town05 | TOTAL | 1,000 | 93,000 | 93.0 |
| Town06 | pedestrian | 500 | 46,500 | 93.0 |
| Town06 | vehicle | 500 | 46,500 | 93.0 |
| Town06 | TOTAL | 1,000 | 93,000 | 93.0 |
Grand Total
| Metric | Value |
|---|---|
| Total Scenes | 6,049 |
| Total Images | 562,557 |
| Towns | 6 (Town01-06) |
Example Usage
📝 Full example code is available in
example_usage.py
Installation
pip install datasets torch pillow numpy webdataset
Basic Usage with webdataset
import webdataset as wds
from huggingface_hub import hf_hub_url
import json
import numpy as np
from PIL import Image
import io
# Stream dataset from HuggingFace
url = "https://huggingface.co/datasets/mkxdxd/carla-dataset/resolve/main/Town01/pedestrian/{carla-stage2-000000..carla-stage2-000010}.tar"
dataset = wds.WebDataset(url).decode("pil")
for sample in dataset:
key = sample["__key__"]
rgb = sample["rgb.png"] # PIL.Image (1280x704)
depth = np.load(io.BytesIO(sample["depth.npy"])) # numpy array (704x1280)
camera = json.loads(sample["camera.json"]) # dict
metadata = json.loads(sample["metadata.json"]) # dict
print(f"Key: {key}")
print(f"RGB size: {rgb.size}")
print(f"Depth shape: {depth.shape}")
print(f"Scene: {metadata['scene_id']}, Town: {metadata['town']}")
break
With PyTorch DataLoader
import webdataset as wds
import torch
from torch.utils.data import DataLoader
import json
import numpy as np
from PIL import Image
import io
def decode_sample(sample):
return {
"rgb": sample["rgb.png"],
"depth": np.load(io.BytesIO(sample["depth.npy"])),
"camera": json.loads(sample["camera.json"]),
"metadata": json.loads(sample["metadata.json"]),
}
url = "https://huggingface.co/datasets/mkxdxd/carla-dataset/resolve/main/Town01/pedestrian/{carla-stage2-000000..carla-stage2-000010}.tar"
dataset = (
wds.WebDataset(url)
.decode("pil")
.map(decode_sample)
)
dataloader = DataLoader(dataset, batch_size=8, num_workers=4)
for batch in dataloader:
rgb_batch = batch["rgb"]
depth_batch = batch["depth"]
# ... training code
break
Dataset generated from CARLA Simulator