Views
No views yet
calibration.json (rhode train-split centroid + Platt scaling params) in this repo.google/siglip-so400m-patch14-384 (full SiglipModel, contrastively fine-tuned).1import json, numpy as np, torch
2from PIL import Image
3from transformers import SiglipModel, SiglipImageProcessor
4from huggingface_hub import hf_hub_download
5
6repo = "Gupta28/judgebench-siglip-judge-v3-hardened"
7model = SiglipModel.from_pretrained(repo)
8proc = SiglipImageProcessor.from_pretrained(repo)
9params = json.load(open(hf_hub_download(repo, "calibration.json")))
10centroid = np.array(params["centroid"]) # L2-normalized rhode train centroid
11
12img = Image.open("image.jpg")
13with torch.no_grad():
14 emb = model.get_image_features(**proc(images=img, return_tensors="pt"))
15v = emb[0].numpy(); v /= np.linalg.norm(v)
16cos = float(v @ centroid)
17score = 1 / (1 + np.exp(-(params["platt_a"] * cos + params["platt_b"]))) # calibrated on-brand prob