Run this model with HF Jobs
Run mata01/slidegen-q-vit on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/mata01/slidegen-q-vit. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/mata01/slidegen-q-vit on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use mata01/slidegen-q-vit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mata01/slidegen-q-vit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="mata01/slidegen-q-vit") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mata01/slidegen-q-vit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
SlideGen-Q shared multi-label ViT
Visual branch of the hybrid slide evaluator in SlideGen-Q: Benchmark-Validated Technical Slide Evaluation for Content-First Generation (SoICT 2026). One ViT-Base forward pass gives five independent sigmoid scores for technical slide defects.
Code and paper: https://github.com/matapv01/SlideGenFunctionCalling/tree/paper/slidegen-q
Outputs
| Index | Checkpoint key | Name | Defect |
|---|---|---|---|
| 0 | mau_nen |
background_color |
background color hurts legibility |
| 1 | mau_chu |
text_color |
text color has too little contrast |
| 2 | size_chu |
font_size |
undersized text |
| 3 | de_nhau |
overlap |
elements obscure each other |
| 4 | tran_chu |
text_overflow |
text leaves its allocated region |
Each output is an independent probability (sigmoid, not softmax), so defects can co-occur. 1 means the defect is present; the paper uses threshold 0.5 for every criterion.
Files
| File | Contents |
|---|---|
best.pt |
PyTorch checkpoint, epoch 22 (best validation macro F1), 343 MB |
config.json |
Training hyperparameters (lr 5e-5, weight decay 0.005, batch 64, seed 45) |
sha256 of best.pt: 51da2ec6ba11e4c3d5cdc82b20ca2ebfbf66d17f57effb098b8d6564c29eff11
best.pt is a dictionary, not a bare state dict:
| Key | Value |
|---|---|
model_state_dict |
weights of ViTForImageClassification with 5 labels |
base_model |
google/vit-base-patch16-224-in21k (architecture to build) |
criteria |
["mau_nen", "mau_chu", "size_chu", "de_nhau", "tran_chu"] (output order) |
label_semantics |
1=error,0=no_error |
epoch |
22 |
val_metrics_05 |
validation metrics at threshold 0.5 |
Load in Python
Requirements: torch, torchvision, transformers, huggingface_hub, Pillow.
Tested with torch 2.9.1, torchvision 0.24.1, transformers 4.57.1, huggingface_hub 0.36.0; runs on CPU.
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from torchvision import transforms
from transformers import ViTConfig, ViTForImageClassification
# 1. Download and open the checkpoint (a pickle with metadata, hence weights_only=False).
path = hf_hub_download("mata01/slidegen-q-vit", "best.pt")
checkpoint = torch.load(path, map_location="cpu", weights_only=False)
# 2. Build ViT-Base with five outputs; only the base config is fetched, all weights come from the checkpoint.
config = ViTConfig.from_pretrained(
checkpoint["base_model"], # google/vit-base-patch16-224-in21k
num_labels=len(checkpoint["criteria"]),
problem_type="multi_label_classification",
)
model = ViTForImageClassification(config)
model.load_state_dict(checkpoint["model_state_dict"], strict=True)
model.eval()
# 3. Preprocess exactly as in training: RGB, resize to 224x224 without cropping, ImageNet normalization.
preprocess = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
# 4. One sigmoid per defect; 1 = defect present at threshold 0.5.
names = ["background_color", "text_color", "font_size", "overlap", "text_overflow"]
with Image.open("slide.png") as image:
pixels = preprocess(image.convert("RGB")).unsqueeze(0)
with torch.inference_mode():
probabilities = torch.sigmoid(model(pixel_values=pixels).logits)[0]
for name, p in zip(names, probabilities.tolist()):
print(f"{name:17s} {p:.3f} {'DEFECT' if p >= 0.5 else 'ok'}")
Notes:
weights_only=Falseis needed because the checkpoint stores metadata next to the weights. Unpickling can run code, so load the file only from this repository and check the sha256 above if in doubt.- Building the model from
ViTConfigdownloads only the base config (a few KB). UsingViTForImageClassification.from_pretrained(checkpoint["base_model"], num_labels=5, problem_type="multi_label_classification", ignore_mismatched_sizes=True)also works, but first downloads the 340 MB base weights thatload_state_dictthen overwrites. - Preprocessing must match: squash to 224x224 (no center crop), ImageNet mean/std. Inputs are 16:9 slide screenshots at any resolution (the paper's real-output renders are 3840x2160).
- For a GPU, move both the model and
pixelsto the device (model.to("cuda")).
Command-line evaluator
From a clone of the code repository (branch paper/slidegen-q):
python ViT/evaluate_generated_outputs.py --input-dir <folder of PNG slides> --output-dir out --device cpu
It downloads best.pt from this repository when --checkpoint points to a missing file, scans the folder
recursively, and writes out/predictions.csv (per-slide probabilities and 0/1 decisions),
out/deck_metrics.csv (pass rate per subfolder), and out/metrics.json (summary, checkpoint sha256).
Use --checkpoint path/to/best.pt for a local copy and --threshold to change the 0.5 cut-off.
Results
Locked 410-image test set (group-disjoint from training), threshold 0.5:
| BG | TC | FS | OV | OF | Macro | |
|---|---|---|---|---|---|---|
| F1 | 0.827 | 0.804 | 0.652 | 0.761 | 0.775 | 0.764 |
Limitations
The benchmark defects are controlled manual corruptions. On real generated slides, transfer depends on the criterion: injected background-color defects are detected reliably, while most text-color, font-size, and overflow defects are missed (Section 6.2 of the paper). The paper therefore keeps deterministic XML/geometry rules beside this model; use it as one signal, not as a sole quality judge.
- Downloads last month
- 28
Model tree for mata01/slidegen-q-vit
Base model
google/vit-base-patch16-224-in21k