Document Seal Detector v1
document-seal-detector-v1 detects rubber seals stamped on document pages. It returns a bounding box and confidence score for each detected seal.
The model is intended for document-processing workflows such as routing, review assistance, or extracting a seal region for a later verification step. It detects the presence and location of a seal; it does not verify the seal's authenticity, legal validity, or ownership.
Quick start
pip install -U torch transformers pillow
from PIL import Image, ImageDraw
import torch
from transformers import AutoImageProcessor, YolosForObjectDetection
MODEL_ID = "ducln-business/document-seal-detector-v1"
THRESHOLD = 0.60 # Start here; calibrate for your documents.
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
processor = AutoImageProcessor.from_pretrained(MODEL_ID)
model = YolosForObjectDetection.from_pretrained(MODEL_ID).to(device)
model.eval()
image = Image.open("document.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="pt")
inputs = {name: value.to(device) for name, value in inputs.items()}
with torch.no_grad():
outputs = model(**inputs)
# target_sizes is (height, width) of the original image.
results = processor.post_process_object_detection(
outputs,
threshold=THRESHOLD,
target_sizes=torch.tensor([[image.height, image.width]], device=device),
)[0]
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
x1, y1, x2, y2 = [round(value, 2) for value in box.tolist()]
print({
"label": model.config.id2label[label.item()],
"score": round(score.item(), 4),
"box_xyxy": [x1, y1, x2, y2],
})
Visualize predictions
rendered = image.copy()
draw = ImageDraw.Draw(rendered)
for score, box in zip(results["scores"].cpu(), results["boxes"].cpu()):
x1, y1, x2, y2 = map(round, box.tolist())
draw.rectangle((x1, y1, x2, y2), outline="lime", width=3)
draw.text((x1 + 4, max(0, y1 - 16)), f"seal {score:.2f}", fill="lime")
rendered.save("document_with_seals.jpg")
Model details
| Property | Value |
|---|---|
| Architecture | YolosForObjectDetection |
| Backbone family | YOLOS / Vision Transformer |
| Input processor | YolosImageProcessor |
| Processor size | 640 × 640 |
| Output label | 0: stamp |
| Fine-tuned from | ducln-business/signature-detector-v1.0 |
Bounding boxes are returned in xyxy pixel coordinates in the original input-image size.
What counts as a positive detection?
The positive class represents an inked rubber seal/stamp applied to a document. The training labels target primarily circular and oval administrative seals.
The following are not intended positive detections:
- QR codes and barcodes
- printed logos, letterheads, and decorative marks
- postage stamps and labels
- document windows, stickers, and blank form fields
- handwritten signatures without a rubber seal
Use a confidence threshold appropriate for the deployment setting. 0.60 is a sensible starting point; raise it to reduce false positives, or lower it to favor recall. Always validate the threshold on representative documents before production use.
Training data and preprocessing
The model was fine-tuned on document pages containing reviewed circular/oval rubber-seal annotations. The training pipeline:
- imports only source annotations labelled
stampwith thecirclegeometry; - converts each circular annotation to its enclosing rectangular detection box;
- keeps QR codes, barcodes, logos, and other printed document elements out of the positive class;
- adds stamp-free hard-negative document crops that do not overlap any annotated seal.
Dataset composition:
| Split | Seal-positive pages | Hard-negative document crops | Seal boxes |
|---|---|---|---|
| Train | 256 | 220 | 413 |
| Validation | 72 | 57 | 115 |
| Test | 39 | 27 | 62 |
Evaluation
The following result is measured on the internal held-out test split.
| Metric | Score |
|---|---|
| mAP@[0.50:0.95] | 0.8690 |
| mAP@0.50 | 1.0000 |
| mAP@0.75 | 1.0000 |
| mAR@100 | 0.8952 |
These numbers describe the curated internal split only. They should not be treated as a guarantee for documents from other countries, scanners, cameras, templates, or organizations.
Limitations and responsible use
- The data is dominated by circular/oval seals on administrative documents; rectangular seals, faint seals, severe blur, heavy occlusion, and uncommon layouts may perform worse.
- Despite hard-negative training, QR codes, logos, barcodes, postage stamps, and labels can still produce false positives on unseen layouts.
- This model locates visual seal-like regions. It must not be used as the sole basis for authenticity, fraud, legal, financial, or compliance decisions.
- For a production workflow, keep a human-review step and collect representative false-positive/false-negative examples for periodic re-training.
Reproducibility
The repository includes the model weights, image-processor configuration, training history, and internal test benchmark. Load both the model and processor from the same repository, as shown above.
Citation
If you use this model, please cite the repository:
@software{document_seal_detector_v1,
author = {ducln-business},
title = {Document Seal Detector v1},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/ducln-business/document-seal-detector-v1}
}