Downloads · 30 days
39
15% of all-time downloads
NationalLibraryOfScotland/archival-index-card-detector
archival-index-card-detector is a object detection model from NationalLibraryOfScotland. Use it when you need objects located in an image. It is set up for ultralytics. The card lists the license as agpl-3.0.
Superseded by NationalLibraryOfScotland/card-detector-retinanet, a newer detector trained on the same collection.
Downloads · 30 days
39
15% of all-time downloads
All-time downloads
252
Public
Repo size
21.1 MB
Likes
4
Public
Click a slice to open those files.
.pt15.7 MB · 100%
From the Hugging Face model README
Superseded by NationalLibraryOfScotland/card-detector-retinanet, a newer detector trained on the same collection.
A YOLO26n model trained to detect index cards in digitized archival document scans.
This model detects index cards in scanned archival documents, returning bounding box coordinates for each detected card. It was trained specifically on historical library index cards from the National Library of Scotland's Advocates Library collection.
Single class: index_card
| Metric | Value |
|---|---|
| mAP@50 | 99.3% |
| mAP@50-95 | 99.1% |
| Precision | 99.9% |
| Recall | 98.9% |
Trained on 905 images over 85 epochs.
This model was built through an iterative loop using Claude Code to build tooling and UV scripts on HF Jobs for inference.
| Version | Images | mAP@50-95 | What happened |
|---|---|---|---|
| v1 | 100 | 94.4% | SAM3 bootstrap → manual correction → train |
| v2 | 297 | 95.5% | Run v1 on new images → correct outputs → retrain |
| v3 | 905 | 99.2% | Run v2 on more images → correct → retrain |
Zero-shot bootstrap with SAM3: Ran SAM3 via a UV script on HF Jobs to get initial bounding box predictions on ~100 archival images. Result: only 31% true positive rate (many false positives on backs of cards).
Claude Code built annotation tooling: Asked Claude Code to build an HTML bounding box editor for correcting the SAM3 outputs. It created a simple tool to visualize images, adjust boxes, and export corrected annotations.
Manual correction: Used the bbox editor to correct annotations - removing false positives from versos (card backs) and adjusting box coordinates.
Train v1: Fine-tuned YOLO26n on the corrected 100 images → 94.4% mAP@50-95.
Expand with model predictions: Claude Code built scripts to run the trained model on new images from HF Hub, outputting predictions in the same format as SAM3 for the bbox editor.
Correct and retrain: Loaded model predictions into the editor, corrected errors, merged with existing annotations, retrained → v2 (95.5%) → v3 (99.2%).
AI bootstraps → Claude builds tooling → human corrects → model improves → repeat
This workflow is useful when you have domain-specific detection needs but no labelled training data. The key insight: use AI (SAM3/previous model) to generate candidate annotations, then spend human time correcting rather than creating from scratch.
from ultralytics import YOLO
from huggingface_hub import hf_hub_download
# Download and load model
model = YOLO(hf_hub_download(
repo_id="NationalLibraryOfScotland/archival-index-card-detector",
filename="model.pt"
))
# Run inference
results = model.predict("scan.jpg")
# Get bounding boxes
for result in results:
boxes = result.boxes
for box in boxes:
x1, y1, x2, y2 = box.xyxy[0].tolist()
confidence = box.conf[0].item()
print(f"Index card detected at ({x1:.0f}, {y1:.0f}, {x2:.0f}, {y2:.0f}) with confidence {confidence:.2f}")
from ultralytics import YOLO
from PIL import Image
model = YOLO(hf_hub_download(
repo_id="NationalLibraryOfScotland/archival-index-card-detector",
filename="model.pt"
))
image = Image.open("scan.jpg")
results = model.predict(image)
for i, box in enumerate(results[0].boxes):
x1, y1, x2, y2 = box.xyxy[0].tolist()
# Add padding (10%)
w, h = x2 - x1, y2 - y1
pad = 0.1
x1 = max(0, x1 - w * pad)
y1 = max(0, y1 - h * pad)
x2 = min(image.width, x2 + w * pad)
y2 = min(image.height, y2 + h * pad)
cropped = image.crop((x1, y1, x2, y2))
cropped.save(f"card_{i}.jpg")
If you use this model, please cite:
@misc{vanstrien2026indexcard,
author = {van Strien, Daniel},
title = {Archival Index Card Detector},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/davanstrien/archival-index-card-detector}
}
This model is released under the AGPL-3.0 license (required by the YOLO26 base model license).