text_plain_output_1.png
from keras.preprocessing.image import ImageDataGenerator

import tensorflow as tf

ROOT = '/kaggle/input/covid19-xray-dataset-train-test-sets/xray_dataset_covid19/'
TRAIN_DIR = ROOT + 'train'
TEST_IMAGE_DIR = '/kaggle/input/covid19-test-sample/pneumonia_test_1.jpg'
VAL_DIR = ROOT + 'test'
NORMAL_DIR = ROOT + 'train/NORMAL/IM-0101-0001.jpeg'
PNEUMONIA_DIR = ROOT + 'train/PNEUMONIA/B59DD164-51D5-40DF-A926-6A42DD52EBE8.jpeg'
RESIZE_WIDTH = 256
RESIZE_HEIGHT = 256
NORMAL_TITLE = 'Normal'
PNEUMONIA_TITLE = 'Pneumonia'
BATCH_SIZE = 32
TARGET_WIDTH = 64
TARGET_HEIGHT = 64
CLASS_MODE = 'binary'
RESCALE = 255
SHEAR_RANGE = 0.25
VERTICAL_FLIP = False
HORIZONTAL_FLIP = True
ZOOM_RANGE = 0.25
VALIDATION_SPLIT = 0.15
EPOCH = 20
SUPTITLE = 'Train vs Validation'
LOSS_LABEL = 'Loss'
ACCURACY_LABEL = 'Accuracy'
AUC_LABEL = 'ROC-AUC'
RECALL_LABEL = 'Recall'
TRAIN_LOSS_LABEL = 'Training Loss'
VALIDATION_LOSS_LABEL = 'Validation Loss'
TRAIN_ACCURACY_LABEL = 'Training Accuracy'
VALIDATION_ACCURACY_LABEL = 'Validation Accuracy'
TRAIN_AUC_LABEL = 'Training AUC'
VALIDATION_AUC_LABEL = 'Validation AUC'
TRAIN_RECALL_LABEL = 'Training Recall'
VALIDATION_RECALL_LABEL = 'Validation Recall'
UPPER_RIGHT = 'upper right'
LOWER_RIGHT = 'lower right'
COLOR_CHANNEL = 3
CONV1_FILTERS = 48
CONV1_KERNEL = 3
CONV1_ACTIVATION = 'relu'
POOL1_SIZE = 3
POOL1_STRIDE = 1
CONV2_FILTERS = 32
CONV2_KERNEL = 3
CONV2_ACTIVATION = 'relu'
DROPOUT = 0.3
POOL2_SIZE = 2
POOL2_STRIDE = 1
CONV3_FILTERS = 16
CONV3_KERNEL = 3
CONV3_ACTIVATION = 'relu'
FC_ACTIVATION = 'relu'
FC_UNITS = 128
OUTPUT_ACTIVATION = 'sigmoid'
OUTPUT_UNITS = 1
OPTIMIZER = 'adam'
LOSS_CLASS = 'binary_crossentropy'
ACCURACY_METRICS = 'accuracy'
AUC_METRICS = tf.keras.metrics.AUC()
RECALL_METRICS = tf.keras.metrics.Recall()

val_gen = ImageDataGenerator(rescale=1.0 / RESCALE)
val_set = val_gen.flow_from_directory(VAL_DIR, batch_size=BATCH_SIZE, target_size=(TARGET_WIDTH, TARGET_HEIGHT), class_mode=CLASS_MODE)