vietcombank-captcha
A lightweight Python library for solving Vietcombank CAPTCHA images using ONNX runtime. This project is purely educational. Using synthetic data from various sources.
Features
- 🚀 Fast inference using ONNX runtime
- 🎯 High accuracy (>95% on test set)
- 🔧 Simple API with minimal dependencies
- 📦 Lightweight package (~2.2MB model)
- 🖼️ Supports multiple input formats (file path, PIL Image, numpy array)
- 🔢 Batch prediction support
- 🍎 Optimized for Apple M Chip
Installation
Using pip
pip install vietcombank-captcha
Using UV (recommended)
uv pip install vietcombank-captcha
Quick Start
Basic Usage
from vietcombank_captcha import predict
# Predict from image file
captcha_code = predict("captcha.png")
print(f"Predicted code: {captcha_code}")
Advanced Usage
from vietcombank_captcha import VietcombankCaptcha
# Initialize predictor
predictor = VietcombankCaptcha()
# Predict single image with confidence scores
code, confidences = predictor.predict_with_confidence("captcha.png")
print(f"Code: {code}")
print(f"Confidence per digit: {confidences}")
# Batch prediction
images = ["captcha1.png", "captcha2.png", "captcha3.png"]
results = predictor.predict_batch(images)
print(f"Results: {results}")
# With confidence scores
results_with_conf = predictor.predict_batch(images, return_confidence=True)
for code, conf in results_with_conf:
print(f"Code: {code}, Avg confidence: {sum(conf)/len(conf):.2f}")
Using PIL Image
from PIL import Image
from vietcombank_captcha import predict
# Load image with PIL
img = Image.open("captcha.png")
code = predict(img)
print(f"Code: {code}")
Using numpy array
import numpy as np
from vietcombank_captcha import predict
# From numpy array (H, W, 3) RGB format
img_array = np.array(...) # Your image array
code = predict(img_array)
print(f"Code: {code}")
Command Line Interface
# Predict single image
vietcombank-captcha predict image.png
# Predict with confidence scores
vietcombank-captcha predict image.png --confidence
# Batch prediction
vietcombank-captcha predict-batch ./captcha_folder/
# Use custom model
vietcombank-captcha predict image.png --model custom_model.onnx
API Reference
VietcombankCaptcha
Main predictor class.
__init__(model_path: Optional[str] = None)
Initialize the predictor with an optional custom model path.
predict(image) -> str
Predict CAPTCHA code from an image.
predict_with_confidence(image) -> Tuple[str, List[float]]
Predict with confidence scores for each digit.
predict_batch(images, return_confidence=False)
Predict multiple images at once.
predict(image, model_path=None) -> str
Convenience function for single prediction.
Requirements
- Python >= 3.8
- numpy >= 1.20.0
- Pillow >= 9.0.0
- onnxruntime >= 1.16.0
Model Information
- Input: RGB image (155x50 pixels)
- Output: 5-digit code (0-9)
- Model size: ~2.2MB
- Architecture: Multi-output CNN optimized for CAPTCHA recognition
Performance
- Inference time: ~5-10ms per image (CPU)
- Accuracy: >95% on test dataset
- Memory usage: <100MB
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions, please use the GitHub issue tracker.
Metadata
Release files for vietcombank-captcha 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vietcombank_captcha-0.1.0.tar.gz | 2.0 MB | Without provenance | Details for vietcombank_captcha-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vietcombank_captcha-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for vietcombank_captcha-0.1.0-py3-none-any.whl |
Total release size: 4.1 MB
Release files / vietcombank_captcha-0.1.0.tar.gz
| Download URL | vietcombank_captcha-0.1.0.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a235aacedb663c29fb195f7c1844d5aaf5e366b8c6687dd781558c90e782e5d
|
|
BLAKE2b-256 checksum How to use checksums |
ad5263e6dcbb9fb533243991245135921cff947b83777a8b48c9e2bba9dd5254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / vietcombank_captcha-0.1.0-py3-none-any.whl
| Download URL | vietcombank_captcha-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fec03cb60e412a409b29bd0e517359cd94b4533a15225ada879eb79042c4397
|
|
BLAKE2b-256 checksum How to use checksums |
6d10233d133991566fcc36ba57d2c13d949cae30f99d13eca286eeee246cf734
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for vietcombank-captcha 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.