facebookresearch / nougat

Implementation of Nougat Neural Optical Understanding for Academic Documents
https://facebookresearch.github.io/nougat/
MIT License
8.81k stars 560 forks source link

Render PDF pages individually #173

Open Vidminas opened 10 months ago

Vidminas commented 10 months ago

Addresses https://github.com/facebookresearch/nougat/issues/110

This removes multi-processing, which may or may not lead to a performance hit when loading documents with many pages. On the one hand, with this modification, nougat now uses a single process for sequential rendering of all PDF pages. On the other, it now avoids copying bitmaps across processes.

The benefit is that this makes it possible to implement nougat in already parallelised workflows (e.g., when reading multiple PDF files, each in a separate process)

mara004 commented 10 months ago

Big +1 for merging from a pypdfium2 dev POV.

Note, a major problem with the transfer is that, if receiving code is slower than the producing pool, images silently queue up in memory, which can cause enormously high memory loads. (PNG saving particularly exhibits the problem. JPG is usually fast enough to somewhat keep up with the pool.)