image imagewidth (px) 320 320 |
|---|
4-captcha dataset
Grayscale synthetic four-digit captcha images for robust digit-string recognition and adversarial fine-tuning experiments.
Splits
| Split | Images | Labels |
|---|---|---|
| clean/train | 100,000 | 4-digit string |
| clean/val | 5,000 | 4-digit string |
| clean/test | 5,000 | 4-digit string |
| adv/{vit,cnn}/train | 20,000 each | same as source clean image |
| adv/{vit,cnn}/val | 1,000 each | same as source clean image |
| adv/{vit,cnn}/test | 1,000 each | same as source clean image |
Total stored images: 132,000 for a full release with both ViT and CNN adversarial splits.
Digit combinations for clean train are sampled with replacement from an 8,000-combo pool. Clean val and test use disjoint 1,000-combo pools. Adversarial splits are generated per model from trained clean checkpoints with FGSM.
Image format
- Resolution: $320 \times 80$ pixels
- Channels: 1, grayscale PNG
- Label file:
labels.csvwith columnsfilename,label
Rendering
Each image contains four digits $d_1 d_2 d_3 d_4$, $d_i \in {0,\ldots,9}$.
Per-digit variation:
- independent TrueType font from a system font pool
- native glyph height about $0.45$β$0.55$ of image height
- rotation uniform in $[-15Β°, 15Β°]$
- small horizontal and vertical shift
- optional slight overlap between neighbours
Canvas background is white or light gray.
Global transforms
Applied to the full image after digit placement, with seed 42:
- elastic deformation
- 2β4 dark BΓ©zier curves, thickness 1β3 px
- Gaussian noise with $\sigma \sim \mathrm{Uniform}(5, 20)$ on the 0β255 scale
- Gaussian blur with kernel $3 \times 3$ or $5 \times 5$
- brightness and contrast jitter
- gamma scaling
Adversarial splits
FGSM with
where $L$ is the sum of four cross-entropy terms over digit positions.
Training adversarial images use $\varepsilon \in {0.015, 0.03}$ in equal proportion. Validation and test adversarial images use the same $\varepsilon$ set per split. Each model has its own adversarial folders under adv/vit/ and adv/cnn/.
Download
The full dataset is shipped as a single gzip-compressed tar archive data.tar.gz. After extraction the layout is
data/
βββ clean/
β βββ train/
β βββ val/
β βββ test/
βββ adv/
βββ vit/
β βββ train/
β βββ val/
β βββ test/
βββ cnn/
βββ train/
βββ val/
βββ test/
from huggingface_hub import hf_hub_download
import tarfile
archive = hf_hub_download(
repo_id="pymlex/4-captcha",
repo_type="dataset",
filename="data.tar.gz",
)
with tarfile.open(archive, "r:gz") as tar:
tar.extractall(path="data")
huggingface-cli download pymlex/4-captcha data.tar.gz --repo-type dataset
tar -xzf data.tar.gz -C data
Preview
The preview/ folder holds four sample images per split with matching labels.csv files. Use it to inspect rendering and adversarial noise before downloading the archive.
| Split | Preview path |
|---|---|
| clean train | preview/clean/train/ |
| clean val | preview/clean/val/ |
| clean test | preview/clean/test/ |
| adv vit | preview/adv/vit/{train,val,test}/ |
| adv cnn | preview/adv/cnn/{train,val,test}/ |
Code and training
Pipeline source: github.com/pymlex/4-captcha
Model checkpoints and evaluation artefacts: pymlex/4-captcha-solvers
Citation
@misc{zyukov2026_4captcha,
author = {Alex Zyukov},
title = {4-captcha: Synthetic Captcha Recognition and Adversarial Fine-tuning},
year = {2026},
howpublished = {\url{https://github.com/pymlex/4-captcha}}
}
The dataset is under GPL-3.0 license.
- Downloads last month
- 57