I am trying to convert image matrices to list, in order to send them as a request to an inference API.
However, as most of my files are 100+ pages(I do pdf2img for getting images), the .tolist()
operation takes a lot of time (Implementation below:)
page_images = [page.image.tolist() for page in pages]
This single line takes forever to run for 100+ page files.
Is there something that can be done to improve the speed?