image_output_1.png
import cupy as np

import cv2

import matplotlib.pyplot as plt

import os

image_size = 200
labels = ['PNEUMONIA', 'NORMAL']
def data_loader(data_dir):
    data = list()
    for label in labels:
        path = os.path.join(data_dir, label)
        class_num = labels.index(label)
        for img in os.listdir(path):
            img_arr = cv2.imread(os.path.join(path, img), 0)
            resized_arr = cv2.resize(img_arr, (image_size, image_size))
            data.append([resized_arr, class_num])
    return data

val = data_loader('../input/chest-xray-pneumonia/chest_xray/val')
test = data_loader('../input/chest-xray-pneumonia/chest_xray/test')
train = data_loader('../input/chest-xray-pneumonia/chest_xray/train')

plt.figure(figsize=(6, 6))
plt.imshow(np.asnumpy(train[2][0]))