Skip to content

Commit c02005d

Browse files
committed
feat: update version to 0.2.3 and refactor captcha processing to use OcrModel
1 parent d9ada95 commit c02005d

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

README.MD

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# MBBank API for Python
2-
A unofficially light weight Python Api for the "Military Commercial Joint Stock Bank" personal account
2+
A unofficially lightweight Python Api for the "Military Commercial Joint Stock Bank" personal account
33

44
## Why we have this lib ?
55

66
Because I don't want to lose money on some api services like [casso.vn](https://casso.vn/) or [payos.vn](https://payos.vn/)
77
when have freemium tier but with limit :>
88

9-
what you need that it use this lib to make your own code so you can use it free forever
9+
What you need that it use this lib to make your own code so you can use it free forever
1010

1111
[Documentation & FAQ](http://mbbank.rtfd.io/)
1212

1313
## Requires
14-
- [pytorch with cuda](https://pytorch.org/get-started/locally/#start-locally) (optional if you want to use cuda gpu)
14+
- [onnx with cuda](https://onnxruntime.ai/getting-started) (optional if you want to use cuda gpu)
1515

1616
- python3
1717

@@ -29,4 +29,6 @@ what you need that it use this lib to make your own code so you can use it free
2929

3030
- [MBBank JS API](https://github.com/CookieGMVN/MBBank)
3131

32+
- [MBBank OCR](https://github.com/thedtvn/mbbank-capcha-ocr)
33+
3234
![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fthedtvn%2FMBBank&count_bg=%2379C83D&title_bg=%23555555&icon=python.svg&icon_color=%23E7E7E7&title=Views+Counter&edge_flat=false)

docs/index.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ when have freemium tier but with limit :>
99
what you need that it use this lib to make your own code so you can use it free forever
1010

1111
## Requires
12-
- [pytorch with cuda](https://pytorch.org/get-started/locally/#start-locally) (optional if you want to use cuda gpu)
12+
- [onnx with cuda](https://onnxruntime.ai/getting-started) (optional if you want to use cuda gpu)
1313

1414
- python3
1515

@@ -35,4 +35,8 @@ These pages go into great detail about everything the API can do.
3535
3636
- Will my account get banned if i use this lib ?
3737

38-
> I can not guarantee that so use it with your own risk.
38+
> I can not guarantee that so use it with your own risk.
39+
40+
- Can i run ocr model on cpu ?
41+
42+
> Yes, you can. but it maybe will be slower than using gpu (cuda)

mbbank/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from .wasm_helper import wasm_encrypt
44
from .capcha_ocr import CapchaProcessing, CapchaOCR
55

6-
__version__ = '0.2.2'
6+
__version__ = '0.2.3'

mbbank/capcha_ocr.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import io
2-
from mb_capcha_ocr import predict
2+
from mb_capcha_ocr import OcrModel
33
from PIL import Image
44

55

@@ -34,8 +34,16 @@ class CapchaOCR(CapchaProcessing):
3434
"""
3535
Torch based OCR for capcha processing
3636
https://pypi.org/project/mb-capcha-ocr/
37+
38+
Args:
39+
model_path (str, optional): path to model file
3740
"""
3841

42+
def __init__(self, model_path: str = None):
43+
super().__init__()
44+
# loading model will take about 1-3 seconds
45+
self.model = OcrModel(model_path)
46+
3947
def process_image(self, img: bytes) -> str:
4048
"""
4149
Process image and return text
@@ -47,7 +55,7 @@ def process_image(self, img: bytes) -> str:
4755
success (str): text from image
4856
"""
4957
image = Image.open(io.BytesIO(img))
50-
text = predict(image)
58+
text = self.model.predict(image)
5159
return text
5260

5361

0 commit comments

Comments
 (0)