text_plain_output_1.png
from keras.preprocessing.image import ImageDataGenerator

import os

import os

import pandas as pd

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

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

train_img_csv = '../input/my-pre-data/MURA-v1.1/abdekho_train.csv'
train_images_paths = pd.read_csv(os.path.join(train_img_csv), dtype=str, header=None)
train_images_paths.columns = ['image_path']
valid_img_csv = '../input/my-pre-data/MURA-v1.1/abdekho_valid.csv'
valid_images_paths = pd.read_csv(os.path.join(valid_img_csv), dtype=str, header=None)
valid_images_paths.columns = ['image_path']
train_images_paths['label'] = train_images_paths['image_path'].map(lambda x: '1' if 'positive' in x else '0')
train_images_paths['category'] = train_images_paths['image_path'].apply(lambda x: x.split('/')[2])
valid_images_paths['label'] = valid_images_paths['image_path'].map(lambda x: '1' if 'positive' in x else '0')
valid_images_paths['category'] = valid_images_paths['image_path'].apply(lambda x: x.split('/')[2])

train_images_paths_XR_FINGER = train_images_paths[train_images_paths['category'] == 'XR_FINGER']
valid_images_paths_XR_FINGER = valid_images_paths[valid_images_paths['category'] == 'XR_FINGER']

images_path_dir = '../input/my-pre-data'
datagen = ImageDataGenerator(samplewise_center=True, samplewise_std_normalization=True, rotation_range=30, width_shift_range=0.1, height_shift_range=0.1, zoom_range=0.1, horizontal_flip=True, vertical_flip=True)
valid_datagen = ImageDataGenerator(rescale=1.0 / 255, rotation_range=30)
targetsize = (224, 224)
classmode = 'binary'
batchsize = 32
train_generator = datagen.flow_from_dataframe(dataframe=train_images_paths_XR_FINGER, directory=images_path_dir, x_col='image_path', y_col='label', target_size=targetsize, class_mode=classmode, batch_size=batchsize, shuffle=True)
valid_generator = valid_datagen.flow_from_dataframe(dataframe=valid_images_paths_XR_FINGER, directory=images_path_dir, x_col='image_path', y_col='label', target_size=targetsize, class_mode=classmode, batch_size=batchsize, shuffle=True)