# 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
```bash
pip install vietcombank-captcha
```
### Using UV (recommended)
```bash
uv pip install vietcombank-captcha
```
## Quick Start
### Basic Usage
```python
from vietcombank_captcha import predict
# Predict from image file
captcha_code = predict("captcha.png")
print(f"Predicted code: {captcha_code}")
```
### Advanced Usage
```python
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
```python
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
```python
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
```bash
# 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](https://github.com/bangprovn/vietcombank-captcha/issues).
Raw data
{
"_id": null,
"home_page": null,
"name": "vietcombank-captcha",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "captcha, machine-learning, ocr, onnx, vietcombank",
"author": null,
"author_email": "bangprovn <me@bangprovn.com>",
"download_url": "https://files.pythonhosted.org/packages/ad/52/63e6dcbb9fb533243991245135921cff947b83777a8b48c9e2bba9dd5254/vietcombank_captcha-0.1.0.tar.gz",
"platform": null,
"description": "# vietcombank-captcha\n\nA lightweight Python library for solving Vietcombank CAPTCHA images using ONNX runtime. This project is purely educational. Using synthetic data from various sources.\n\n## Features\n\n- \ud83d\ude80 Fast inference using ONNX runtime\n- \ud83c\udfaf High accuracy (>95% on test set)\n- \ud83d\udd27 Simple API with minimal dependencies\n- \ud83d\udce6 Lightweight package (~2.2MB model)\n- \ud83d\uddbc\ufe0f Supports multiple input formats (file path, PIL Image, numpy array)\n- \ud83d\udd22 Batch prediction support\n- \ud83c\udf4e Optimized for Apple M Chip\n\n## Installation\n\n### Using pip\n\n```bash\npip install vietcombank-captcha\n```\n\n### Using UV (recommended)\n\n```bash\nuv pip install vietcombank-captcha\n```\n\n## Quick Start\n\n### Basic Usage\n\n```python\nfrom vietcombank_captcha import predict\n\n# Predict from image file\ncaptcha_code = predict(\"captcha.png\")\nprint(f\"Predicted code: {captcha_code}\")\n```\n\n### Advanced Usage\n\n```python\nfrom vietcombank_captcha import VietcombankCaptcha\n\n# Initialize predictor\npredictor = VietcombankCaptcha()\n\n# Predict single image with confidence scores\ncode, confidences = predictor.predict_with_confidence(\"captcha.png\")\nprint(f\"Code: {code}\")\nprint(f\"Confidence per digit: {confidences}\")\n\n# Batch prediction\nimages = [\"captcha1.png\", \"captcha2.png\", \"captcha3.png\"]\nresults = predictor.predict_batch(images)\nprint(f\"Results: {results}\")\n\n# With confidence scores\nresults_with_conf = predictor.predict_batch(images, return_confidence=True)\nfor code, conf in results_with_conf:\n print(f\"Code: {code}, Avg confidence: {sum(conf)/len(conf):.2f}\")\n```\n\n### Using PIL Image\n\n```python\nfrom PIL import Image\nfrom vietcombank_captcha import predict\n\n# Load image with PIL\nimg = Image.open(\"captcha.png\")\ncode = predict(img)\nprint(f\"Code: {code}\")\n```\n\n### Using numpy array\n\n```python\nimport numpy as np\nfrom vietcombank_captcha import predict\n\n# From numpy array (H, W, 3) RGB format\nimg_array = np.array(...) # Your image array\ncode = predict(img_array)\nprint(f\"Code: {code}\")\n```\n\n## Command Line Interface\n\n```bash\n# Predict single image\nvietcombank-captcha predict image.png\n\n# Predict with confidence scores\nvietcombank-captcha predict image.png --confidence\n\n# Batch prediction\nvietcombank-captcha predict-batch ./captcha_folder/\n\n# Use custom model\nvietcombank-captcha predict image.png --model custom_model.onnx\n```\n\n## API Reference\n\n### `VietcombankCaptcha`\n\nMain predictor class.\n\n#### `__init__(model_path: Optional[str] = None)`\nInitialize the predictor with an optional custom model path.\n\n#### `predict(image) -> str`\nPredict CAPTCHA code from an image.\n\n#### `predict_with_confidence(image) -> Tuple[str, List[float]]`\nPredict with confidence scores for each digit.\n\n#### `predict_batch(images, return_confidence=False)`\nPredict multiple images at once.\n\n### `predict(image, model_path=None) -> str`\n\nConvenience function for single prediction.\n\n## Requirements\n\n- Python >= 3.8\n- numpy >= 1.20.0\n- Pillow >= 9.0.0\n- onnxruntime >= 1.16.0\n\n## Model Information\n\n- Input: RGB image (155x50 pixels)\n- Output: 5-digit code (0-9)\n- Model size: ~2.2MB\n- Architecture: Multi-output CNN optimized for CAPTCHA recognition\n\n## Performance\n\n- Inference time: ~5-10ms per image (CPU)\n- Accuracy: >95% on test dataset\n- Memory usage: <100MB\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Support\n\nFor issues and questions, please use the [GitHub issue tracker](https://github.com/bangprovn/vietcombank-captcha/issues).",
"bugtrack_url": null,
"license": "MIT",
"summary": "Lightweight CAPTCHA predictor for Vietcombank using ONNX",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/bangprovn/vietcombank-captcha",
"Issues": "https://github.com/bangprovn/vietcombank-captcha/issues"
},
"split_keywords": [
"captcha",
" machine-learning",
" ocr",
" onnx",
" vietcombank"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6d10233d133991566fcc36ba57d2c13d949cae30f99d13eca286eeee246cf734",
"md5": "05b86f7f2b4756e7f1fe7a6ca1bc3068",
"sha256": "2fec03cb60e412a409b29bd0e517359cd94b4533a15225ada879eb79042c4397"
},
"downloads": -1,
"filename": "vietcombank_captcha-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "05b86f7f2b4756e7f1fe7a6ca1bc3068",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 2038319,
"upload_time": "2025-08-06T04:43:17",
"upload_time_iso_8601": "2025-08-06T04:43:17.362108Z",
"url": "https://files.pythonhosted.org/packages/6d/10/233d133991566fcc36ba57d2c13d949cae30f99d13eca286eeee246cf734/vietcombank_captcha-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ad5263e6dcbb9fb533243991245135921cff947b83777a8b48c9e2bba9dd5254",
"md5": "e2f59208152477128435e4f2d8f7b29e",
"sha256": "9a235aacedb663c29fb195f7c1844d5aaf5e366b8c6687dd781558c90e782e5d"
},
"downloads": -1,
"filename": "vietcombank_captcha-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "e2f59208152477128435e4f2d8f7b29e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 2038095,
"upload_time": "2025-08-06T04:43:20",
"upload_time_iso_8601": "2025-08-06T04:43:20.669390Z",
"url": "https://files.pythonhosted.org/packages/ad/52/63e6dcbb9fb533243991245135921cff947b83777a8b48c9e2bba9dd5254/vietcombank_captcha-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-06 04:43:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bangprovn",
"github_project": "vietcombank-captcha",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "vietcombank-captcha"
}