YOLOv8n ID-code detector for RVL-CDIP documents

A YOLOv8n model fine-tuned to detect document ID codes. These are the identifiers printed on scanned pages in the RVL-CDIP / IIT-CDIP (Legacy Tobacco Documents) collection. Use it to find these codes so you can mask or remove them. Removing them stops document classifiers from using the codes as shortcut features.

  • Classes: 1 (id)
  • Base model: yolov8n.pt (Ultralytics 8.3.153)
  • Input size: 640

Example: detected ID code (left) and whited-out result (right)

An RVL-CDIP test invoice. Left: the ID code found by the model (red box, confidence 0.89). Right: the same page after whiting out the box with the code in the Usage section.

Intended use

  • Finding Bates-style ID codes on RVL-CDIP and Tobacco3482 page scans (and more broadly the IIT-CDIP corpus they are drawn from), so they can be masked or removed from the image and the OCR text.
  • Building versions of these benchmarks without ID codes, to check whether a document classifier relies on them (as in the paper below).

Related dataset

stefan-hf/rvlcdip-id-codes contains the ID codes this model found on all 399,998 RVL-CDIP pages: 446,332 boxes, each with an OCR transcription. It also contains the hand-annotated boxes for 11,199 RVL-CDIP pages (including the 8,000-page training sample) and for all of Tobacco3482.

Out-of-scope use and limitations

  • It was trained only on tobacco-industry scans (RVL-CDIP / IIT-CDIP). It hasn't been tested on other document collections, where ID-code styles and page layouts may differ.
  • It only detects ID codes. It isn't a general tool for removing personal information: names, addresses and signatures are not detected.
  • Validation used Tobacco3482, which comes from the same source collection as RVL-CDIP. Expect lower accuracy on documents from other sources.
  • Missed detections leave ID codes in place, so check a sample of the masked output before relying on it.

Usage

from huggingface_hub import hf_hub_download
from ultralytics import YOLO

model = YOLO(hf_hub_download("stefan-hf/yolov8n-rvlcdip-idcodes", "yolov8n-idcodes.pt"))
results = model.predict("page.png")
for box in results[0].boxes.xyxy:
    print(box.tolist())  # pixel coordinates of each detected ID code

To white out the detected ID codes:

from PIL import Image, ImageDraw

image = Image.open("page.png")
draw = ImageDraw.Draw(image)
for x1, y1, x2, y2 in results[0].boxes.xyxy.tolist():
    draw.rectangle([round(x1), round(y1), round(x2), round(y2)], fill="white")
image.save("page_redacted.png")

Training

Train set 8,000-page sample of RVL-CDIP
Validation set Tobacco3482 (3,482 pages)
Epochs 50
Batch size 32
Image size 640

Full hyperparameters are in args.yaml. Per-epoch metrics are in results.csv.

Results (Tobacco3482 validation, epoch 50)

Precision Recall mAP50 mAP50-95
0.974 0.968 0.987 0.851

results

Citation

This model was used in Spurious Cues in RVL-CDIP and Tobacco3482 Document Classification: The Case of ID Codes (DocEng '25). If you use this model in your research, please cite:

@inproceedings{larson2025spurious,
  title     = {Spurious Cues in {RVL-CDIP} and {Tobacco3482} Document Classification: The Case of {ID} Codes},
  author    = {Larson, Stefan and Duwal, Sharad and Vilnrotter, Brian and Chakkithara, Gayatri and Padwal, Vedant and Leach, Kevin},
  booktitle = {Proceedings of the 2025 ACM Symposium on Document Engineering},
  series    = {DocEng '25},
  pages     = {1--4},
  year      = {2025},
  month     = aug,
  publisher = {ACM},
  address   = {New York, NY, USA},
  doi       = {10.1145/3704268.3748683},
  url       = {https://doi.org/10.1145/3704268.3748683}
}

License

The model is fine-tuned from Ultralytics YOLOv8, so it is released under AGPL-3.0.

Downloads last month
21
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for stefan-hf/yolov8n-rvlcdip-idcodes

Finetuned
(233)
this model

Dataset used to train stefan-hf/yolov8n-rvlcdip-idcodes