From 48f778eeda90d42eb716a35b685e1fd497940457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E6=B4=8B=E4=B8=89=E6=B4=8B?= <1258009915@qq.com> Date: Wed, 17 Apr 2024 15:23:30 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E4=BA=86=E6=94=AF=E6=8C=81mixed=20inf?= =?UTF-8?q?erence,=20=E9=87=8D=E6=9E=84=E4=BA=86=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 2 ++ src/inference.py | 1 - src/utils/__init__.py | 1 + src/{utils.py => utils/to_katex.py} | 19 ------------------- 4 files changed, 3 insertions(+), 20 deletions(-) create mode 100644 src/utils/__init__.py rename src/{utils.py => utils/to_katex.py} (55%) diff --git a/requirements.txt b/requirements.txt index c5f254c..9bd8876 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,5 @@ onnxruntime streamlit==1.30 streamlit-paste-button + +easyocr diff --git a/src/inference.py b/src/inference.py index bc7c006..127537e 100644 --- a/src/inference.py +++ b/src/inference.py @@ -6,7 +6,6 @@ from pathlib import Path from utils import to_katex from models.ocr_model.utils.inference import inference as latex_inference from models.ocr_model.model.TexTeller import TexTeller -from utils import load_det_tex_model, load_lang_models if __name__ == '__main__': diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..ba17b40 --- /dev/null +++ b/src/utils/__init__.py @@ -0,0 +1 @@ +from .to_katex import to_katex \ No newline at end of file diff --git a/src/utils.py b/src/utils/to_katex.py similarity index 55% rename from src/utils.py rename to src/utils/to_katex.py index 7822a76..fe08a74 100644 --- a/src/utils.py +++ b/src/utils/to_katex.py @@ -1,9 +1,6 @@ import numpy as np import re -from models.ocr_model.utils.inference import inference as latex_inference - - def to_katex(formula: str) -> str: res = formula res = re.sub(r'\\mbox\{([^}]*)\}', r'\1', res) @@ -16,19 +13,3 @@ def to_katex(formula: str) -> str: if res.endswith(r'\newline'): res = res[:-8] return res - - -def load_lang_models(language: str): - ... - # language: 'ch' or 'en' - # return det_model, rec_model (or model) - - -def load_det_tex_model(): - ... - # return the loaded latex detection model - - -def mix_inference(latex_det_model, latex_rec_model, lang_model, img: np.ndarray, use_cuda: bool) -> str: - ... - # latex_inference(...)