Skip to content

Commit

Permalink
Merge pull request #12 from breezedeus/dev
Browse files Browse the repository at this point in the history
optimize the order of boxes (new version of CnSTD), and the latex result
  • Loading branch information
breezedeus committed Feb 19, 2023
2 parents e74372c + 6cb49ad commit 17c7673
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 150 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package:
rm -rf build
python setup.py sdist bdist_wheel

VERSION = 0.2
VERSION = 0.2.1
upload:
python -m twine upload dist/pix2text-$(VERSION)* --verbose

Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
![last-commit](https://img.shields.io/github/last-commit/breezedeus/pix2text)
[![Twitter](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2Fbreezedeus)](https://twitter.com/breezedeus)

[🛀🏻 在线Demo](https://huggingface.co/spaces/breezedeus/pix2text) |
[👩🏻‍💻网页版](https://p2t.behye.com) |
[💬 交流群](https://cnocr.readthedocs.io/zh/latest/contact/)

</div>
Expand All @@ -24,16 +24,18 @@
# Pix2Text (P2T)


【Update 2023.02.10: **[P2T网页版](https://p2t.behye.com)** 开放免费试用
【Update 2023.02.10: **[P2T网页版](https://p2t.behye.com)** 开放免费使用

* P2T作为Python包,对于不熟悉Python的朋友还是太不友好,所以我们也开发了 [P2T网页版](https://p2t.behye.com)
限于服务器资源有限,网页版前期只开放少量 key 供有需要的朋友使用,优先在校师生(MathPix 每月要5美元,对在校生来说还是蛮贵的)
* 更多信息[Pix2Text (P2T) 新版发布,离Mathpix又近了一大步 - 知乎](https://zhuanlan.zhihu.com/p/604999678)
* P2T作为Python包,对于不熟悉Python的朋友还是太不友好,所以我们也开发了 [P2T网页版](https://p2t.behye.com),可直接免费使用,欢迎帮忙推荐分享
* 视频介绍:[Pix2Text 新版和网页版发布,离Mathpix又近了一大步_bilibili](https://www.bilibili.com/video/BV1U24y1q7n3)
* 文字版介绍[Pix2Text (P2T) 新版发布,离Mathpix又近了一大步 - 知乎](https://zhuanlan.zhihu.com/p/604999678)

【Update 2023.02.03:**V0.2** 发布】

* 利用 **[CnSTD](https://github.com/breezedeus/cnstd)** 新版的**数学公式检测****Mathematical Formula Detection**,简称 **MFD**)能力,**P2T V0.2** 支持**识别既包含文字又包含公式的混合图片**

了解更多:[RELEASE.md](./RELEASE.md)

---


Expand Down Expand Up @@ -398,13 +400,15 @@ Options:
analyzer]
-a, --analyzer-name [mfd|layout]
使用哪个Analyzer,MFD还是版面分析 [default: mfd]
-t, --analyzer-type TEXT Analyzer使用哪个模型,'yolov7_tiny' or 'yolov7'
[default: yolov7_tiny]
-d, --device TEXT 使用 `cpu` 还是 `gpu` 运行代码,也可指定为特定gpu,如`cuda:0`
[default: cpu]
--resized-shape INTEGER 把图片宽度resize到此大小再进行处理 [default: 700]
--resized-shape INTEGER 把图片宽度resize到此大小再进行处理 [default: 600]
-i, --img-file-or-dir TEXT 输入图片的文件路径或者指定的文件夹 [required]
--save-analysis-res TEXT 把解析结果存储到此文件或目录中(如果"--img-file-or-dir"
为文件/文件夹,则"--save-analysis-res"
也应该是文件/文件夹)。取值为 `None` 表示不存储 [default: None]
--save-analysis-res TEXT 把解析结果存储到此文件或目录中(如果'--img-file-or-
dir'为文件/文件夹,则'--save-analysis-
res'也应该是文件/文件夹)。取值为 `None` 表示不存储
-l, --log-level TEXT Log Level, such as `INFO`, `DEBUG`
[default: INFO]
-h, --help Show this message and exit.
Expand Down
12 changes: 9 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Release Notes

# Update 2023.02.03:发布 **V0.2**
## Update 2023.02.19:发布 **V0.2.1**

主要变更:
* 增加后处理机制优化Latex-OCR的识别结果;
* 使用最新的 [CnSTD](https://github.com/breezedeus/cnstd)[CnOCR](https://github.com/breezedeus/cnocr),它们修复了一些bug。

## Update 2023.02.03:发布 **V0.2**

主要变更:
* 利用 **[CnSTD](https://github.com/breezedeus/cnstd)** 新版的**数学公式检测****Mathematical Formula Detection**,简称 **MFD**)能力,**P2T V0.2** 支持**识别既包含文字又包含公式的混合图片**

# Update 2022.10.21:发布 V0.1.1
## Update 2022.10.21:发布 V0.1.1

主要变更:
* Fix: remove the character which causes error on Windows

# Update 2022.09.11:发布 V0.1
## Update 2022.09.11:发布 V0.1
* 初版发布
2 changes: 1 addition & 1 deletion pix2text/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# Copyright (C) 2022, [Breezedeus](https://github.com/breezedeus).

__version__ = '0.2'
__version__ = '0.2.1'
33 changes: 24 additions & 9 deletions pix2text/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def cli():
help="使用哪个Analyzer,MFD还是版面分析",
show_default=True,
)
@click.option(
"-t",
"--analyzer-type",
type=str,
default='yolov7_tiny',
help="Analyzer使用哪个模型,'yolov7_tiny' or 'yolov7'",
show_default=True,
)
@click.option(
"-d",
"--device",
Expand All @@ -45,16 +53,19 @@ def cli():
show_default=True,
)
@click.option(
"--resized-shape", help="把图片宽度resize到此大小再进行处理", type=int, default=700,
"--resized-shape",
help="把图片宽度resize到此大小再进行处理",
type=int,
default=600,
show_default=True,
)
@click.option("-i", "--img-file-or-dir", required=True, help="输入图片的文件路径或者指定的文件夹")
@click.option(
"--save-analysis-res",
default=None,
help="把解析结果存储到此文件或目录中"
"(如果'--img-file-or-dir'为文件/文件夹,则'--save-analysis-res'也应该是文件/文件夹)。"
"取值为 `None` 表示不存储",
"(如果'--img-file-or-dir'为文件/文件夹,则'--save-analysis-res'也应该是文件/文件夹)。"
"取值为 `None` 表示不存储",
show_default=True,
)
@click.option(
Expand All @@ -67,6 +78,7 @@ def cli():
def predict(
use_analyzer,
analyzer_name,
analyzer_type,
device,
resized_shape,
img_file_or_dir,
Expand All @@ -76,7 +88,10 @@ def predict(
"""模型预测"""
logger = set_logger(log_level=log_level)

p2t = Pix2Text(analyzer_config=dict(model_name=analyzer_name), device=device)
p2t = Pix2Text(
analyzer_config=dict(model_name=analyzer_name, model_type=analyzer_type),
device=device,
)

fp_list = []
if os.path.isfile(img_file_or_dir):
Expand All @@ -88,7 +103,9 @@ def predict(
fp_list = [os.path.join(img_file_or_dir, fn) for fn in fn_list]
if save_analysis_res:
os.makedirs(save_analysis_res, exist_ok=True)
save_analysis_res = [os.path.join(save_analysis_res, 'analysis-' + fn) for fn in fn_list]
save_analysis_res = [
os.path.join(save_analysis_res, 'analysis-' + fn) for fn in fn_list
]

for idx, fp in enumerate(fp_list):
analysis_res = save_analysis_res[idx] if save_analysis_res is not None else None
Expand All @@ -104,12 +121,10 @@ def predict(

@cli.command('serve')
@click.option(
'-H', '--host', type=str, default='0.0.0.0', help='server host',
show_default=True,
'-H', '--host', type=str, default='0.0.0.0', help='server host', show_default=True,
)
@click.option(
'-p', '--port', type=int, default=8503, help='server port',
show_default=True,
'-p', '--port', type=int, default=8503, help='server port', show_default=True,
)
@click.option(
'--reload',
Expand Down
Loading

0 comments on commit 17c7673

Please sign in to comment.