eynollah
eynollah copied to clipboard
performance with high-res images
Sometimes the input comes with DPI 600 or beyond. It seems to me this makes eynollah become much slower. Larger resolution might be needed for newspapers, but there is always a point at which result quality does increase. I would assume that a single downscaling interpolation after import should not be too costly.
The documentation of allow_scaling says that it would also scale down images. But the implementation does not look like that's the case:
https://github.com/qurator-spk/eynollah/blob/8d5079c909b662eda0b4acf5ae2908455f0ff939/qurator/eynollah/eynollah.py#L437-L444
IIUC only too small images get upsampled. I'd expect a secondary DPI_THRESHOLD2 at which downsampling would begin.
Sometimes the input comes with DPI 600 or beyond. It seems to me this makes eynollah become much slower. Larger resolution might be needed for newspapers, but there is always a point at which result quality does increase. I would assume that a single downscaling interpolation after import should not be too costly.
The documentation of
allow_scalingsays that it would also scale down images. But the implementation does not look like that's the case:https://github.com/qurator-spk/eynollah/blob/8d5079c909b662eda0b4acf5ae2908455f0ff939/qurator/eynollah/eynollah.py#L437-L444
IIUC only too small images get upsampled. I'd expect a secondary
DPI_THRESHOLD2at which downsampling would begin.
Two points about your comment. First, a DPI of 600 can not alone make eynollah slower. The problem with high resolution documents is (without allow_scaling option) that they can not be scaled down automatically. The allow_scaling should be True and if columns are detected correctly then down scaling can be a case.
The second point, allow_scaling lets you to scale down for documents with DPI bigger than 300. But scaling down will happen if its needed. This means if scale of document is much bigger than of "training scale" then scaling down will be applied.
@vahidrezanezhad please help me understand:
First, a DPI of 600 can not alone make eynollah slower.
How is that? I can see lots of CPU-bound image processing. Most algorithms are O(n²). And even for the GPU-bound parts: they each need to downscale to the fixed input size of the respective model.
The problem with high resolution documents is (without allow_scaling option) that they can not be scaled down automatically.
Why not? Downsampling (with suitable interpolation algorithm) should be trivial – as opposed to upsampling, for which you built an elaborate model.
allow_scaling lets you to scale down for documents with DPI bigger than 300. But scaling down will happen if its needed. This means if scale of document is much bigger than of "training scale" then scaling down will be applied.
I am confused. Where does this actually happen?
I am confused. Where does this actually happen?
Here: https://github.com/qurator-spk/eynollah/blob/13bc2378d952f1ef7637480304d5383a45af789d/qurator/eynollah/eynollah.py#L2007-L2008
https://github.com/qurator-spk/eynollah/blob/13bc2378d952f1ef7637480304d5383a45af789d/qurator/eynollah/eynollah.py#L373
https://github.com/qurator-spk/eynollah/blob/13bc2378d952f1ef7637480304d5383a45af789d/qurator/eynollah/eynollah.py#L318-L323
(So, essentially, if the column detector is confident enough, there can be downsampling.)