VLMs OCR

by Agostino Cesarano
5
4
3
2
1
Score: 50/100

Description

Multimodal OCR for Obsidian: extract text, LaTeX math formulas, and tables from images & PDFs, or generate detailed descriptions of charts and diagrams using local or cloud VLMs.

Reviews

No reviews yet.

Stats

1
stars
169
downloads
0
forks
47
days
47
days
47
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
28
commits

Latest Version

2 months ago

Changelog

Release 1.1.4 — VLMs OCR for Obsidian

Comprehensive release introducing local and cloud Vision-Language Model (VLM) capabilities, low-VRAM optimizations for entry-level GPUs (2GB VRAM), automatic output detection, math table support, and full compliance with the Obsidian Community Plugin guidelines.


Key Features & Architecture Improvements

1. Low-VRAM Optimization (2GB MX450 / Entry-Level GPUs)

  • Native GGUF Inference with llama.cpp: Support for GLM-OCR (0.9B parameters) quantized to Q4_K_M (~531 MB weights) and multimodal projector mmproj-Q8_0 (~484 MB), fitting comfortably within 1.7 GB available VRAM.
  • Smart Image Downscaling: Proportional downscaling to 1536px maximum dimension (src/image_processor.ts) to prevent visual token explosion and GPU Out-Of-Memory (OOM) errors.
  • In-Memory Clipboard Pipeline: Processes images directly in RAM via Buffer and Base64 data URLs without writing intermediate files to disk.

2. Configurable OCR Modes & Prompts

  • Automatic Output Detection (auto): Automatically detects whether an image contains text, LaTeX formulas, Markdown tables, or complex charts/diagrams and provides the optimal structured representation.
  • Chart & Diagram Analytical Description (describe): Produces deep technical summaries for scientific plots, flowcharts, architectures, and diagrams.
  • Specialized Modes:
    • document: Full structured Markdown formatting.
    • formulas: LaTeX expressions wrapped in $$ or $.
    • tables: Markdown tables with aligned columns.
    • text: Plain text extraction.
    • custom: User-defined prompt instructions.

