application_vnd.jupyter.stderr_output_1.png
from PIL import Image

import cv2

import keras

import matplotlib.pyplot as plt

import numpy as np

import os

infectados = os.listdir('../input/cell_images/cell_images/Parasitized/')
saudaveis = os.listdir('../input/cell_images/cell_images/Uninfected/')

data = []
labels = []
for i in infectados:
    try:
        image = cv2.imread('../input/cell_images/cell_images/Parasitized/' + i)
        image_array = Image.fromarray(image, 'RGB')
        resize_img = image_array.resize((50, 50))
        rotated30 = resize_img.rotate(30)
        rotated60 = resize_img.rotate(60)
        blur = cv2.blur(np.array(resize_img), (10, 10))
        data.append(np.array(resize_img))
        data.append(np.array(rotated30))
        data.append(np.array(rotated60))
        data.append(np.array(blur))
        labels.append(1)
        labels.append(1)
        labels.append(1)
        labels.append(1)
    except AttributeError:
for s in saudaveis:
    try:
        image = cv2.imread('../input/cell_images/cell_images/Uninfected/' + s)
        image_array = Image.fromarray(image, 'RGB')
        resize_img = image_array.resize((50, 50))
        rotated30 = resize_img.rotate(30)
        rotated60 = resize_img.rotate(60)
        data.append(np.array(resize_img))
        data.append(np.array(rotated30))
        data.append(np.array(rotated60))
        labels.append(0)
        labels.append(0)
        labels.append(0)
    except AttributeError:

celulas = np.array(data)
classes = np.array(labels)

import matplotlib.pyplot as plt
n = 0
for i in range(49):
    n += 1
    r = np.random.randint(0, celulas.shape[0], 1)
    (plt.xticks([]), plt.yticks([]))

np.random.seed(0)
n = np.arange(celulas.shape[0])
np.random.shuffle(n)
cells = celulas[n]
labels = classes[n]

cells = cells.astype(np.float32)
labels = labels.astype(np.int32)
cells = cells / 255

num_classes = len(np.unique(labels))
len_data = len(cells)
y_tr = keras.utils.to_categorical(y_tr, num_classes)
y_val = keras.utils.to_categorical(y_val, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)

print(y_tr.shape, y_val.shape, X_tr.shape, X_val.shape)