Views
No views yet
| Metric | Value |
|---|---|
| Test AUC | 0.8805 |
| Average Precision | 0.2593 |
| Geographic Gap (GGG) | -0.018 (better on unseen countries) |
| Benchmark | Metric | PRECOG | Previous Best |
|---|---|---|---|
| CCD | AP | 99.95% | 99.80% (RARE) |
| CCD | mTTA | 4.25s | — |
| DAD | mTTA | 3.83s | 3.16s (LATTE) |
1import torch
2import torch.nn as nn
3from huggingface_hub import hf_hub_download
4
5class HERALDv2(nn.Module):
6 def __init__(self, n_frames=5):
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=4, dim_feedforward=1536,
12 dropout=0.3, batch_first=True, norm_first=True)
13 self.transformer = nn.TransformerEncoder(layer, num_layers=2)
14 self.cam_norm = nn.LayerNorm(768)
15 self.obj_encoder = nn.Sequential(
16 nn.Linear(7,64), nn.GELU(), nn.Dropout(0.3), nn.Linear(64,128), nn.GELU())
17 self.head = nn.Sequential(
18 nn.Linear(896,256), nn.GELU(), nn.Dropout(0.3),
19 nn.Linear(256,64), nn.GELU(), nn.Linear(64,1))
20 def forward(self, x, obj):
21 B = x.shape[0]
22 cls = self.cls_token.expand(B,-1,-1)
23 x = torch.cat([cls,x],dim=1)
24 pos = torch.arange(x.shape[1], device=x.device)
25 x = x + self.pos_embed(pos)
26 x = self.cam_norm(self.transformer(x))
27 return self.head(torch.cat([x[:,0], self.obj_encoder(obj)],dim=1)).squeeze(-1)
28
29path = hf_hub_download("Trazemag/PRECOG-HERALD", "herald_v2_best.pt")
30model = HERALDv2()
31model.load_state_dict(torch.load(path, map_location="cpu"))
32model.eval()
33# x: (1, N_FRAMES, 768) ViT-B/16 features
34# obj: (1, 7) object proximity stats — pass zeros for camera-only mode1@misc{upadhyay2026precog,
2 title = {PRECOG: Proactive Risk and Environmental Cognition for Autonomous Vehicles},
3 author = {Upadhyay, Nikhil},
4 year = {2026},
5 url = {https://github.com/TrazeMaG/PRECOG-AV}
6}