---
title: MixTex-ZhEn-Latex-OCR
canonical_url: "https://www.modelscope.cn/models/MixTeX/MixTex-ZhEn-Latex-OCR"
md_url: "https://www.modelscope.cn/models/MixTeX/MixTex-ZhEn-Latex-OCR.md"
repository: MixTeX/MixTex-ZhEn-Latex-OCR
last_updated: 2024-07-31
license: apache-2.0
model_type:
  - vision-encoder-decoder
architectures:
  - VisionEncoderDecoderModel
parameters: 85.9M
tensor_type:
  - F16
  - I64
library_name:
  - transformer
  - safetensors
downloads: 283
stars: 2
---

# MixTex-ZhEn-Latex-OCR

> MixTex-ZhEn-Latex-OCR - MixTeX 在 ModelScope 开源的模型。MixTeX 是一款Swin+Roberta的多模态 LaTeX 识别小程序，由我们从数据收集模型搭建训练部署一条龙完成，能够在本地离线环境下进行高效的 CPU 推理。无论是 LaTeX 公式、表格，还是混合文字，MixTeX 都能轻松识别，并且支持中英文双语处理。

MixTeX/MixTex-ZhEn-Latex-OCR 是 ModelScope 魔搭社区上的 85.9M 参数机器学习模型，采用 apache-2.0 许可。

- **Repository**: MixTeX/MixTex-ZhEn-Latex-OCR
- **License**: apache-2.0
- **Parameters**: 85.9M
- **Downloads**: 283
- **Stars**: 2
- **Last updated**: 2024-07-31

Source: https://www.modelscope.cn/models/MixTeX/MixTex-ZhEn-Latex-OCR

---

已经发布win客户端本地离线cpu推理exe，可以在github上下载。
或者直接在Files里下载zip文件解压,直接运行exe即可（免安装）。

The win client local offline CPU inference exe has been released and can be downloaded on github.

Github: https://github.com/RQLuo/MixTeX?tab=readme-ov-file

# 使用方法 Usage instructions：
```python
from transformers import AutoTokenizer, VisionEncoderDecoderModel, AutoImageProcessor
from PIL import Image
import requests

feature_extractor = AutoImageProcessor.from_pretrained("MixTex/ZhEn-Latex-OCR")
tokenizer = AutoTokenizer.from_pretrained("MixTex/ZhEn-Latex-OCR", max_len=296)
model = VisionEncoderDecoderModel.from_pretrained("MixTex/ZhEn-Latex-OCR")

imgen = Image.open(requests.get('https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/eOAym7FZDsjic_8ptsC-H.png', stream=True).raw)
#imgzh = Image.open(requests.get('https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/m-oVg8dsQbQZ1fDWbwKtO.png', stream=True).raw)
print(tokenizer.decode(model.generate(feature_extractor(imgen, return_tensors="pt").pixel_values)[0]).replace('\\[','\\begin{align*}').replace('\\]','\\end{align*}'))
```

colab: https://colab.research.google.com/drive/1vj3GKTmHcVor7FRKyk254nXEi9Lu_dhL?usp=sharing 


# 样例 Dataset example：

![image/png](https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/eOAym7FZDsjic_8ptsC-H.png)

![image/png](https://cdn-uploads.huggingface.co/production/uploads/62dbaade36292040577d2d4f/m-oVg8dsQbQZ1fDWbwKtO.png)

I will release a small portion of the generated synthetic dataset and the data collection methods.

# 补充 Supplementary information：
建议图片尺寸：大约 (400, 500), (H, W)。
建议输出字数：大约100－300个tokens。
Latex 环境：

Suggested image dimensions: approximately (400, 500), (H, W).
Recommended output length: approximately 100-300 tokens.
LaTeX environment:

```
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{stmaryrd}
\usepackage{color}
```
