Views
No views yet
{state_dict, vis_dim, txt_dim, d_model, num_layers, encoder, epoch, val_miou, val_acc50}.VisualGroundingHeadvis_proj : Linear(vis_dim → 256)
txt_proj : Linear(txt_dim → 256)
reg_token : Parameter [1, 1, 256]
sequence : [REG | vis_tokens | txt_token]
transformer: 3 × TransformerEncoderLayer (self-attn, pre-norm)
box_head : MLP(256 → 256 → 4) # sigmoid → (cx,cy,w,h) ∈ [0,1]| File | Encoder | vis_dim | txt_dim |
|---|---|---|---|
clip-vit-l14.pt | CLIP ViT-L/14 | 1024 | 768 |
siglip.pt | SigLIP | 1152 | 1152 |
florence2.pt | Florence-2 | 1024 | 768 |
coca.pt | CoCa | 768 | 768 |
owlv2.pt | OWLv2 | 1024 | 768 |
mae-vit-l16.pt | MAE ViT-L/16 | 1024 | 768 |
1import torch
2from lapvqa.pg.heads import VisualGroundingHead
3
4ckpt = torch.load("mae-vit-l16.pt", map_location="cpu")
5head = VisualGroundingHead(
6 vis_dim = ckpt["vis_dim"],
7 txt_dim = ckpt["txt_dim"],
8 d_model = ckpt["d_model"],
9 num_layers = ckpt["num_layers"],
10)
11head.load_state_dict(ckpt["state_dict"])
12head.eval()
13
14with torch.no_grad():
15 # vis_tokens: [B, HW, vis_dim] — spatial patch tokens from frozen encoder
16 # txt_vec: [B, txt_dim] — pooled text representation from frozen encoder
17 pred_boxes = head(vis_tokens, txt_vec) # [B, 4] (cx,cy,w,h) in [0,1]