系列文章目录
前言
项目地址:这儿
一、安装
版本要求
Python: 3.7+
PyTorch: >=1.7.1
安装:
pip install torch torchvision torchaudio
pip install "pix2tex[gui]
注意:Pyside6 和 PyQt6 版本需要保持一致,否则会报 QT 错误
二、使用
打开 Windows 终端,输入命令:
latexocr
注意:需要将 latexocr.exe 所在路径添加到系统 Path 路径下,以便找到该可执行文件
例如:
三、
可以识别出来,如果识别有错误,可以直接在 gui 界面修改 Latex 代码,公式会实时更新,修改好之后再复制。
四、报错
Traceback (most recent call last):
File "D:\Software\miniconda3\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Software\miniconda3\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\kuanli\AppData\Roaming\Python\Python310\Scripts\latexocr.exe\__main__.py", line 7, in <module>
File "C:\Users\kuanli\AppData\Roaming\Python\Python310\site-packages\pix2tex\__main__.py", line 28, in main
main(arguments)
File "C:\Users\kuanli\AppData\Roaming\Python\Python310\site-packages\pix2tex\gui.py", line 347, in main
ex = App(arguments)
File "C:\Users\kuanli\AppData\Roaming\Python\Python310\site-packages\pix2tex\gui.py", line 28, in __init__
self.model = cli.LatexOCR(self.args)
File "D:\Software\miniconda3\lib\contextlib.py", line 79, in inner
return func(*args, **kwds)
File "C:\Users\kuanli\AppData\Roaming\Python\Python310\site-packages\pix2tex\cli.py", line 84, in __init__
self.model.load_state_dict(torch.load(self.args.checkpoint, map_location=self.args.device))
File "C:\Users\kuanli\AppData\Roaming\Python\Python310\site-packages\torch\serialization.py", line 993, in load
with _open_zipfile_reader(opened_file) as opened_zipfile:
File "C:\Users\kuanli\AppData\Roaming\Python\Python310\site-packages\torch\serialization.py", line 447, in __init__
super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
因为下载模型文件时网络错误,导致模型文件下载不全
路径下:
C:\Users\kuanli\AppData\Roaming\Python\Python310\site-packages\pix2tex\model\checkpoints文章来源:https://www.toymoban.com/news/detail-742025.html
删除未下载完的 .pth
文件,再次运行即可文章来源地址https://www.toymoban.com/news/detail-742025.html
到了这里,关于pix2tex - LaTeX OCR 安装使用记录的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!