data-doctor
Diagnose vision datasets before they lie to you: duplicate images, train/val leakage, and annotation defects — in one command, with no heavy dependencies (Pillow only).
Why
Metrics are only as honest as the split behind them. This tool exists because
of a real production dataset whose delivered train/val split contained 81
groups of byte-identical images spanning both sides — the reference model
scored 0.75 recall on that split and substantially less on an honest one.
Nothing in the training stack warned about it. data-doctor makes that
check (and its cousins) a 10-second habit instead of a post-mortem.
Install
pip install data-doctor
Usage
Find corrupt files, exact duplicates, and near-duplicates in a folder:
data-doctor scan data/images --json report.json
Check a train/val split for leakage (byte-identical and perceptually near-identical frames on both sides):
data-doctor leakage --train data/train --val data/val
train: 714 images | val: 231 images
FAIL exact leaks (byte-identical in both splits): 81
val/frame_0117.jpg == train/frame_0116.jpg
...
FAIL near leaks (pixel-verified >= 90% similar): 12
val/frame_0201.jpg ~~ train/frame_0200.jpg (99.4% similar)
val/shot_114.jpg ~~ train/shot_113.jpg (98.7% similar, rot90)
40.3% of the validation set is leaked from train.
Metrics measured on this split overstate real performance.
Structural checks on a COCO annotation file:
data-doctor coco annotations/train.json --images data/images
Checks: duplicate image ids and file names, annotations referencing missing images, unknown category references, degenerate boxes (zero width/height), degenerate polygons (< 3 points), referenced files missing on disk, and a count of zero-annotation images (hard negatives or missing labels — you decide which, the tool makes sure you see them).
Exit codes
0 when clean, 1 when any check fails — drop it straight into CI:
- run: data-doctor leakage --train data/train --val data/val
Python API
from data_doctor import scan_directory, check_leakage, check_coco
result = check_leakage(Path("data/train"), Path("data/val"))
print(result.leaked_val_fraction)
How near-duplicate detection works
Three stages, so every reported duplicate is a concrete, verified claim — not a fuzzy hash coincidence:
- Exact — SHA-256 catches byte-identical copies.
- Nominate — two perceptual hash families (difference hash and DCT pHash), computed over all 8 rotations/flips, propose candidate pairs. Candidates are found by 16-bit quadrant bucketing (pigeonhole: any two hashes within hamming distance 3 share an identical quadrant), so scans stay fast on large folders.
- Verify — every candidate pair is confirmed on decoded pixels:
grayscale thumbnails compared across the 8 dihedral orientations. Only
pairs at or above the similarity floor are reported, each with its
measured score and matching orientation (
99.4% similar, rot90).
Hashes alone never convict — they only nominate. Tune recall with
--near-threshold (default 3) and precision with --min-similarity
(default 0.90). Rotated, flipped, re-encoded, and resized copies are all
caught; the JSON report carries every verified pair with its score.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vision_data_doctor-0.2.0.tar.gz.
File metadata
- Download URL: vision_data_doctor-0.2.0.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5fa23d13f7e97e3522e881f03968ac07408482468db347a6758f595052445be
|
|
| MD5 |
e62ead5d9fe11d99c13d230c143bf7d8
|
|
| BLAKE2b-256 |
ab355eb62c6f7e83b8b22194832b80f9666710f83a717e9588c0a46712a91f55
|
File details
Details for the file vision_data_doctor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vision_data_doctor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1294f304d8ed45f6d73a5109035ec30f714ebf17d0363c3f673b792fba945e93
|
|
| MD5 |
d73390bd16f924165ecf5653e37439fd
|
|
| BLAKE2b-256 |
dcec977afbe052dfafe96d006ddaf80fde807c103e232519e740dc87f71f4705
|