I have the following function:
def rescale(file): img = cv2.imread(file) return img I am trying to upscale a series of images, but each image takes 20 seconds to process. I want to use multithreading in order to create a faster program.
I have a list of my images :
file_list = ['page-136.jpg', 'page-0.jpg', 'page-11.jpg', 'page-12.jpg', 'page-13.jpg', 'page-14.jpg', 'page-37.jpg', 'page-58.jpg', 'page-62.jpg', 'page-64.jpg', 'page-134.jpg', 'page-135.jpg'] and I have the following code to add multithreading:
import tqdm from concurrent.futures import ThreadPoolExecutor, as_completed with ThreadPoolExecutor(max_workers=1000) as executor: future_to_response = { executor.submit(Upscale, i): i for i in file_list } t = tqdm.tqdm(total=len(future_to_response)) for future in as_completed(future_to_response): domain = future_to_response[future] result = future.result() t.update() This however does not work, and I appear to be stuck. Can someone guide me in the right direction?