OpenThai 2.2 OCR for Mac M2, Radeon 890M, and GTX 1080 Ti

OpenThai 2.2 OCR สำหรับ Mac M2, Radeon 890M และ GTX 1080 Ti

This community port runs iApp OpenThai 2.2.2 on Thai and English page images. It outputs Markdown with HTML tables and LaTeX formulas. The original checkpoint serves Radeon and GTX. The second checkpoint is the tested 6-bit MLX conversion for M2.

พอร์ตนี้ใช้ OpenThai 2.2.2 จาก iApp อ่านภาพเอกสารภาษาไทยและภาษาอังกฤษ แล้วส่งออก Markdown พร้อมตาราง HTML และสูตร LaTeX ใช้เช็กพอยต์ต้นฉบับบน Radeon และ GTX ส่วน M2 ใช้ไฟล์ MLX 6-bit ที่ผ่านการทดสอบ

Recommended profiles / โหมดแนะนำ

Hardware / ฮาร์ดแวร์ Profile / โหมด Median full page / เวลามัธยฐานต่อหน้า Peak memory / หน่วยความจำสูงสุด
Apple M2 mlx · 6-bit decoder, FP16 vision, whole prefill 6.930 s 1.780 GiB MLX allocation
Radeon 890M (gfx1150) rocm · BF16 grouped flash, buffered KV 16.422 s 1.606 GiB PyTorch allocated
GTX 1080 Ti pascal · balanced, FP32 prefill, int8 decode, FP16 KV 3.392 s 4,982 MiB NVML process peak

M2 and Radeon share the 88-item holdout. GTX uses a different 30-page sample. Compare each profile with its own baseline below. MLX uses unified memory. ROCm reports allocations tracked by PyTorch on the integrated GPU. GTX memory is sampled for the whole OCR process. Each peak is the maximum observed on that profile's sample.

M2 และ Radeon ใช้ชุด holdout เดียวกัน 88 รายการ ส่วน GTX ใช้ตัวอย่างอีกชุด 30 หน้า ให้เปรียบเทียบแต่ละโหมดกับค่าฐานด้านล่าง MLX ใช้หน่วยความจำรวม ROCm วัดการจัดสรรของ PyTorch บน GPU ในตัว และ GTX วัดหน่วยความจำของโปรเซส OCR ด้วย NVML ตัวเลขคือค่าสูงสุดที่วัดได้จากตัวอย่างของแต่ละโหมด

Install and run / ติดตั้งและใช้งาน

Run from the repository root. Use Python 3.12 and uv. To download from Hugging Face after publication, use Git LFS.

รันจากโฟลเดอร์หลักของรีโพซิทอรี ใช้ Python 3.12 และ uv หลังเผยแพร่แล้วดาวน์โหลดจาก Hugging Face ด้วย Git LFS

git lfs install
git clone https://huggingface.co/anusoft/OpenThai2.2-OCR-Markdown-20261127-mlx-rocm-pascal
cd OpenThai2.2-OCR-Markdown-20261127-mlx-rocm-pascal
mkdir -p outputs

For an existing checkout, start with mkdir -p outputs. Substitute your file for the bundled synthetic sample. Choose a new JSONL output name on each run. For a smaller download, clone with GIT_LFS_SKIP_SMUDGE=1 and pull only models/original/model.safetensors for GTX or Radeon, or models/mlx/openthai22-q6/model.safetensors for M2 using git lfs pull --include PATH.

หากมีรีโพซิทอรีอยู่แล้ว ให้เริ่มจาก mkdir -p outputs เปลี่ยนภาพสังเคราะห์ในตัวอย่างเป็นไฟล์ของคุณ และใช้ชื่อไฟล์ JSONL ใหม่ในแต่ละครั้ง หากต้องการลดปริมาณการดาวน์โหลด ให้ clone ด้วย GIT_LFS_SKIP_SMUDGE=1 แล้วใช้ git lfs pull --include PATH เพื่อดึงเฉพาะ models/original/model.safetensors สำหรับ GTX หรือ Radeon หรือ models/mlx/openthai22-q6/model.safetensors สำหรับ M2

Apple M2 · MLX

Use native arm64 Python on macOS 14 or newer. The recorded M2 run used macOS 27.2.1. This profile returns JSONL with Markdown and layout blocks.

ใช้ Python แบบ arm64 บน macOS 14 ขึ้นไป เครื่อง M2 ที่ทดสอบใช้ macOS 27.2.1 โหมดนี้ส่งออก JSONL ที่มี Markdown และบล็อกโครงสร้างเอกสาร

