Views
No views yet
| Task | Metric | Score | Random Baseline |
|---|---|---|---|
| Danger Anticipation | AUC | 0.8385 | 0.500 |
| Geographic Region | Accuracy | 0.4438 | 0.167 (6 classes) |
| Time of Day | Accuracy | 0.5168 | 0.250 (4 classes) |
| Radar Health | AUC | 1.0000 | 0.500 |
| TTC Regression | Pearson r | 0.3009 | 0.000 |
1import torch
2import torch.nn as nn
3from huggingface_hub import hf_hub_download
4
5class DriveBenchModel(nn.Module):
6 def __init__(self, embed_dim=256, n_frames=5, n_regions=6):
7 super().__init__()
8 self.cls_token = nn.Parameter(torch.randn(1,1,768))
9 self.pos_embed = nn.Embedding(n_frames+1, 768)
10 layer = nn.TransformerEncoderLayer(
11 d_model=768, nhead=8, dim_feedforward=2048,
12 dropout=0.1, batch_first=True, norm_first=True)
13 self.transformer = nn.TransformerEncoder(layer, num_layers=3)
14 self.norm = nn.LayerNorm(768)
15 self.projector = nn.Sequential(
16 nn.Linear(768,512), nn.GELU(), nn.Dropout(0.15),
17 nn.Linear(512,embed_dim), nn.LayerNorm(embed_dim))
18
19 def encode(self, x):
20 B = x.shape[0]
21 cls = self.cls_token.expand(B,-1,-1)
22 x = torch.cat([cls,x],dim=1)
23 pos = torch.arange(x.shape[1], device=x.device)
24 x = x + self.pos_embed(pos)
25 x = self.norm(self.transformer(x))
26 return self.projector(x[:,0])
27
28path = hf_hub_download("Trazemag/DriveBench", "drivebench_best.pt")
29model = DriveBenchModel()
30ckpt = torch.load(path, map_location="cpu", weights_only=False)
31model.load_state_dict(ckpt["model_state"])
32model.eval()
33
34# Input: (batch, 5, 768) ViT-B/16 features from 5 consecutive frames
35# Output: (batch, 256) DriveBench embedding
36# Use as features for any downstream driving task1import numpy as np
2from huggingface_hub import hf_hub_download
3
4path = hf_hub_download(
5 "Trazemag/DriveBench-Embeddings",
6 "drivebench_embeddings.npz",
7 repo_type="dataset")
8data = np.load(path)
9embeddings = data["embeddings"] # (298326, 256)| Model | Task | Link |
|---|---|---|
| PRECOG-SENSE | Radar health from camera | Trazemag/PRECOG-SENSE |
| PRECOG-HERALD | Danger anticipation | Trazemag/PRECOG-HERALD |
| DriveBench | General scene encoder | This model |
1@misc{upadhyay2026drivebench,
2 title = {DriveBench: General-Purpose Driving Scene Encoder
3 via Multi-Task Safety-Focused Pre-training across 25 Countries},
4 author = {Upadhyay, Nikhil},
5 year = {2026},
6 url = {https://github.com/TrazeMaG/PRECOG-AV}
7}