An pytorch ocr base library for MBBank lib
Project description
OCR Model Training and Prediction
This project is designed to train and use an Optical Character Recognition (OCR) model for recognizing characters in CAPTCHA images.
Project Structure
mb_capcha_ocr/: Contains the core OCR model and prediction logic.train_model/: Contains the training script for the OCR model.
Installation and Setup for Training
-
Clone the repository:
git clone https://github.com/thedtvn/mbbank-capcha-ocr cd mbbank-capcha-ocr cd train_model
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
-
Install the required dependencies:
pip install -r train_requirements.txt
Training the Model
-
Place your training and testing images in the
dataset/directory. The images should be named in the format{label}.(png|jpg|jpeg). -
Run the training script:
python train.py -
The trained model will be saved as
model.onnxin the directory.
Using the Model for Prediction
from PIL import Image
from mb_capcha_ocr import OcrModel
model = OcrModel() # model_path optional if using custom model
img = Image.open("path_to_image.png")
predicted_text = model.predict(img)
print(predicted_text)
Files
train_model/train.py: Script to train the OCR model.mb_capcha_ocr/predict.py: Script to predict text from an image using the trained OCR model.requirements.txt: List of dependencies required for the project.
Dependencies
- Python 3.x
- numpy
- onnxruntime
- Pillow
Dependencies Training
- Python 3.x
- torch
- torchvision
- matplotlib
- Pillow
- onnx
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Credits
Best thanks to CookieGMVN for providing the dataset V1 V2.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 mb_capcha_ocr-0.1.5-py3-none-any.whl.
File metadata
- Download URL: mb_capcha_ocr-0.1.5-py3-none-any.whl
- Upload date:
- Size: 44.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
479fdc55451056a9e5d92abb9afb8c04b64effe1966fcb5e52ef7ae034e0fe09
|
|
| MD5 |
7ed5f2c83f19b629f90e75628e84d655
|
|
| BLAKE2b-256 |
e950a0ae095ad9487aabc7cf4d1d555c3082f8688cb22bd69b129cdc873eb49f
|