Spaces:
Sleeping
Sleeping
| import logging | |
| import sys | |
| import paddle | |
| from paddleocr import PaddleOCR | |
| # check GPU | |
| # gpu = True if torch.cuda.is_available() else False | |
| GPU = paddle.device.is_compiled_with_cuda() | |
| IMAGE_FORMAT = (".bmp", ".gif", ".jpeg", ".jpg", ".png") | |
| OUT_DIR = "data/output/" | |
| RECOGNITION_THRESHOLD = 0.90 | |
| FONTPATH = "fonts/GenShinGothic-Bold.ttf" | |
| """ Models list | |
| # Detection: | |
| ch_PP-OCRv4_det: lightweight model, | |
| supporting Chinese, English, multilingual | |
| ch_PP-OCRv4_server_det: server model, | |
| supporting Chinese, English, multilingual | |
| en_PP-OCRv3_det: lightweight model, | |
| supporting English, multilingual text detection | |
| # Recognition: | |
| ch_PP-OCRv4_rec: lightweight model, | |
| supporting Chinese, English, multilingual text recognition. | |
| dict is attached. | |
| japan_PP-OCRv4_rec: Lightweight model for Japanese recognition | |
| Need dict: ppocr/utils/dict/japan_dict.txt | |
| """ | |
| OCR_JA = PaddleOCR( | |
| det_model_dir="models/detection/ch_PP-OCRv4_server_det/", | |
| rec_model_dir="models/recognition/japan_PP-OCRv4_rec/", | |
| rec_char_dict_path="models/char_dict/japan_dict.txt", | |
| cls_model_dir="models/cls/ch_ppocr_mobile_v2.0_cls", | |
| use_angle_cls=True, | |
| use_gpu=GPU, | |
| show_log=False, | |
| ) | |
| OCR_ML = PaddleOCR( | |
| det_model_dir="models/detection/ch_PP-OCRv4_server_det/", | |
| rec_model_dir="models/recognition/ch_PP-OCRv4_rec/", | |
| # rec_char_dict_path="models/char_dict/japan_dict.txt", | |
| cls_model_dir="models/cls/ch_ppocr_mobile_v2.0_cls", | |
| use_angle_cls=True, | |
| use_gpu=GPU, | |
| show_log=False, | |
| ) | |
| # MARKDOWN | |
| TEXT_SCALE = 1 | |
| MAX_CHAR = 40 # Klever Wiki | |
| # TODO: add logging | |
| """Define logging""" | |
| logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) | |
| # logger_value = logging.getLogger("Value") | |
| # logger_value.disabled() | |
| # logger_date = logging.getLogger("Date") | |
| # logger_date.disable() | |