A fine-tuned YOLOS model for detecting stamps in documents.
This model is based on hustvl/yolos-small and fine-tuned for single-class stamp detection in documents. It can identify and localize stamps with high accuracy.
from transformers import AutoImageProcessor, AutoModelForObjectDetection
from PIL import Image
import torch
# Load model
processor = AutoImageProcessor.from_pretrained("Ooredoo-Group/ooredoo-stamp-detection")
model = AutoModelForObjectDetection.from_pretrained("Ooredoo-Group/ooredoo-stamp-detection")
# Inference
image = Image.open("document_with_stamp.jpg")
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
# Post-process results
target_sizes = torch.tensor([image.size[::-1]])
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes)[0]
# Display results
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
print(f"Detected stamp with confidence {score:.2f}")
print(f"Bounding box: {box}")
Ooredoo-Group
Apache-2.0