Kartikey Sharma's other Models Reports

Major Concepts

 

Sign-Up/Login to access Several ML Models and also Deploy & Monetize your own ML solutions for free

Models Home » Domain Usecases » Health Care and Pharmaceuticals » Retinal OCT Image Classification

Retinal OCT Image Classification

Models Status

Model Overview


Retinal OCT Images


Retinal Optical Coherence (or OCT) is an imaging technique used to capture high-resolution cross-sections of the retinas of living patients.


Usage


The model can be used in the healthcare sector to identify the defects in the retina without much significant human intervention. This can assist in faster diagnosis and subsequent treatment of the infection.

Data Source


The dataset was taken from mendeley. It contains three folders - train, test, and val, and each folder is further divided into four subfolders - CNV, DME, DRUSEN, and NORMAL (disease types). The total number of images is approximately 84k. The images were obtained from Shiley Eye Institute of the University of California San Diego, the California Retinal Research Foundation, Medical Center Ophthalmology Associates, the Shanghai First People’s Hospital, and Beijing Tongren Eye Center between July 1, 2013, and March 1, 2017.

Data Preprocessing

This step involved scaling the images to size 128x128, with 3 channels, and appending them to numpy arrays. The number of samples in train, validation and test set are 20008, 32 and 968, respectively.


def get_array (path) :

X = []
y = []

for label, disease in enumerate(os.listdir(path)) :




# resize and append
for count, image in enumerate(os.listdir(os.path.join(path, disease))) :
X.append(img_to_array(
fromarray(
cv2.resize(
cv2.imread(
os.path.join(os.path.join(path, disease),image)),(128,128)))))

# only 5k imgs
y.append(label)
if count > 5e3 :
break

X = np.array(X)
y = np.array(y)

return X/255.0, to_categorical(y)



X_train, y_train = get_array(paths[0])
X_test , y_test = get_array(paths[1])
X_valid, y_valid = get_array(paths[2])


To visualize some of the image samples, use matplotlib to plot images from the three classes.

plt.figure(figsize = (20,20))

i = 0

while i < 16 :

x = np.random.randint(0, 20000)
plt.subplot(4, 4, i+1)
plt.imshow(X_train[x])
plt.axis('off')
plt.title(info[np.argmax(y_train[x])])

i += 1
plt.show()






Model

Two methods were defined to construct the convolution block and fully connected block. The convolution blocks consists of Conv2D, MaxPooling2D, BatchNormalization, Dropout and LeakyReLU (with a slope of 0.2) layers. And the fully connected block consists of Dense with l2 regularization, BatchNormalization, Dropout and LeakyReLU layers.


def conv_layer (filterx) :

model = Sequential()

model.add(Conv2D(filterx, (4,4), padding = 'same', use_bias = False))
model.add(BatchNormalization())
model.add(Dropout(.2))
model.add(LeakyReLU())
model.add(MaxPooling2D((2, 2)))

return model

def dens_layer (hiddenx) :

model = Sequential()

model.add(Dense(hiddenx, kernel_regularizer = 'l2'))
model.add(BatchNormalization())
model.add(Dropout(.2))
model.add(LeakyReLU())

return model



Conv2D -

Convolution layers are the feature detectors for images. The filters move across the width and height of the image performing convolution operations and storing the values.


MaxPooling2D -

Pooling layer with mode = ‘max’ is used to reduce the image and retain the dominant features in the region of the filter applied.


BatchNormalization -

Normalize the hidden features to have zero mean and unit standard deviation. It helps in faster convergence and prevents internal covariate shift.


LeakyReLU -

Gives a small value for negative inputs instead of completely making them zero.


def cnn (filter1, filter2, filter3, hidden1) :

model = Sequential([

Input((128,128,3,)),
conv_layer(filter1),
conv_layer(filter2),
conv_layer(filter3),
Flatten(),
dens_layer(hidden1),
Dense(4, activation = 'softmax')
])

model.compile(loss = 'categorical_crossentropy', optimizer = 'adam', metrics = ['accuracy'])
return model


model summary,




Accuracy




Confusion Matrix



0 comments