This project implements a stamp detection and processing pipeline using YOLOv8 and OpenCV. It can detect stamps in documents and create background-less stamp images.
This website is a Stamp Processor application built with Streamlit that automatically detects stamps in uploaded images using a YOLO (You Only Look Once) deep learning model. It processes the detected stamps by making the blue parts transparent through HSV color thresholding, allowing users to extract stamps with transparent backgrounds. The application features a user-friendly interface with a customizable threshold slider for fine-tuning the blue detection sensitivity, supports various input options (single image, multiple images, or zip files), and provides download capabilities for the processed stamps.
-
Dataset Preparation
- Manual annotation of stamps in documents using Roboflow
- Dataset extraction and preprocessing
-
Model Training
- YOLOv8n model training for stamp detection
from ultralytics import YOLO model = YOLO("yolov8n.pt") model.train( data="/kaggle/input/stamp-data/My First Project/data.yaml", epochs=100, patience=5, imgsz=640, device="cuda" )
-
Inference Pipeline
- Document stamp detection using trained model
- Bounding box extraction of detected stamps
- Background removal using HSV color filtering for blue stamps
The project uses specific HSV color ranges to isolate blue stamps:
- Hue: Blue color range
- Saturation: Color intensity
lower_blue = np.array([90, 50, 50])
upper_blue = np.array([130, 255, 255])
hsv = cv2.cvtColor(cropped_img, cv2.COLOR_BGR2HSV)
mask = cv2.inRange(hsv, lower_blue, upper_blue)- Base Model: YOLOv8n
- Task: Object Detection
- Classes: 1 (Stamp)
- Training Data: Custom annotated dataset
The pipeline successfully:
- Detects stamps in documents
- Extracts stamp regions
- Creates clean, background-less stamp images






