text_plain_output_1.png
from time import time

import cv2 as cv

import imageio as io

import numpy as np # linear algebra

import os

list_train_img = []
a = 0
timea = time()
print('Converting training images to a numpy array...')
for im in os.listdir('../input/train_images'):
    uri = '../input/train_images/' + im
    image = io.imread(uri)
    image = cv.resize(image, (640, 640), interpolation=cv.INTER_AREA)
    list_train_img.append(image)
    a += 1
    if a % 500 == 0:
        print(f'\t{a} images from the training set added to a numpy array')
print('All images from the training set converted to a numpy array!')
train_im = np.asarray(list_train_img)
print(train_im.shape, '\n')
del list_train_img
list_test_img = []
b = 0
print('Converting test images to a numpy array...')
for im_test in os.listdir('../input/test_images'):
    uri = '../input/test_images/' + im_test
    image = io.imread(uri)
    image = cv.resize(image, (640, 640), interpolation=cv.INTER_AREA)
    list_test_img.append(image)
    b += 1
    if b % 500 == 0:
        print(f'\t{b} images from the test set added to a numpy array')
print('All images from the test set converted to a numpy array!\n')
test_im = np.asarray(list_test_img)
print(test_im.shape, '\n')
del list_test_img
timeb = time()
print(f'It took {(timeb - timea) / 60} minutes to complete the conversion')