Skip to content

ocr(paddleocr-vl-1.8): stage chunk temp images as threaded lossless BMP - #224

Merged
davanstrien merged 1 commit into
mainfrom
ocr/paddleocr-vl-1.8-bmp-staging
Dec 4, 2026
Merged

davanstrien merged 1 commit into
mainfrom
ocr/paddleocr-vl-1.8-bmp-staging

Conversation

@davanstrien

Copy link
Copy Markdown
Owner

Summary

Speeds up per-chunk image staging in ocr/paddleocr-vl-1.8.py by replacing sequential PNG(compress_level=1) writes with parallel uncompressed 24-bit RGB .bmp writes sized from CPU_CORES (capped at 8).

  • Thread safety: Raw dataset cells are read sequentially on the main thread (avoiding cross-thread datasets/Arrow access); PIL decode, EXIF/mode normalization, and BMP writes run in a ThreadPoolExecutor (_stage_chunk_images) while preserving exact row ordering and per-row error isolation.
  • Worker cap: _image_workers() sizes threads from CPU_CORES (the HF Jobs quota, capped at 8) rather than host os.cpu_count().
  • Minor hygiene: Adds strict=True to zip(valid_indices, results, strict=True) and documents the ablation in ocr/CLAUDE.md.
  • Disk trade-off: Uncompressed BMP is larger on ephemeral /tmp (~18 MB/page for 6 MP book scans → ~1.15 GB per 64-page chunk, cleaned up immediately at the end of each chunk's TemporaryDirectory).

Prior ablation evidence

Measured in a controlled 64-page ablation on a10g-small (Job 6b118264):

  • Sequential PNG(compress_level=1): 21.84 s encode, 41.86 s predict() (1.53 pg/s).
  • 8-thread lossless BMP: 2.41 s encode (9.1× faster), 33.11 s predict() (1.93 pg/s, +26%), with 64/64 exact text match vs PNG.
  • use_queues=True and vl_rec_max_concurrency=64 gave no meaningful gain in the same ablation and are intentionally left out.

Verification

  • python3 -m py_compile ocr/paddleocr-vl-1.8.py
  • Local unit assertions for _image_workers (CPU_CORES parsing/caps) and _stage_chunk_images (ordering, corrupt-row isolation, empty slice, single-worker path, pixel-for-pixel equality vs PNG across RGB/RGBA inputs).
  • Fresh GPU smoke run on this exact commit before merge (left for review session).

@davanstrien
davanstrien merged commit 4d27aab into main Dec 4, 2026
1 check passed
@davanstrien
davanstrien deleted the ocr/paddleocr-vl-1.8-bmp-staging branch December 4, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant