DeOCR
DeOCR (de-cor), A reverse OCR tool that renders huggingface-compatible datasets to configurable images (e.g., custom size 512x512, black background, paddings, margins, etc.). This tool can be considered as a text-to-image data pre-processing component in pipelines such as DeepSeek-OCR.
---
title: DeOCR Usage in LLM Pipeline
---
flowchart LR
TEXTDATA[/"context as pure text"/]
MMDATA[/"Does this particular car <br/> <image> present in here <image> ?"/]
HFDATASET[("huggingface dataset")]
subgraph DeOCR
CSS1["cli --style red-text,bold"]
CSS2["cli --style default"]
CSS3["cli --style default"]
MAPPER["DeOCR Dataset Mapper"]
end
TEXTDATA --> CSS1 --> IMG1[["🖼️🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>🖼️ context as img 🖼️<br/>🖼️🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>"]]:::redText
TEXTDATA --> CSS2 --> IMG2[["🖼️🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>🖼️ context as img 🖼️<br/>🖼️🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>"]]
MMDATA --> CSS3 --> IMG3[["Does this particular car <br/> 🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>🖼️🖼️🖼️🚗🖼️🖼️🖼️<br/>🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/> present in here <br/> 🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>🖼️🖼️🖼️🖼️🖼️🖼️🖼️<br/>?"]]
HFDATASET --> MAPPER --> DEOCRDATASET[("🖼️ imagified dataset")]
DEOCRDATASET & IMG1 & IMG2 & IMG3 -.-> MODEL["LLMs or VLMs<br/> Evaluation"]
classDef redText color:#ff0000,font-weight:bold;
IMG1 ~~~|"fa:fa-mobile-screen A screenshot of text <br/>w. special formatting"| IMG1
IMG2 ~~~|"fa:fa-mobile-screen A plain screenshot of text"| IMG2
IMG3 ~~~|"fa:fa-mobile-screen A screenshot of both text and images"| IMG3
Here is an output example, sized `512x512`, with random string as context
Quick Start
pip install deocr[playwright,pymupdf]
# activate your python environment, then install playwright deps
playwright install chromium
Alternatively, install from source
# uv
uv add "deocr[playwright,pymupdf] @ git+https://github.com/Moenupa/DeOCR.git"
# activate your python environment, then install playwright deps
playwright install chromium
For development
Please use uv to manage the environment:
git clone https://github.com/Moenupa/DeOCR.git
cd DeOCR
uv venv
uv sync --all-extras --all-groups
source .venv/bin/activate
playwright install chromium
pre-commit install
Known Issues
- async function timeout: increase threshold 0.05 at datasets/utils/py_utils.py:612-626
Performance
DeOCR is mainly optimized by asynchronous rendering and multiprocessing dataset mapping. The rendering speed may vary depending on the machine configuration and the complexity of the text to be rendered. On a standard machine with 32 cores, DeOCR can render more than 1k images per second.
GSM8K dataset (one 512x512 image per sample) rendering speed with Intel Xeon Gold 6430:
# increase MAX_ASYNC_PAGES for more cores
$ MAX_ASYNC_PAGES=1 python tests/dataset/manual_load.py
Map (num_proc=1): 100%|██████████████| 7473/7473 [02:48<00:00, 44.33 examples/s]
Map (num_proc=1): 100%|██████████████| 1319/1319 [00:27<00:00, 47.28 examples/s]
Metadata
Release files for DeOCR 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deocr-0.3.2.tar.gz | 10.1 kB | Without provenance | Details for deocr-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deocr-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for deocr-0.3.2-py3-none-any.whl |
Total release size: 25.0 kB
Release files / deocr-0.3.2.tar.gz
| Download URL | deocr-0.3.2.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4b6022ecfd2659684b44a76170f99c2784b2b244b37e012f127e169cb6f1b63
|
|
BLAKE2b-256 checksum How to use checksums |
473406899d2d6c92067cd87e929c6a4f4d3465dc9208321bfbe749bc038d5cb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / deocr-0.3.2-py3-none-any.whl
| Download URL | deocr-0.3.2-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c9748c8df67b20b499ef74347134ea29a9a2fba24feff8213c58785ab478950
|
|
BLAKE2b-256 checksum How to use checksums |
943d00edfff895ec2e7a8e5cadd2bdc7991be97265e42ac160d9b4fe6fcc0aa3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for DeOCR 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.