From c711566b9762d7df851f68c2401a482047cf412c Mon Sep 17 00:00:00 2001 From: breezedeus Date: Tue, 4 Jun 2024 18:07:14 +0800 Subject: [PATCH 1/2] fix: configs were incorrectly passed when it was called multiple times. --- pix2text/ocr_engine.py | 2 ++ pix2text/text_formula_ocr.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pix2text/ocr_engine.py b/pix2text/ocr_engine.py index 5d8848c..cf0ce09 100644 --- a/pix2text/ocr_engine.py +++ b/pix2text/ocr_engine.py @@ -2,6 +2,7 @@ # [Pix2Text](https://github.com/breezedeus/pix2text): an Open-Source Alternative to Mathpix. # Copyright (C) 2022-2024, [Breezedeus](https://www.breezedeus.com). import string +from copy import deepcopy from typing import Sequence, List, Optional import numpy as np @@ -175,6 +176,7 @@ def ocr( def prepare_ocr_engine(languages: Sequence[str], ocr_engine_config): + ocr_engine_config = deepcopy(ocr_engine_config) if ocr_engine_config else {} if len(set(languages).difference({'en', 'ch_sim'})) == 0: from cnocr import CnOcr diff --git a/pix2text/text_formula_ocr.py b/pix2text/text_formula_ocr.py index 02de6b3..3d149c8 100644 --- a/pix2text/text_formula_ocr.py +++ b/pix2text/text_formula_ocr.py @@ -157,8 +157,8 @@ def prepare_configs( ): def _to_default(_conf, _def_val): if not _conf: - _conf = _def_val - return _conf + _conf = deepcopy(_def_val) + return deepcopy(_conf) mfd_config = _to_default(mfd_config, DEFAULT_CONFIGS['mfd']) # FIXME From 2ea128f7e985c2592b5eb69c23832b04e701ee80 Mon Sep 17 00:00:00 2001 From: breezedeus Date: Tue, 4 Jun 2024 18:11:56 +0800 Subject: [PATCH 2/2] update doc & bump version --- docs/RELEASE.md | 10 ++++++++++ pix2text/__version__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/RELEASE.md b/docs/RELEASE.md index 6a9ed67..fd65dda 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -1,5 +1,15 @@ # Release Notes +## Update 2024.06.04:**V1.1.0.6** Released + +Major changes: + +* Fix: The Text OCR incorrectly carried over the configuration from previous calls when it was called multiple times. + +主要变更: + +* 修复 bug:Text OCR 多次调用时错误沿用了之前的配置信息。 + ## Update 2024.05.27:**V1.1.0.5** Released Major changes: diff --git a/pix2text/__version__.py b/pix2text/__version__.py index 48ea715..bacd869 100644 --- a/pix2text/__version__.py +++ b/pix2text/__version__.py @@ -2,4 +2,4 @@ # [Pix2Text](https://github.com/breezedeus/pix2text): an Open-Source Alternative to Mathpix. # Copyright (C) 2022-2024, [Breezedeus](https://www.breezedeus.com). -__version__ = '1.1.0.5' +__version__ = '1.1.0.6'