Instructions to use Stuart08/FormulaOCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Stuart08/FormulaOCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Stuart08/FormulaOCR") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Stuart08/FormulaOCR") model = AutoModelForMultimodalLM.from_pretrained("Stuart08/FormulaOCR", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Stuart08/FormulaOCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Stuart08/FormulaOCR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Stuart08/FormulaOCR", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Stuart08/FormulaOCR
- SGLang
How to use Stuart08/FormulaOCR with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Stuart08/FormulaOCR" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Stuart08/FormulaOCR", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Stuart08/FormulaOCR" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Stuart08/FormulaOCR", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Stuart08/FormulaOCR with Docker Model Runner:
docker model run hf.co/Stuart08/FormulaOCR
FormulaOCR๏ผๅ ฌๅผๆชๅพ โ LaTeX๏ผ0.8B๏ผๆฌๅฐ่ฟ่ก๏ผ
A small (0.8B) image-to-LaTeX model for screenshots of math formulas (papers, PDFs, web pages, handwriting), fine-tuned from Qwen3.5-0.8B-Base, plus ready-to-use desktop apps for macOS and Windows that run fully offline.
ไธไธช 0.8B ๅๆฐ็ๅ ฌๅผ่ฏๅซๆจกๅ๏ผๆชๅพ้็ๅ ฌๅผ โ LaTeXใๆฏๆๅฐๅทไฝใ่ฎบๆ/PDF ๆชๅพ๏ผๅซๅ ฌๅผ็ผๅท๏ผใ็ฝ้กตๅ ฌๅผๅๆๅๅ ฌๅผใ ้ๅธฆ Mac ๅ Windows ๆก้ขๅบ็จ๏ผๅฟซๆท้ฎๆก้ๅฑๅนไธ็ๅ ฌๅผ๏ผ็ปๆ่ชๅจๅคๅถๅฐๅช่ดดๆฟ๏ผๅฎๅ จๅจๆฌๆบ่ฟ่ก๏ผไธ่็ฝใ
ๆก้ขๅบ็จไธ่ฝฝ
| ็ณป็ป | ๆไปถ | ่ฏดๆ |
|---|---|---|
| macOS๏ผApple ่ฏ็๏ผmacOS 13+๏ผ | releases/FormulaOCR-mac-arm64.dmg๏ผ1.4 GB๏ผ |
่ๅๆ โ๏ผๅฟซๆท้ฎ โงโ2๏ผ็จ Apple GPU๏ผไธ่ฌๅ ฌๅผ็บฆ 1 ็ง |
| Windows 10/11๏ผ64 ไฝ๏ผ | releases/FormulaOCR-windows-x64.zip๏ผ1.6 GB๏ผ |
ๆ็ โ๏ผๅฟซๆท้ฎ Ctrl+Shift+2๏ผCPU ่ฟ่ก๏ผไธ่ฌๅ ฌๅผ 2๏ฝ5 ็ง |
ๅฎ่ฃ ๅ ่ชๅธฆ Python ่ฟ่ก็ฏๅขๅๆจกๅ๏ผไธ้่ฆๅฆๅคๅฎ่ฃ ไปปไฝไธ่ฅฟใๅฎ่ฃ ๅไฝฟ็จๆนๆณ่งๅ ๅ ็ใไฝฟ็จ่ฏดๆใใ ๅบ็จๆช็ป Apple ๅ ฌ่ฏ / ๅพฎ่ฝฏ็ญพๅ๏ผ็ฌฌไธๆฌกๆๅผ้่ฆๆๅจๆพ่ก๏ผ่ฏดๆ้ๆๆญฅ้ชค๏ผใ
ๆๆ
ๅนณๅ็ผ่พ่ท็ฆป๏ผNED๏ผ่ถไฝ่ถๅฅฝ๏ผ๏ผๆฌๅทๅ ไธบๅฎๅ จไธ่ด็ใๆฏไธชๆต่ฏ้้ๆบ 300 ไธชๆ ทๆฌใ
| ๆต่ฏ้ | GLM-OCR | FormulaOCR |
|---|---|---|
| ็ฝ้กต/่ฝฏไปถๅ ฌๅผๆชๅพ๏ผ่ชๅปบ๏ผ600 ไธชๆชๅไธ่ฎญ็ป็ๅ ฌๅผ๏ผ | 0.078๏ผ53%๏ผ | 0.027๏ผ80%๏ผ |
| UniMER-Test ็ฎๅๅฐๅทไฝ SPE | 0.061 | 0.031 |
| UniMER-Test ๅคๆๅฐๅทไฝ CPE | 0.118 | 0.046 |
| UniMER-Test ๆๅ HWE | 0.053 | 0.042 |
| CROHME 2014 / 2016 / 2019๏ผๆๅ๏ผ | 0.117 / 0.104 / 0.082 | 0.057 / 0.046 / 0.057 |
| HME100K๏ผๆๅ๏ผ | 0.058 | 0.036 |
| UniMER-Test ็ๅฎๆชๅพ SCE | 0.105 | 0.120 |
| OmniDocBench ๅ ฌๅผ | 0.057 | 0.084 |
ๅจๅไธค้กนไธไปไธๅฆ GLM-OCR๏ผๅ
ถไธญไธ้จๅๅทฎ่ทๆฅ่ชๆ ๆณจไน ๆฏไธๅ๏ผ็ฉบๆ ผใ\leq/\leqslant ็ญๅๆณ๏ผใ
็จ Python ่ฐ็จ
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
repo = "Stuart08/FormulaOCR"
proc = AutoProcessor.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype=torch.bfloat16).to("cuda").eval() # or "mps" / "cpu" (use float32 on CPU)
prompt = "<|vision_start|><|image_pad|><|vision_end|>Transcribe the image into Markdown. Use LaTeX for math: $...$ inline, $$...$$ for display.\n"
img = Image.open("formula.png").convert("RGB")
inputs = proc(text=[prompt], images=[img], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=768, do_sample=False)
print(proc.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])
# -> $$\frac{\partial}{\partial t}(\rho h)+\nabla\cdot(\rho h\mathbf{u})=\dots$$
- ่พๅ ฅไธ็จ chat template๏ผ็ดๆฅ็จไธ้ข่ฟๆฎตๅบๅฎๆ็คบ่ฏ๏ผ่ฎญ็ปๆถๅฐฑๆฏ่ฟไธชๆ ผๅผ๏ผใ
- ่พๅบๆฏ Markdown๏ผๅไธชๅ
ฌๅผไธบ
$$...$$๏ผๅธฆๅ ฌๅผ็ผๅทๆถๆซๅฐพๆฏ\tag{n}ใ - ้่ฆ
transformers>=5.16ใtorchvisionใ
่ฎญ็ป
- ๅบๅบง๏ผQwen3.5-0.8B-Base๏ผๅ จๅๆฐๅพฎ่ฐใ
- ๆฐๆฎ๏ผUniMER-1M ่ฎญ็ป้ใHME100KใCROHME๏ผ็จ MathJax๏ผ11 ็งๆฐๅญฆๅญไฝ๏ผๆธฒๆ็็บฆ 30 ไธๅผ ็ฝ้กต้ฃๆ ผๆชๅพ๏ผ ็จ็ๅฎ LaTeX๏ผ25 ็งๆๅๅญไฝ๏ผๆธฒๆ็็บฆ 20 ไธๅผ PDF/่ฎบๆ้ฃๆ ผๆชๅพ๏ผๅซๅ ฌๅผ็ผๅทใไฝๅ่พจ็ๅฐๅพใ็ญ่กจ่พพๅผ๏ผใ ่ฎญ็ป็จ็ๅ ฌๅผ้ฝๅปๆไบไธๆต่ฏ้้ๅค็ๅ ๅฎนใ
- ๅ ่ฎญ็ป่ฟไธไธช้็จ OCR ๆจกๅ๏ผๅฐๅท/ๆๅๆๅญใไธญ่ฑๆๆททๆ๏ผ๏ผๅ ฌๅผๆจกๅๅจๅฎๅบ็กไธ็ปง็ปญ่ฎญ็ปใ
่ฎธๅฏไธ้ๅถ
- CC BY-NC 4.0๏ผๅ ่ฎธๅ ่ดนไฝฟ็จๅๅไบซ๏ผ็ฆๆญขๅไธ็จ้ใ ่ฎญ็ปๆฐๆฎไธญ็ CASIA-HWDBใIAMใHME100K ็ญๆฐๆฎ้ๅชๅ ่ฎธ้ๅไธ็ ็ฉถไฝฟ็จใ
- ๅบๅบงๆจกๅ Qwen3.5-0.8B-Base ้ตๅพชๅ ถ่ช่บซ่ฎธๅฏ่ฏใ
- ไธป่ฆ้ๅฏนๅไธชๅ ฌๅผ๏ผๆไธๅฐๆฎตๅ ฌๅผ๏ผ็ๆชๅพ๏ผๆด้กตๆๆกฃใ่กจๆ ผใ้ฟๆฎต่ฝๆๅญไธๆฏๅฎ็ๅผบ้กนใ
- ่พๅบๅฏ่ฝๆๅฐ้่ฏฏ๏ผ็บฆไบๅไนไธ็ๅ ฌๅผไธๆฏ้ๅญไธ่ด๏ผ๏ผ้่ฆๅบๅ่ฏทๅฏน็ งๅๅพๆฃๆฅใ
- Downloads last month
- -