uv venv --python 3.12 .venv-mlx
uv pip install --python .venv-mlx/bin/python -r requirements/mlx.txt
OCR_PYTHON="$PWD/.venv-mlx/bin/python" bash run.sh mlx outputs/m2.jsonl \
  --image benchmarks/fixtures/synthetic-ocr-page.png

Radeon 890M · ROCm

Use Linux x86-64 with ROCm and a visible gfx1150 GPU. The launcher enables the AOTriton flash path. Use rocm-math for the BF16 math baseline.

ใช้ Linux x86-64 พร้อม ROCm ที่มองเห็น GPU gfx1150 ตัวเรียกเปิดใช้แฟลชผ่าน AOTriton เลือก rocm-math สำหรับค่าฐาน BF16 math

python3.12 -m venv .venv-rocm
.venv-rocm/bin/python -m pip install \
  'torch==2.11.0+rocm7.13.0' 'torchvision==0.26.0+rocm7.13.0' \
  --index-url https://repo.amd.com/rocm/whl/gfx1150/ --extra-index-url https://pypi.org/simple
.venv-rocm/bin/python -m pip install -r requirements/rocm.txt
OCR_PYTHON="$PWD/.venv-rocm/bin/python" bash run.sh rocm outputs/radeon.jsonl \
  --image benchmarks/fixtures/synthetic-ocr-page.png

GTX 1080 Ti · CUDA 12.6

Use Linux x86-64, a compatible NVIDIA driver, CUDA 12.6 with nvcc, and a C++ compiler. The first run builds the CUDA extensions. Set CUDA_HOME if the toolkit lives outside /usr/local/cuda-12.6. The GTX test used driver 580.173.02. The launcher writes Markdown.

ใช้ Linux x86-64 พร้อมไดรเวอร์ NVIDIA ที่รองรับ, CUDA 12.6 ที่มี nvcc และคอมไพเลอร์ C++ ครั้งแรกจะคอมไพล์ส่วนขยาย CUDA หากติดตั้งไว้ที่อื่นให้ตั้ง CUDA_HOME เครื่องทดสอบใช้ไดรเวอร์ 580.173.02 ผลลัพธ์เป็น Markdown

uv venv --python 3.12 .venv-pascal
uv pip install --python .venv-pascal/bin/python \
  --default-index https://download.pytorch.org/whl/cu126 \
  'torch==2.13.0+cu126' 'torchvision==0.28.0+cu126'
uv pip install --python .venv-pascal/bin/python -r requirements/pascal.txt
OCR_PYTHON="$PWD/.venv-pascal/bin/python" bash run.sh pascal outputs/gtx.md \
  --image benchmarks/fixtures/synthetic-ocr-page.png

Append --engine mixed for closer agreement with stock, or --engine accurate for FP32 decode.

เพิ่ม --engine mixed เพื่อให้ผลใกล้เคียงต้นฉบับมากขึ้น หรือ --engine accurate เพื่อใช้ FP32 ในขั้นถอดรหัส

Measured trade-offs / ความเร็วและคุณภาพที่วัดได้

M2 and Radeon / M2 และ Radeon

The holdout has 48 crops, 20 full pages, and 20 tables. Lower character error rate (CER) and higher local table similarity (0–100) are better. Peak is the maximum across all scored items. The speed ratios below compare runs on the same hardware.

ชุด holdout มีภาพครอป 48 รายการ ภาพเต็มหน้า 20 หน้า และตาราง 20 หน้า ค่า CER ยิ่งต่ำยิ่งดี ส่วนคะแนนความคล้ายของตารางที่วัดด้วยตัวให้คะแนนของโปรเจกต์ (0–100) ยิ่งสูงยิ่งดี หน่วยความจำคือค่าสูงสุดจากตัวอย่างทั้งหมด อัตราเร็วเปรียบเทียบผลบนฮาร์ดแวร์เครื่องเดียวกัน

Profile / โหมด Page p50 / มัธยฐานต่อหน้า Page CER Table p50 / มัธยฐานต่อตาราง Table score / คะแนนตาราง Peak allocation / การจัดสรรสูงสุด
M2 MLX BF16 baseline 11.397 s 11.90% 10.602 s 70.76 1.963 GiB
M2 MLX 6-bit, default prefill 7.216 s 11.99% 6.800 s 72.62 1.788 GiB
M2 MLX 6-bit, whole prefill 6.930 s 10.81% 6.911 s 72.27 1.780 GiB
Radeon BF16 math baseline 42.984 s 11.62% 39.665 s 70.67 25.478 GiB
Radeon grouped flash, buffered KV 16.422 s 11.91% 14.761 s 71.39 1.606 GiB