3. Robust LaTeX Math & Table Formatting

  • LaTeX Math Normalization: Automatically wraps raw formulas into proper $$ display math or $ inline math, removing unwanted markdown code fence blocks.
  • Complex Math Tables:
    • Automatically escapes LaTeX absolute values/norms (\|) within formulas so Markdown tables do not break columns.
    • Decodes HTML entities (', &, <, >).
    • Converts HTML <table> elements generated by vision models into clean Obsidian Markdown tables.

4. UI/UX Modernization

  • Neutral Placeholder: Replaced disruptive math blocks with a discreet HTML comment placeholder (<!-- [OCR is being generated... line N] -->).
  • Modernized Settings: Full adoption of Obsidian's Setting.setHeading() API, low-VRAM one-click preset button, and streamlined configuration.

Code Quality & Community Plugin Compliance

  • Complete Open-Source Repository: Full source tree (src/, src/models/, tsconfig.json, esbuild.config.mjs) synchronized on GitHub with official GPL-3.0 License.
  • Obsidian Helper Compliance: Replaced direct DOM calls (document.createElement) with native Obsidian helpers (createEl, createSpan).
  • Strict TypeScript & ESLint: Eliminated all any usages and unhandled promises; typed Electron safe storage integration; verified against eslint-plugin-obsidianmd.
  • Security Disclosures: Detailed explanation in README of local process execution (llama-server) and filesystem access for note assets.
  • CI/CD Build: Verified end-to-end compilation with tsc and esbuild running on GitHub Actions.

README file from

Github

VLMs OCR for Obsidian

GitHub release Obsidian Downloads License: GPL-3.0 Local & Private

VLMs OCR turns Obsidian into an intelligent multimodal transcription workspace. Extract text, LaTeX mathematical formulas, and tables from images and PDFs, or generate in-depth structured descriptions of charts, plots, and diagrams—completely offline using local Vision-Language Models (VLMs) or in the cloud.

Powered locally by high-efficiency VLMs like GLM-OCR (0.9B) or any vision model via llama.cpp / Ollama, as well as the Hugging Face Inference API.


✨ Features

  • 🧠 Auto-detect & Intelligent OCR Modes:
    • Auto-detect: Intelligently classifies content and outputs formatted Markdown, inline/display LaTeX, or converts charts and diagrams into rich textual explanations.
    • Describe Image / Chart: Generates structured markdown summaries of graphs, plots, architectures, workflows, and infographics.
    • Full Document: Converts book pages, slides, papers, and scanned notes into clean Markdown.
    • Formulas Only: Formats math expressions directly into Obsidian-compatible LaTeX ($$...$$ and $ ... $).
    • Tables: Parses complex tabular data into pristine Markdown tables.
    • Plain Text & Custom Prompt: Extract unformatted text or provide your own instruction prompt.
  • ⚡ Optimized for Low-VRAM Hardware (MX450 / 2GB–4GB GPUs):
    • Smart automatic downscaling preserves aspect ratio while preventing token explosion and out-of-memory errors.
    • Zero-temp-file in-memory clipboard pipeline processes images directly from RAM.
    • One-click Low-VRAM Preset configures context window and memory limits automatically.
  • 📋 Seamless Workflow & Hotkeys:
    • Paste image directly as OCR: Press Ctrl+Alt+V (configurable) to grab an image from your clipboard and immediately insert transcribed Markdown/LaTeX at your cursor.
    • Non-blocking inline preview: Real-time markdown placeholder (<!-- [OCR is being generated...] -->) keeps your editor responsive while the model runs.
    • Context Menu & Ribbon: Right-click any image or PDF in your file explorer to transcribe or describe it.
  • 🔒 100% Local & Private or Zero-Install Cloud:
    • llama.cpp: Native, blazing-fast GGUF execution with optional GPU offloading.
    • Ollama: Connects to your local Ollama instance with auto-start support.
    • Hugging Face API: Free cloud inference with zero local dependencies or GPU requirements.

🚀 Quick Start

Option A: Cloud Inference (Zero-Install, No GPU Required)

  1. Create a free account at huggingface.co.
  2. Generate a read token in Hugging Face Token Settings.
  3. In Obsidian, go to Settings → VLMs OCR:
    • Turn off Use local model.
    • Paste your token into the API Key field.

Running GLM-OCR locally in GGUF format requires less than 1.2 GB of VRAM, making it ideal even for entry-level GPUs (like the NVIDIA GeForce MX450 / GTX 1650) or pure CPU execution.

  1. Obtain llama-server:
    • Download the latest llama.cpp release with your preferred acceleration (CUDA or CPU) from llama.cpp Releases.
  2. Download GLM-OCR GGUF weights:
  3. Configure Settings:
    • In Obsidian, go to Settings → VLMs OCR.
    • Enable Use local model and choose Local backend: llama.cpp.
    • Set llama.cpp executable path to your llama-server.exe (or llama-server on Linux/macOS).
    • Click Apply Low-VRAM preset or set arguments:
      -m "/path/to/GLM-OCR.Q4_K_M.gguf" --mmproj "/path/to/GLM-OCR.mmproj-Q8_0.gguf" -ngl 99 -c 4096 --host 127.0.0.1 --port 8080
      

Option C: Run Locally with Ollama

  1. Install Ollama.
  2. Pull your desired vision model (e.g., ollama pull glm-ocr or ollama pull minicpm-v).
  3. In Obsidian Settings → VLMs OCR:
    • Enable Use local model and select Local backend: Ollama.
    • Enter your model name in Ollama model.

⌨️ How to Use

1. Clipboard Paste (Fastest)

  1. Copy any screenshot, math formula, or document snippet to your clipboard (Win + Shift + S on Windows, Cmd + Shift + 4 on macOS).
  2. In your Obsidian note, run the command "OCR image from clipboard" (or bind it to Ctrl+Alt+V).
  3. The recognized Markdown or LaTeX expression will appear right at your cursor position!

2. Vault Files

  • Right-click any supported image (.png, .jpg, .webp, .bmp, .gif) or .pdf in the file explorer.
  • Select Perform OCR (Auto / Active mode) to copy the text to your clipboard, or Describe Image / Chart for an analytical breakdown.

⚙️ Configuration Reference

Setting Description Default
OCR mode Choose default parsing behavior (Auto-detect, Describe, Document, Formulas, Tables, Text, Custom) Auto-detect
Max image dimension Proportional image downscaling threshold to conserve VRAM (set 1536 for 2GB GPUs, 0 to disable) 1536
In-memory clipboard Process clipboard captures entirely in memory without writing temporary files to disk Enabled
Show status bar Displays live backend status indicators (Ready ✅, Loading ⚙️, Offline ❌) Enabled

🛠️ Requirements & Compatibility

  • Obsidian: v1.4.0 or newer.
  • Operating Systems: Windows, macOS, Linux (Desktop only).
  • Supported File Types: PNG, JPG, JPEG, WEBP, BMP, GIF, PDF.

🔒 Security & Disclosures

In accordance with the Obsidian Developer Policies:

  • Desktop Only (isDesktopOnly: true): This plugin is strictly for desktop platforms because local Vision-Language Model execution requires native binary execution and filesystem access.
  • Shell Execution (child_process):
    • Used exclusively to spawn and manage the local inference servers chosen and configured by the user (llama-server.exe or ollama).
    • The plugin does not execute arbitrary shell commands. It only spawns the configured local server executable with inference parameters (such as --port, -m, --mmproj, -c).
  • Filesystem Access (fs):
    • Local Model Files: Reads user-selected local model weights (.gguf files) and local server executables configured in settings.
    • Vault Files & Images: Reads user-selected image and PDF files from the vault or file picker to convert them into base64 visual inputs for OCR processing.
    • No system files outside the configured paths and selected attachments are modified or deleted.
  • Network Use:
    • Local Mode (Default): Connects strictly to localhost / 127.0.0.1 (to the local llama-server or Ollama HTTP REST API). Zero data leaves your computer.
    • Cloud Mode (Optional): If and only if the user explicitly switches the backend to Hugging Face API, image data is transmitted directly over HTTPS to Hugging Face Inference API using the user-provided API key.

📄 License & Attribution