text_plain_output_1.png
from openslide import OpenSlide

from tqdm import tqdm

import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import tensorflow as tf

train_df = pd.read_csv('../input/mayo-clinic-strip-ai/train.csv')
test_df = pd.read_csv('../input/mayo-clinic-strip-ai/test.csv')

train_df_sample = train_df.iloc[:754].copy()

def preprocess(image_path):
    slide = OpenSlide(image_path)
    region = (1000, 1000)
    size = (5000, 5000)
    image = slide.read_region(region, 0, size)
    image = image.convert('RGB')
    image = tf.image.resize(image, (256, 256))
    image = np.array(image)
    return image
x_train = []
for i in tqdm(train_df_sample['file_path']):
    x1 = preprocess(i)
    x_train.append(x1)

x_train = np.array(x_train)
y_train = np.array(train_df_sample['target'])
X_train, X_test, Y_train, Y_test = train_test_split(x_train, y_train, test_size=0.2)