On M2, whole prefill delivered 1.64× the historical BF16 baseline's page speed and reduced page CER by 1.09 percentage points. Compared with the same 6-bit checkpoint on mlx-vlm 0.8.1 with default prefill, whole prefill cut page median by 4.0%, while table median rose 1.6% and table similarity fell 0.35 points. The historical BF16 baseline also uses an earlier mlx-vlm build.

บน M2 โหมด whole prefill เร็วกว่าค่าฐาน BF16 เดิม 1.64 เท่า และลด CER เต็มหน้า 1.09 จุดเปอร์เซ็นต์ เมื่อเทียบกับเช็กพอยต์ 6-bit เดียวกันบน mlx-vlm 0.8.1 ที่ใช้ prefill ค่าเริ่มต้น โหมด whole prefill ลดเวลามัธยฐานเต็มหน้า 4.0% แต่ใช้เวลาตารางเพิ่ม 1.6% และคะแนนตารางลด 0.35 คะแนน ค่าฐาน BF16 เดิมใช้ mlx-vlm รุ่นก่อนหน้าด้วย

On Radeon, grouped flash was 2.62× as fast as BF16 math at the page median. Page CER rose 0.29 percentage points, while table similarity rose 0.73 points. The optimized profile produced scored output for all 20 tables. Deltas use unrounded measurements.

บน Radeon โหมด grouped flash เร็วกว่าค่าฐาน BF16 math 2.62 เท่า ที่ค่ามัธยฐานต่อหน้า โดย CER เพิ่ม 0.29 จุดเปอร์เซ็นต์ และคะแนนตารางเพิ่ม 0.73 คะแนน ระบบส่งผลที่ให้คะแนนได้ครบทั้ง 20 ตาราง ค่าความแตกต่างคำนวณจากตัวเลขก่อนปัดเศษ

Holdout scores / คะแนน holdout · Pilot scores / คะแนน pilot

GTX 1080 Ti

The 30-page sample has ten full pages, ten tables, and ten document parsing pages. Total time sums the measured pages after warmup. Character accuracy, TEDS, and STEDS use the dataset references. Exact agreement compares rendered text or Markdown against stock outputs for the task.

ตัวอย่างมี 30 หน้า แบ่งเป็นข้อความเต็มหน้า ตาราง และโครงสร้างเอกสารอย่างละ 10 หน้า เวลารวมคือผลรวมของเวลาแต่ละหน้าหลังอุ่นเครื่อง ความแม่นยำระดับอักขระ, TEDS และ STEDS วัดจากคำตอบอ้างอิง ส่วนความตรงกันเทียบข้อความหรือ Markdown กับผลจากวิธีรันต้นฉบับ

Preset / โหมด Total / เวลารวม Char. accuracy / ความแม่นยำอักขระ Table TEDS Doc. STEDS Exact / ตรงกับต้นฉบับ Peak VRAM
Stock FP32 554.89 s 86.06% 49.88 40.63 30/30 —
Balanced 148.70 s 86.29% 50.61 40.63 22/30 4,982 MiB
Mixed 163.23 s 86.07% 50.61 40.63 28/30 5,100 MiB
Accurate 214.97 s 86.06% 49.88 40.63 30/30 5,178 MiB

Balanced ran 3.73× as fast as stock. On this sample it gained 0.23 percentage points in character accuracy and 0.74 TEDS. Relative to balanced, mixed took 9.8% longer and matched six more stock outputs. Accurate took 44.6% longer and matched all 30.

Balanced เร็วกว่าต้นฉบับ 3.73 เท่า บนตัวอย่างนี้ความแม่นยำระดับอักขระเพิ่ม 0.23 จุดเปอร์เซ็นต์ และ TEDS เพิ่ม 0.74 คะแนน เมื่อเทียบกับ balanced โหมด mixed ใช้เวลาเพิ่ม 9.8% และตรงกับต้นฉบับเพิ่ม 6 หน้า โหมด accurate ใช้เวลาเพิ่ม 44.6% และตรงกันครบ 30 หน้า

A separately distributed Q8_0 GGUF with F16 projector used 2,008 MiB on the same GTX sample. It took 219.91 s, 47.9% longer than balanced, and scored 85.91% character accuracy, 51.79 TEDS, and 39.04 STEDS. Its result on one long table used fewer generated tokens, which affected total latency.

ไฟล์ GGUF Q8_0 ที่เผยแพร่แยก พร้อม projector F16 ใช้ 2,008 MiB บนตัวอย่าง GTX ชุดเดียวกัน ใช้เวลา 219.91 วินาที มากกว่า balanced 47.9% ได้ความแม่นยำอักขระ 85.91%, TEDS 51.79 และ STEDS 39.04 ผลของหน้าตารางขนาดยาวหนึ่งหน้าสร้างโทเคนน้อยลง จึงมีผลต่อเวลารวม Pascal results / ผล Pascal · Mixed scores · GGUF comparison and setup / วิธีรันและผล GGUF

