{"id":16881497,"url":"https://github.com/swhl/convertlatexocrtoonnx","last_synced_at":"2025-06-21T04:10:34.166Z","repository":{"id":210922105,"uuid":"727770822","full_name":"SWHL/ConvertLaTeXOCRToONNX","owner":"SWHL","description":"Convert LaTeX-OCR To ONNX","archived":false,"fork":false,"pushed_at":"2024-04-02T10:07:02.000Z","size":931,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T12:13:39.677Z","etag":null,"topics":["convert-to-onnx","img2latex","latex-ocr","math-formula"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SWHL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-05T14:41:27.000Z","updated_at":"2025-02-04T19:22:24.000Z","dependencies_parsed_at":"2023-12-05T16:05:31.289Z","dependency_job_id":"dfe8c62d-6649-4d63-af2b-582c3a413017","html_url":"https://github.com/SWHL/ConvertLaTeXOCRToONNX","commit_stats":null,"previous_names":["swhl/convertlatexocrtoonnx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SWHL/ConvertLaTeXOCRToONNX","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FConvertLaTeXOCRToONNX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FConvertLaTeXOCRToONNX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FConvertLaTeXOCRToONNX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FConvertLaTeXOCRToONNX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SWHL","download_url":"https://codeload.github.com/SWHL/ConvertLaTeXOCRToONNX/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2FConvertLaTeXOCRToONNX/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261060173,"owners_count":23103987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convert-to-onnx","img2latex","latex-ocr","math-formula"],"created_at":"2024-10-13T16:02:52.413Z","updated_at":"2025-06-21T04:10:29.143Z","avatar_url":"https://github.com/SWHL.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Convert LaTeX-OCR To ONNX\n\n### 1. Clone the source code.\n```bash\ngit clone https://github.com/SWHL/ConvertLaTeXOCRToONNX.git\n```\n\n### 2. Install env.\n#### Anaconda\n```bash\nconda env create -f environment.yml\n```\n\n#### Pip\n```bash\n$ conda create -n cvt_latex python=3.10.13\n\n$ conda activate cvt_latex\n\n$ pip install -r requirements.txt\n```\n\n\n### 3. Run the convert.py, and the converted model is located in the `models` directory.\n```bash\n$ python convert.py\n\n# /Users/xxx/miniconda3/envs/convert_latex_ocr/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py:1513: UserWarning: ONNX export mode is set to TrainingMode.EVAL, but operator 'batch_norm' is set to train=True. Exporting with train=True.\n#   warnings.warn(\n# Exported model has been tested with ONNXRuntime, and the result looks good!\n# ONNX Model has been saved /Users/xxx/projects/_self/ConvertLaTeXOCRToONNX/models/image_resizer.onnx\n# Exported model has been tested with ONNXRuntime, and the result looks good!\n# ONNX Model has been saved /Users/xxx/projects/_self/ConvertLaTeXOCRToONNX/models/encoder.onnx\n# Exported model has been tested with ONNXRuntime, and the result looks good!\n# ONNX Model has been saved /Users/xxx/projects/_self/ConvertLaTeXOCRToONNX/models/decoder.onnx\n# \\exp\\left[\\int d^{4}x g\\phi\\bar{\\psi}\\psi\\right]=\\sum_{n=0}^{\\infty}\\frac{g^{n}}{n!}\\left(\\int d^{4}x\\phi\\bar{\\psi}\\psi\\right)^{n}.\n```\n\n\n### 4. Used in [RapidLaTeXOCR](https://github.com/RapidAI/RapidLaTeXOCR).\n\n```python\nfrom rapid_latex_ocr import LatexOCR\n\nimage_resizer_path = 'models/image_resizer.onnx'\nencoder_path = 'models/encoder.onnx'\ndecoder_path = 'models/decoder.onnx'\ntokenizer_json = 'models/tokenizer.json'\nmodel = LatexOCR(image_resizer_path=image_resizer_path,\n                 encoder_path=encoder_path,\n                 decoder_path=decoder_path,\n                 tokenizer_json=tokenizer_json)\n\nimg_path = \"tests/test_files/6.png\"\nwith open(img_path, \"rb\") as f:\n    data = f. read()\n\nresult, elapse = model(data)\n\nprint(result)\n# {\\frac{x^{2}}{a^{2}}}-{\\frac{y^{2}}{b^{2}}}=1\n\nprint(elapse)\n# 0.4131628000000003\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswhl%2Fconvertlatexocrtoonnx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswhl%2Fconvertlatexocrtoonnx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswhl%2Fconvertlatexocrtoonnx/lists"}