Git Product home page Git Product logo

rapidlatexocr's Introduction

Rapid ⚡︎ LaTeX OCR

 

PyPI SemVer2.0

Introduction

rapid_latex_ocr is a tool to convert formula images to latex format.

The reasoning code in the repo is modified from LaTeX-OCR, the model has all been converted to ONNX format, and the reasoning code has been simplified, Inference is faster and easier to deploy.

The repo only has codes based on ONNXRuntime or OpenVINO inference in onnx format, and does not contain training model codes. If you want to train your own model, please move to LaTeX-OCR.

If it helps you, please give a little star ⭐ or sponsor a cup of coffee (click the link in Sponsor at the top of the page)

🔥 Model Conversion Notes 👉 ConvertLaTeXOCRToONNX

Framework

flowchart LR

A(Preprocess Formula\n ProcessLaTeXFormulaTools) --> B(Train\n LaTeX-OCR) --> C(Convert \n ConvertLaTeXOCRToONNX) --> D(Deploy\n RapidLaTeXOCR)

click A "https://github.com/SWHL/ProcessLaTeXFormulaTools" _blank
click B "https://github.com/lukas-blecher/LaTeX-OCR" _blank
click C "https://github.com/SWHL/ConvertLaTeXOCRToONNX" _blank
click D "https://github.com/RapidAI/RapidLaTeXOCR" _blank

Installation

Note

When installing the package through pip, the model file will be automatically downloaded and placed under models in the installation directory.

If the Internet speed is slow, you can download it separately through Google Drive or Baidu NetDisk.

pip install rapid_latex_ocr

Usage

Used by python script

from rapid_latex_ocr import LatexOCR

model = LatexOCR()

img_path = "tests/test_files/6.png"
with open(img_path, "rb") as f:
    data = f.read()

res, elapse = model(data)

print(res)
print(elapse)

Used by command line

$ rapid_latex_ocr tests/test_files/6.png

# {\\frac{x^{2}}{a^{2}}}-{\\frac{y^{2}}{b^{2}}}=1
# 0.47902780000000034

Changlog

Click to expand

2023-12-10 v0.0.6 update:

  • Fixed issue #12

2023-12-07 v0.0.5 update:

  • Add the relevant code to automatically download the model when installing the package

2023-09-13 v0.0.4 update:

2023-07-15 v0.0.1 update:

  • First release

Code Contributors

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

If you want to sponsor the project, you can directly click the Buy me a coffee image, please write a note (e.g. your github account name) to facilitate adding to the sponsorship list below.

License

This project is released under the MIT license.

rapidlatexocr's People

Contributors

chaodreaming avatar swhl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rapidlatexocr's Issues

About Transforming Models

Hello, thank you very much for your work. I have previously trained the model on my own data, so I would like to ask for more details on how to convert the onnx model so that I can convert the model I trained into onnx

ONNX模型会被重复下载

问题描述

如果没有指定ONNX模型路径,每次调用类别实例,都会重复下载ONNX模型到指定目录下

问题版本

v0.0.5

Training mode is not supported in this build.

请提供下述完整信息以便快速定位问题
(Please provide the following information to quickly locate the problem)

  • 系统环境/System Environment: Ubuntu 20.4 (WSL 2)
  • 使用的是哪门语言的程序/Which programing language: Python3.8
  • 所使用语言相关版本信息/Version: 0.6
  • OnnxRuntime版本/OnnxRuntime Version: 1.8
  • 使用rapidocr_onnxruntime版本/Use rapidocr_onnxruntime version: 1.3.16
  • 可复现问题的demo和文件/Demo of reproducible problems: import LatexOcr, create instance of LatexOCR, run model

image

  • 完整报错/Complete Error Message:
    onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/cpu/nn/batch_norm.h:52 onnxruntime::BatchNorm::BatchNorm(const onnxruntime::OpKernelInfo&) [with T = float] !is_train_ was false. Training mode is not supported in this build.

  • 可能的解决方案/Possible solutions:

How to disable Training mode?

Generated onnx has incorrect output

Thanks for your great work. And I must say that it has been incredibly valuable to me.

However, I have encountered an issue while following the steps mentioned in the Model Conversion Notes. Even after inserting the export code into Latex-OCR and resolving the 'context' error, the resulting ONNX model is still producing incorrect output. When I tried using your provided ONNX model, it worked perfectly fine.

I would like to ask if you made any additional modifications to the conversion process that are not mentioned in the notes. I noticed the mention of Attention sentences in the Model Conversion Notes. Could you please provide guidance on which conditional statements should be commented out in order to ensure proper conversion?

I am grateful for any assistance you can provide in resolving this issue. Thank you for your time and help.

Bug

请提供下述完整信息以便快速定位问题
(Please provide the following information to quickly locate the problem)

  • 系统环境/System Environment:
  • 使用的是哪门语言的程序/Which programing language:
  • 所使用语言相关版本信息/Version:
  • OnnxRuntime版本/OnnxRuntime Version:
  • 使用rapidocr_onnxruntime版本/Use rapidocr_onnxruntime version:
  • 可复现问题的demo和文件/Demo of reproducible problems:
  • 完整报错/Complete Error Message:
  • 可能的解决方案/Possible solutions:

数据集合作

你好,我们有mathpix API接口,我们课题组正在构造足够多的手写或印刷体数据(也许在不久的未来超过100万)。也许我们可以合作共同完善Latex ocr模型,如果你对此感兴趣,欢迎联系我们

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.