Reproduce the checks / ทดสอบซ้ำ

The fetcher verifies original image hashes and builds the local benchmark files from the pinned ThaiOCRBench revision. The Git repository contains the sample IDs, hashes, the synthetic fixture, and numeric summaries.

สคริปต์ดาวน์โหลดตรวจแฮชภาพต้นฉบับและสร้างไฟล์ทดสอบจากเวอร์ชัน ThaiOCRBench ที่ระบุไว้ ใน Git มีรหัสตัวอย่าง แฮช ภาพสังเคราะห์ และผลคะแนนเชิงตัวเลข

uv venv --python 3.12 .venv-bench
uv pip install --python .venv-bench/bin/python -r requirements/benchmark.txt
.venv-bench/bin/python bench/fetch_inputs.py

On GTX, compare exact Markdown on the three reference pages using the Pascal environment. On Radeon or M2, select the matching launcher and environment to replay the 88 scored holdout items. Use bench/pilot-ids.json for the 20-item pilot. Score the chosen run against the dataset references. To measure exact agreement and speed against Radeon BF16 math, run rocm-math with the same arguments and pass both outputs to bench/compare_retest.py.

บน GTX ให้ใช้สภาพแวดล้อม Pascal เพื่อตรวจ Markdown ทั้งสามหน้าอ้างอิง บน Radeon หรือ M2 ให้เลือกโหมดและสภาพแวดล้อมให้ตรงกันเพื่อรันชุด holdout 88 รายการ ใช้ bench/pilot-ids.json สำหรับชุด pilot 20 รายการ คำสั่งให้คะแนนเทียบกับคำตอบอ้างอิงของชุดข้อมูล หากต้องการเทียบความเร็วและความตรงกันกับ Radeon BF16 math ให้รัน rocm-math ด้วยอาร์กิวเมนต์เดียวกัน แล้วส่งผลทั้งสองชุดให้ bench/compare_retest.py

PATH="$PWD/.venv-pascal/bin:$PATH" CUDA_HOME=/usr/local/cuda-12.6 \
  TORCH_CUDA_ARCH_LIST=6.1 .venv-pascal/bin/python bench/verify_pascal.py \
  --output outputs/parity.json

OCR_PYTHON="$PWD/.venv-rocm/bin/python" bash run.sh rocm outputs/candidate.jsonl \
  --ids bench/holdout-ids.json --index benchmark-data/thaiocrbench/index.jsonl \
  --images benchmark-data/thaiocrbench/images
.venv-bench/bin/python bench/score_port.py benchmark-data/thaiocrbench/index.jsonl \
  bench/holdout-ids.json outputs/candidate.jsonl > outputs/scores.json

For the M2 candidate, use .venv-mlx/bin/python and the mlx profile. The stored 30-page GTX results retain their full manifest and per-page scoring. The three-page check tests exact Markdown independently.

สำหรับผลทดสอบ M2 ให้ใช้ .venv-mlx/bin/python และโหมด mlx ผล GTX 30 หน้าระบุรายการตัวอย่างและคะแนนรายหน้า ส่วนการทดสอบสามหน้าตรวจความตรงกัน ของ Markdown แยกต่างหาก

Provenance / ที่มา

Original 2.2.2 revision a9357989091e4d70310d6fb29de5527b9febe825. The MLX checkpoint uses the same source and a 6-bit affine decoder. ThaiOCRBench is pinned at ca610d1ab33059e721251137ab1f19f936b87648. Run sha256sum -c SHA256SUMS on Linux or shasum -a 256 -c SHA256SUMS on macOS to verify the full checkout.

เช็กพอยต์ต้นฉบับ 2.2.2 ใช้ revision a9357989091e4d70310d6fb29de5527b9febe825 ไฟล์ MLX ใช้ต้นฉบับเดียวกันและตัวถอดรหัส affine 6-bit ชุด ThaiOCRBench ใช้ revision ca610d1ab33059e721251137ab1f19f936b87648 ตรวจสอบไฟล์ทั้งหมดด้วย sha256sum -c SHA256SUMS บน Linux หรือ shasum -a 256 -c SHA256SUMS บน macOS Licenses and credits / สิทธิ์และเครดิต · Publish / เผยแพร่

Downloads last month

-

Downloads are not tracked for this model. How to track
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for anusoft/OpenThai2.2-OCR-Markdown-20261127-mlx-rocm-pascal

Quantized
(6)
this model