Downloads · 30 days
0
meghnagera15/paligemma-checkbox-classifier
paligemma-checkbox-classifier is a machine learning model from meghnagera15. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a lightweight classifier head trained on top of frozen PaliGemma-3B vision embeddings to classify checkbox state:
Downloads · 30 days
0
Access
Public
Updated Jan 22, 2026
Repo size
2.1 MB
Likes
0
Public
Click a slice to open those files.
.pt2.1 MB · 100%
From the Hugging Face model README
This repository contains a lightweight classifier head trained on top of frozen PaliGemma-3B vision embeddings to classify checkbox state:
uncheckedcheckedNote: The PaliGemma backbone (
google/paligemma-3b-mix-224) is loaded from Hugging Face at runtime.
This repo stores only the trained classifier head and configs.
classifier_head.pt — trained PyTorch classifier head weightsmodel_config.json — inference configuration (backbone + head input dim + labels)training_config.json — training hyperparameters and setupmodel_info.json — short metadata about the modelpip install torch transformers pillow
import json
import torch
import torch.nn as nn
from PIL import Image
from transformers import AutoProcessor, PaliGemmaModel
DEVICE = "cpu"
MODEL_DIR = "." # folder containing classifier_head.pt + model_config.json
with open(f"{MODEL_DIR}/model_config.json", "r") as f:
cfg = json.load(f)
# Load backbone + processor
processor = AutoProcessor.from_pretrained(cfg["backbone"])
backbone = PaliGemmaModel.from_pretrained(cfg["backbone"]).to(DEVICE)
backbone.eval()
# Rebuild classifier head (must match training)
classifier = nn.Sequential(
nn.Linear(cfg["classifier_architecture"]["input_dim"], 256),
nn.ReLU(),
nn.Dropout(0.3),
nn.Linear(256, 2)
).to(DEVICE)
classifier.load_state_dict(
torch.load(f"{MODEL_DIR}/classifier_head.pt", map_location=DEVICE)
)
classifier.eval()
@torch.no_grad()
def extract_features(image: Image.Image):
inputs = processor(images=image, return_tensors="pt").to(DEVICE)
outputs = backbone(**inputs)
return outputs.last_hidden_state.mean(dim=1)
@torch.no_grad()
def predict(image_path: str):
image = Image.open(image_path).convert("RGB")
features = extract_features(image)
logits = classifier(features)
pred = logits.argmax(dim=1).item()
return "checked" if pred == 1 else "unchecked"
print(predict("sample.jpg"))
0 → unchecked1 → checked