eynollah icon indicating copy to clipboard operation
eynollah copied to clipboard

performance with high-res images

Open bertsky opened this issue 3 years ago • 3 comments
trafficstars

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.

bertsky avatar Aug 16 '22 14:08 bertsky

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.

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 avatar Aug 18 '22 11:08 vahidrezanezhad

@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?

bertsky avatar Aug 30 '22 10:08 bertsky

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.)

bertsky avatar Feb 16 '23 18:02 bertsky