franken_ocr  by Dicklesworthstone

CPU-only OCR engine for multimodal document understanding

Created 1 month ago
264 stars

Top 96.5% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a pure-Rust, CPU-only OCR engine designed for efficient deployment on commodity hardware. It addresses the challenge of integrating powerful OCR models, like Baidu Unlimited-OCR, into environments lacking GPUs or complex Python/CUDA dependencies. The primary benefit is a single, portable binary (focr) offering offline inference with a minimal footprint, suitable for embedded systems, CI runners, and agent hosts.

How It Works

franken_ocr achieves its CPU-only, dependency-free operation by converting ML model checkpoints into custom int8 .focrq artifacts. It bypasses general ML frameworks, instead employing model-specific Rust kernels optimized for various CPU instruction sets (e.g., AVX-VNNI, NEON). The engine utilizes Reference Sliding Window Attention (R-SWA) for bounded memory usage during long document processing and includes native Rust PDF rasterization.

Quick Start & Requirements

  • Primary install / run command:
    curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/franken_ocr/main/install.sh | bash
    
    (A PowerShell installer is available for Windows.)
  • Non-default prerequisites and dependencies: No GPU, CUDA, Python, or FFI required for inference. Building from source requires the nightly Rust toolchain. Model weights must be downloaded separately using focr pull.
  • Estimated setup time or resource footprint: Binaries are ~13-17 MB. Model weights vary (e.g., 61 MB for TrOMR int8).
  • Links: Installer script, comprehensive README, COMPREHENSIVE_PLAN_FOR_FRANKEN_OCR.md, docs/FEATURE_PARITY.md.

Highlighted Details

  • CPU-Optimized Kernels: Runtime ISA dispatch selects optimal CPU instruction sets (AVX-512-VNNI, AVX-VNNI, AVX2, NEON, SDOT, SMMLA).
  • Model Zoo: Supports five models: Baidu Unlimited-OCR (default), GOT-OCR2 (structured formats), SmolVLM2 (description/VQA), OneChart (chart data), and Polyphonic-TrOMR (sheet music OMR).
  • Offline Operation: Fully functional offline after initial model weight downloads.
  • Memory Safety: #![forbid(unsafe_code)] enforced, with exceptions for audited SIMD kernels and optional mmap.
  • Bounded KV Cache (R-SWA): Enables consistent memory usage for long document OCR.
  • Native PDF/Image Handling: Pure Rust PDF rasterization, supporting rotation metadata and page selection.

Maintenance & Community

The project is primarily maintained by Jeffrey Emanuel. While bug reports and illustrative PRs are welcome, the maintainer explicitly states they do not merge outside contributions due to bandwidth constraints, preferring to review submissions via AI assistance. Community links like Discord/Slack are not provided.

Licensing & Compatibility

The source code is licensed under the MIT License with an OpenAI/Anthropic Rider. The distributed model weights, including Baidu Unlimited-OCR, are under the MIT License. This generally permits commercial use and integration into closed-source applications.

Limitations & Caveats

The default Unlimited-OCR model exhibits a documented "hard-page tail" (page0590) with a high character error rate (CER). Full end-to-end verification for Windows ARM64 is an ongoing release obligation. The native PDF decoder does not support JPXDecode (JPEG 2000) or JBIG2Decode codecs. The project focuses on a curated set of models and is not a generic inference runtime for arbitrary checkpoints.

Health Check
Last Commit

3 days ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
2
Star History
248 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.