How harisnae/offlinewebocr works
This is a static, browser-based OCR demo: users load an image, optionally crop it, select and load a model, then run OCR in a web worker and view raw and decoded output. The worker uses Transformers.js for TrOCR-style image-to-text or Donut document-question-answering inference; the UI also supports copying decoded text. The README documents offline processing after model loading and browser caching. Edges reflect the shown script/worker messaging and calls; other capabilities are included where documented, without inferring unsampled implementation details.
Main entry points: worker.js OCR Worker · script.js Image Canvas
Components 14
Image Input
- Image Intake
script.js - Image Canvas
script.js - Crop Tool
script.js
Model Setup
- Model Selection
script.js
OCR Runtime
- Model Loader
worker.js - OCR Worker
worker.js - Transformers.js
- TrOCR Inference
worker.js - Donut Inference
worker.js
Results
- Progress Status
script.js - Raw JSON Output
script.js - Decoded Text
script.js
Other components
- User
- Clipboard
Connections 18
- User → Image Intake: uploads or selects
script.js - Image Intake → Image Canvas: displays image
script.js - User → Crop Tool: selects region
script.js - Crop Tool → Image Canvas: draws selection
script.js - User → Model Selection: chooses model
script.js - Model Selection → Model Loader: sends model ID
script.js - Model Loader → Transformers.js: loads pipeline
worker.js - Transformers.js → Model Loader: reports progress
- Model Loader → Progress Status: posts progress
worker.js - User → Image Canvas: runs OCR on
script.js - Image Canvas → OCR Worker: sends image data
script.js - OCR Worker → TrOCR Inference: dispatches image task
worker.js - OCR Worker → Donut Inference: dispatches document task
worker.js - TrOCR Inference → Transformers.js: runs pipeline
worker.js - Donut Inference → Transformers.js: runs pipeline
worker.js - OCR Worker → Raw JSON Output: posts raw result
script.js - OCR Worker → Decoded Text: posts decoded text
script.js - User → Clipboard: copies text