Views
No views yet
{state_dict, vis_dim, d_model, num_queries, num_enc, num_dec, encoder, epoch, val_map40, val_map50}.DetectionHeadvis_proj : Linear(vis_dim → 256)
encoder : 2 × TransformerEncoderLayer (self-attn, pre-norm)
object_queries : Parameter [1, 20, 256]
decoder : 3 × TransformerDecoderLayer (cross-attn to encoder output)
class_head : Linear(256 → 15) # 14 classes + background
box_head : MLP(256 → 256 → 4) # (cx,cy,w,h) ∈ [0,1]| Encoder | mAP@0.4 (test) |
|---|---|
| OWLv2 | 0.048 |
| SigLIP | ~0.045 |
| CLIP ViT-L/14 | ~0.040 |
| File | Encoder | vis_dim |
|---|---|---|
clip-vit-l14.pt | CLIP ViT-L/14 | 1024 |
siglip.pt | SigLIP | 1152 |
florence2.pt | Florence-2 | 1024 |
coca.pt | CoCa | 768 |
owlv2.pt | OWLv2 | 1024 |
mae-vit-l16.pt | MAE ViT-L/16 | 1024 |
1import torch
2from lapvqa.ad.heads import DetectionHead
3from lapvqa.ad.heads import predict
4
5ckpt = torch.load("owlv2.pt", map_location="cpu")
6head = DetectionHead(
7 vis_dim = ckpt["vis_dim"],
8 d_model = ckpt["d_model"],
9 num_queries = ckpt["num_queries"],
10 num_enc_layers = ckpt["num_enc"],
11 num_dec_layers = ckpt["num_dec"],
12)
13head.load_state_dict(ckpt["state_dict"])
14head.eval()
15
16with torch.no_grad():
17 # vis_tokens: [B, HW, vis_dim] — spatial patch tokens from the frozen encoder
18 outputs = head(vis_tokens)
19 detections = predict(outputs, score_threshold=0.1, nms_iou=0.5)
20 # detections[i]: {'boxes': [K,4] xyxy, 'labels': [K], 'scores': [K]}