pix2tex - LaTeX OCR 基于图像的公式识别 实践笔记

在线LaTex 公式编辑

强大的是:这个竟然支持图像识别公式,太棒了。 好吧,它收费了。我决定要抛弃它的图像识别功能了了。

由于该在线图像识别公式的应用已经收费。因此我尝试了如下开源库用来图像识别公式:

代码仓库: https://github.com/lukas-blecher/LaTeX-OCR

这个项目的目标是创建一个基于学习的系统,该系统获取数学公式的图像并返回相应的 LaTeX 代码。

image

1. 安装

要求:Python 3.7+

pip install pix2tex[gui] -i https://pypi.tuna.tsinghua.edu.cn/simple

安装成功!

2. 运行

Thanks to @katie-lim, you can use a nice user interface as a quick way to get the model prediction. Just call the GUI with latexocr. From here you can take a screenshot and the predicted latex code is rendered using MathJax and copied to your clipboard.

我使用的 方式 2。 命令行 运行:

latexocr

报错: module 'numpy' has no attribute 'object'。

我的 numpy 版本:'1.24.1'。

解决方案:卸载重装支持的。参考:module 'numpy' has no attribute 'object'

pip install numpy==1.23.4  -i https://pypi.tuna.tsinghua.edu.cn/simple

当然也可以选择,还是使用当前版本的numpy,自己把包里面的这些不支持操作都改了,只是比较麻烦。

然后执行: latexocr, 继续报错:

requests.exceptions.SSLError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /lukas-blecher/LaTeX-OCR/releases/download/v0.0.1/weights.pth (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))

好吧,这是因为我开了github 加速代理。把代理关了就可以下载预训练权重了。

下载速度慢的问题,可以开 vpn 或者 迅雷 解决。

下载链接:https://github.com/lukas-blecher/LaTeX-OCR/releases/download/v0.0.1/weights.pth

放到 推荐的目录中:

C:\ProgramData\Miniconda3\envs\xx\lib\site-packages\pix2tex\model\checkpoints

然后运行: latexocr

完美打开!

drawing
posted @ 2023-02-17 14:53  cold_moon  阅读(1921)  评论(0编辑  收藏  举报