text_plain_output_1.png
from PIL import Image

import cv2

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
plt.figure(1, figsize=(15, 9))
n = 0
for i in range(49):
    n += 1
    r = np.random.randint(0, celulas.shape[0], 1)
    plt.subplot(7, 7, n)
    plt.subplots_adjust(hspace=0.5, wspace=0.5)
    plt.imshow(celulas[r[0]])
    plt.title('{} : {}'.format('Infectados' if classes[r[0]] == 1 else 'Saudaveis', classes[r[0]]))
    (plt.xticks([]), plt.yticks([]))
plt.show()