标签:数据预处理 -o file 设备 for creat split for 循环 sda
import glob import os import cv2 ### Loop through all jpg files in the current folder ### Resize each one to size 600x600 for image_filename in glob.glob("*.jpg"): ### Read in the image data
img = cv2.imread(image_filename) ### Resize the image img = cv2.resize(img, (600, 600))
import glob import os import cv2 import concurrent.futures def load_and_resize(image_filename): ### Read in the image data img = cv2.imread(image_filename) ### Resize the image img = cv2.resize(img, (600, 600)) ### Create a pool of processes. By default, one is created for each CPU in your machine. with concurrent.futures.ProcessPoolExecutor() as executor: ### Get a list of files to process image_files = glob.glob("*.jpg") ### Process the list of files, but split the work across the process pool to use all CPUs ### Loop through all jpg files in the current folder ### Resize each one to size 600x600 executor.map(load_and_resize, image_files)
「executor.map()」将你想要运行的函数和列表作为输入,列表中的每个元素都是我们函数的单个输入。
python | concurrent.futures模块提升数据处理速度
标签:数据预处理 -o file 设备 for creat split for 循环 sda
原文地址:https://www.cnblogs.com/geo-will/p/9757016.html