Spaces:
Running
Running
Commit
·
84028a2
1
Parent(s):
0aff688
update copyright year to 2025, update Pix2Text version to 1.1.4, and modify model dropdown options
Browse files- app.py +6 -24
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# coding: utf-8
|
| 2 |
# [Pix2Text](https://github.com/breezedeus/pix2text): an Open-Source Alternative to Mathpix.
|
| 3 |
-
# Copyright (C) 2022-
|
| 4 |
|
| 5 |
import os
|
| 6 |
import json
|
|
@@ -31,24 +31,6 @@ OUTPUT_RESULT_DIR = Path('./output-results')
|
|
| 31 |
OUTPUT_RESULT_DIR.mkdir(exist_ok=True)
|
| 32 |
|
| 33 |
|
| 34 |
-
def prepare_mfd_model():
|
| 35 |
-
target_fp = './yolov7-model/mfd-yolov7-epoch224-20230613.pt'
|
| 36 |
-
if os.path.exists(target_fp):
|
| 37 |
-
return target_fp
|
| 38 |
-
HF_TOKEN = os.environ.get('HF_TOKEN')
|
| 39 |
-
local_path = hf_hub_download(
|
| 40 |
-
repo_id='breezedeus/paid-models',
|
| 41 |
-
subfolder='cnstd/1.2',
|
| 42 |
-
filename='yolov7-model-20230613.zip',
|
| 43 |
-
repo_type="model",
|
| 44 |
-
cache_dir='./',
|
| 45 |
-
token=HF_TOKEN,
|
| 46 |
-
)
|
| 47 |
-
with zipfile.ZipFile(local_path) as zf:
|
| 48 |
-
zf.extractall('./')
|
| 49 |
-
return target_fp
|
| 50 |
-
|
| 51 |
-
|
| 52 |
def get_p2t_model(lan_list: list, mfd_model_name: str, mfr_model_name: str):
|
| 53 |
mfd_config = dict(model_name=mfd_model_name, model_backend='onnx') # 声明 MFD 的初始化参数
|
| 54 |
formula_config = dict(model_name=mfr_model_name, model_backend='onnx') # 声明 MFR 的初始化参数
|
|
@@ -172,7 +154,7 @@ If useful, please help to **star 🌟 [Pix2Text](https://github.com/breezedeus/p
|
|
| 172 |
|
| 173 |
with gr.Blocks() as demo:
|
| 174 |
gr.HTML(
|
| 175 |
-
f'<h1 style="text-align: center; margin-bottom: 1rem;"><a href="https://github.com/breezedeus/pix2text" target="_blank">Pix2Text V1.1.
|
| 176 |
)
|
| 177 |
with gr.Row(equal_height=False):
|
| 178 |
with gr.Column(min_width=200, variant='panel', scale=3):
|
|
@@ -186,13 +168,13 @@ If useful, please help to **star 🌟 [Pix2Text](https://github.com/breezedeus/p
|
|
| 186 |
)
|
| 187 |
mfd_model_name = gr.Dropdown(
|
| 188 |
label='MFD Models',
|
| 189 |
-
choices=['mfd', 'mfd-advanced', 'mfd-pro'],
|
| 190 |
-
value='mfd-pro',
|
| 191 |
)
|
| 192 |
mfr_model_name = gr.Dropdown(
|
| 193 |
label='MFR Models',
|
| 194 |
-
choices=['mfr', 'mfr-pro', 'mfr-plus'],
|
| 195 |
-
value='mfr-pro',
|
| 196 |
)
|
| 197 |
rec_type = gr.Dropdown(
|
| 198 |
label='file_type',
|
|
|
|
| 1 |
# coding: utf-8
|
| 2 |
# [Pix2Text](https://github.com/breezedeus/pix2text): an Open-Source Alternative to Mathpix.
|
| 3 |
+
# Copyright (C) 2022-2025, [Breezedeus](https://www.breezedeus.com).
|
| 4 |
|
| 5 |
import os
|
| 6 |
import json
|
|
|
|
| 31 |
OUTPUT_RESULT_DIR.mkdir(exist_ok=True)
|
| 32 |
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def get_p2t_model(lan_list: list, mfd_model_name: str, mfr_model_name: str):
|
| 35 |
mfd_config = dict(model_name=mfd_model_name, model_backend='onnx') # 声明 MFD 的初始化参数
|
| 36 |
formula_config = dict(model_name=mfr_model_name, model_backend='onnx') # 声明 MFR 的初始化参数
|
|
|
|
| 154 |
|
| 155 |
with gr.Blocks() as demo:
|
| 156 |
gr.HTML(
|
| 157 |
+
f'<h1 style="text-align: center; margin-bottom: 1rem;"><a href="https://github.com/breezedeus/pix2text" target="_blank">Pix2Text V1.1.4</a>{title}</h1>'
|
| 158 |
)
|
| 159 |
with gr.Row(equal_height=False):
|
| 160 |
with gr.Column(min_width=200, variant='panel', scale=3):
|
|
|
|
| 168 |
)
|
| 169 |
mfd_model_name = gr.Dropdown(
|
| 170 |
label='MFD Models',
|
| 171 |
+
choices=['mfd-1.5', 'mfd-advanced-1.5', 'mfd-pro-1.5', 'mfd', 'mfd-advanced', 'mfd-pro'],
|
| 172 |
+
value='mfd-pro-1.5',
|
| 173 |
)
|
| 174 |
mfr_model_name = gr.Dropdown(
|
| 175 |
label='MFR Models',
|
| 176 |
+
choices=['mfr-1.5', 'mfr-pro-1.5', 'mfr', 'mfr-pro', 'mfr-plus'],
|
| 177 |
+
value='mfr-pro-1.5',
|
| 178 |
)
|
| 179 |
rec_type = gr.Dropdown(
|
| 180 |
label='file_type',
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
--extra-index-url https://pypi.org/simple
|
| 2 |
|
| 3 |
pyyaml
|
| 4 |
-
pix2text[multilingual]>=1.1.
|
|
|
|
| 1 |
--extra-index-url https://pypi.org/simple
|
| 2 |
|
| 3 |
pyyaml
|
| 4 |
+
pix2text[multilingual]>=1.1.4
|