text_plain_output_1.png
from joblib import Parallel, delayed

import matplotlib.pyplot as plt

import numpy as np

import numpy as np

import numpy as np # linear algebra

import os

img_size = 32

def process_image(img_file):
    img = cv2.imread(img_file, cv2.IMREAD_GRAYSCALE)
    img = cv2.resize(img, (img_size, img_size))
    return img

start = time.time()
X_data = []
Y_data = []
for j in range(10):
    path = os.path.join('../input/state-farm-distracted-driver-detection/imgs/train', 'c' + str(j), '*.jpg')
    files = glob.glob(path)
    X_data.extend(Parallel(n_jobs=2)((delayed(process_image)(im_file) for im_file in files)))
    Y_data.extend([j] * len(files))
end = time.time() - start

X_data = np.array(X_data)
Y_data = np.array(Y_data)
np.random.shuffle(X_data)
np.random.shuffle(Y_data)
X_data = X_data[0:1000]
Y_data = Y_data[0:1000]

plt.imshow(X_data[0], cmap='gray')
plt.show()
print(Y_data[0])