在python中加载图像进行处理的最快方法 [英] fastest way to load images in python for processing

查看:67
本文介绍了在python中加载图像进行处理的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以numpy数组的形式在我的8GB内存中加载10000张以上的图像.到目前为止,我已经尝试了cv2.imread,keras.preprocessing.image.load_image,pil,imageio,scipy.最快的方法,但我不知道是哪一个.

I want to load more than 10000 images in my 8gb ram in the form of numpy arrays.So far I have tried cv2.imread,keras.preprocessing.image.load_image,pil,imageio,scipy.I want to do it the fastest way possible but I can't figure out which on is it.

推荐答案

最快的方法之一是让您的多处理器并行执行您的工作,它要求并行执行所需的工作,它使多个处理器可以完成您的任务同时运行并发不是问题.这种并行处理使您可以快速处理事情.现在,下面的示例只是其外观的简单草图,您可以练习一些小功能,然后将其与您自己的代码集成:

One of the Fastest way is to get your multiprocessors do your job in Parallel it asks for parallelisation of your desired job, it brings multiple processors to work on your tasks at the same time when concurrent running isn't an issue. This parallel processing enables you for a rapid things. Now the example below is just a simple sketch out of how it might look, you can practice with small functions and then integrate it with your own code :

from multiprocessing import Process
    #this is the function to be parallelised
    def image_load_here(image_path):
        pass 

if __name__ == '__main__':
    #Start the multiprocesses and provide your dataset.
    p = Process(target=image_load_here,['img1', 'img2', 'img3', 'img4'])
    p.start()
    p.join()

随时写信,请帮忙.

这篇关于在python中加载图像进行处理的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