text_plain_output_1.png
from PIL import Image

import cv2

import numpy as np

import os

image_dir = 'datasets/'
no_tumour = os.listdir(image_dir + 'no/')
yes_tumour = os.listdir(image_dir + 'yes/')
dataset = []
label = []

for i, image_name in enumerate(no_tumour):
    if image_name.split('.')[1] == 'jpg':
        image = cv2.imread(image_dir + 'no/' + image_name)
        image = Image.fromarray(image, 'RGB')
        image = image.resize((64, 64))
        dataset.append(np.array(image))
        label.append(0)
for i, image_name in enumerate(yes_tumour):
    if image_name.split('.')[1] == 'jpg':
        image = cv2.imread(image_dir + 'yes/' + image_name)
        image = Image.fromarray(image, 'RGB')
        image = image.resize((64, 64))
        dataset.append(np.array(image))
        label.append(1)

print(dataset)