PP-FormulaNet is an advanced formula recognition model developed by the PaddleOCR Team. The PP-FormulaNet includes multiple versions: L, and S, where PP-FormulaNet-S uses PP-HGNetV2-B4 as its backbone network. Through parallel masking and model distillation techniques, it significantly improves inference speed while maintaining high recognition accuracy, making it suitable for applications requiring fast inference. The key accuracy metrics are as follow:
Model
Backbone
En-BLEU↑
Zh-BLEU(%)↑
GPU Inference Time (ms)
UniMERNet
Donut Swin
85.91
43.50
2266.96
PP-FormulaNet-S
PPHGNetV2_B4
87.00
45.71
202.25
PP-FormulaNet-L
Vary_VIT_B
90.36
45.78
1976.52
PP-FormulaNet_plus-S
PPHGNetV2_B4
88.71
53.32
191.69
PP-FormulaNet_plus-M
PPHGNetV2_B6
91.45
89.76
1301.56
PP-FormulaNet_plus-L
Vary_VIT_B
92.22
90.64
1745.25
LaTeX-OCR
Hybrid ViT
74.55
39.96
1244.61
Note: En-BLEU and Zh-BLEU (%) represent the BLEU scores for English formulas and Chinese formulas, respectively. The evaluation dataset for English formulas includes simple and complex formulas from UniMERNet, as well as simple, intermediate, and complex formulas from PaddleX’s internally developed dataset. The evaluation dataset for Chinese formulas comes from PaddleX’s internally developed Chinese formula dataset.
Quick Start
Installation
PaddlePaddle
Please refer to the following commands to install PaddlePaddle using pip:
# for CUDA11.8
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
# for CUDA12.6
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
# for CPU
python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
You can also integrate the model inference of the formula recognition module into your project. Before running the following code, please download the
sample image
to your local machine.
from paddleocr import FormulaRecognition
model = FormulaRecognition(model_name="PP-FormulaNet-S")
output = model.predict(input="4kkIUGxXMGozIg6U1BIxZ.png", batch_size=1)
for res in output:
res.print()
res.save_to_img(save_path="./output/")
res.save_to_json(save_path="./output/res.json")
Note: If you need to visualize the formula recognition module, you must install the LaTeX rendering environment by running the following command. Currently, visualization is only supported on Ubuntu. Other environments are not supported for now. For complex formulas, the LaTeX result may contain advanced representations that may not render successfully in Markdown or similar environments:
For details about usage command and descriptions of parameters, please refer to the
Document
.
Pipeline Usage
The ability of a single model is limited. But the pipeline consists of several models can provide more capacity to resolve difficult problems in real-world scenarios.
Formula Recognition Pipeline
The formula recognition pipeline is designed to solve formula recognition tasks by extracting formula information from images and outputting it in LaTeX source code format. And there are 4 modules in the pipeline:
If save_path is specified, the visualization results will be saved under
save_path
. The visualization output is shown below:
The command-line method is for quick experience. For project integration, also only a few codes are needed as well:
from paddleocr import FormulaRecognitionPipeline
pipeline = FormulaRecognitionPipeline(formula_recognition_model_name="PP-FormulaNet-S")
output = pipeline.predict("./4HrLNUf2yKGI8CwN9axpt.png")
for res in output:
res.print() ## Print the structured output of the prediction
res.save_to_img(save_path="output") ## Save the formula visualization result of the current image.
res.save_to_json(save_path="output") ## Save the structured JSON result of the current image
For details about usage command and descriptions of parameters, please refer to the
Document
.
PP-FormulaNet-S huggingface.co is an AI model on huggingface.co that provides PP-FormulaNet-S's model effect (), which can be used instantly with this PaddlePaddle PP-FormulaNet-S model. huggingface.co supports a free trial of the PP-FormulaNet-S model, and also provides paid use of the PP-FormulaNet-S. Support call PP-FormulaNet-S model through api, including Node.js, Python, http.
PP-FormulaNet-S huggingface.co is an online trial and call api platform, which integrates PP-FormulaNet-S's modeling effects, including api services, and provides a free online trial of PP-FormulaNet-S, you can try PP-FormulaNet-S online for free by clicking the link below.
PaddlePaddle PP-FormulaNet-S online free url in huggingface.co:
PP-FormulaNet-S is an open source model from GitHub that offers a free installation service, and any user can find PP-FormulaNet-S on GitHub to install. At the same time, huggingface.co provides the effect of PP-FormulaNet-S install, users can directly use PP-FormulaNet-S installed effect in huggingface.co for debugging and trial. It also supports api for free installation.