API reference
Reading and annotating
Load images and labels into memory.
| read_captcha | Read one or more captcha image files into a Captcha object. |
| Captcha | Container for one or more captcha images. |
| annotate | Manual / batch annotation of captcha files. |
Datasets and preprocessing
PyTorch dataset plumbing.
| CaptchaDataset | Dataset of labeled captcha images. |
| transform_image | Load and resize image(s) to a fixed height, preserving aspect ratio. |
| encode_label | Encode a string label into a 1D LongTensor of vocab indices (no blanks). |
| decode_indices | Decode a CTC index sequence to a string. |
| pad_collate | Collate function: pads images to the max width and stacks targets. |
| DEFAULT_VOCAB |
Model
CRNN + CTC architecture.
| CRNN | Convolutional Recurrent Neural Network for variable-length text recognition. |
Training
Fit a model end-to-end.
| fit_model | Train a CRNN captcha model on a directory of labeled images. |
| FitHistory | |
| sequence_accuracy | Fraction of sequences where the full predicted string equals the target. |
Inference
Predict labels with masking and fixed-length options.
| decrypt | decrypt: predict labels for captcha images using a trained CRNN model. |
Local checkpoints
Save and load local .pt files.
| save_model | Persist a CRNN model to disk. |
| load_model | Load a CRNN model previously saved with :func:save_model. |
Hugging Face Hub
Publish and fetch models from the Hub.
| from_pretrained | Download and load a txtcaptcha CRNN from the Hugging Face Hub. |
| save_pretrained | Write model.safetensors + config.json (+ optional README.md) |
| push_to_hub | Create repo_id if needed and upload weights, config and model card. |
| DEFAULT_REPO_ID |
Datasets (download)
Fetch labeled captcha datasets published by the project.
| download_dataset | Download (and optionally unzip) one of the R captcha datasets. |
| available_datasets | List of dataset names published in the R captcha release. |
Live captcha download
Fetch fresh captchas from live sources for evaluation.
| download_captchas | Download up to n captchas from source into dest_dir. |
| available_sources | Sorted list of registered source names. |
| DownloadError | Raised when a captcha cannot be fetched or parsed from a source. |