This repository presents a Conditional-DETR model with ResNet-50 backbone, fine-tuned to detect handwritten signatures in document images. This model achieved the highest mAP@0.5 (93.65%) among all tested architectures in our comprehensive evaluation.
Resource
Links / Badges
Details
Article
A detailed community article covering the full development process of the project
The training utilized a dataset built from two public datasets: [Tobacco800](https://paperswithcode.com/dataset/tobacco-800) and [signatures-xc8up](https://universe.roboflow.com/roboflow-100/signatures-xc8up), unified and processed in [Roboflow](https://roboflow.com/).
Dataset Summary:
Training: 1,980 images (70%)
Validation: 420 images (15%)
Testing: 419 images (15%)
Format: COCO JSON
Resolution: 640x640 pixels
Roboflow Dataset
Training Process
The training process involved the following steps:
1. Model Selection:
Various object detection models were evaluated to identify the best balance between precision, recall, and inference time.
The models were evaluated on the test set at the end of training in ONNX (CPU) and TensorRT (GPU - T4) formats. Performance metrics included precision, recall, mAP50, and mAP50-95.
Trials
Results Comparison:
Metric
Base Model
Best Trial (#10)
Difference
mAP50
87.47%
95.75%
+8.28%
mAP50-95
65.46%
66.26%
+0.81%
Precision
97.23%
95.61%
-1.63%
Recall
76.16%
91.21%
+15.05%
F1-score
85.42%
93.36%
+7.94%
Results
After hyperparameter tuning of the YOLOv8s model, the best model achieved the following results on the test set:
Precision: 94.74%
Recall: 89.72%
mAP@50: 94.50%
mAP@50-95: 67.35%
Inference Time:
ONNX Runtime (CPU): 171.56 ms
TensorRT (GPU - T4): 7.657 ms
How to Use
Installation
pip install transformers torch torchvision pillow
Inference
python
1from transformers import AutoImageProcessor, AutoModelForObjectDetection
2from PIL import Image
3import torch
45# Load model and processor6model_name ="tech4humans/conditional-detr-50-signature-detector"7processor = AutoImageProcessor.from_pretrained(model_name)8model = AutoModelForObjectDetection.from_pretrained(model_name)910# Load and process image11image = Image.open("path/to/your/document.jpg")12inputs = processor(images=image, return_tensors="pt")1314# Run inference15with torch.no_grad():16 outputs = model(**inputs)1718# Post-process results19target_sizes = torch.tensor([image.size[::-1]])20results = processor.post_process_object_detection(21 outputs, target_sizes=target_sizes, threshold=0.522)[0]2324# Extract detections25for score, label, box inzip(results["scores"], results["labels"], results["boxes"]):26 box =[round(i,2)for i in box.tolist()]27print(f"Detected signature with confidence {round(score.item(),3)} at location {box}")
You can explore the model and test real-time inference in the Hugging Face Spaces demo, built with Gradio and ONNXRuntime.
🔗 Inference with Triton Server
If you want to deploy this signature detection model in a production environment, check out our inference server repository based on the NVIDIA Triton Inference Server.