In this blog post, we will be performing three main tasks:-
Three deep neural network architectures used by me are Vgg16, Resnet50, and MobileNet.
We will start by setting up the Monk AI toolkit and its dependencies on the platform you are working with and I am using Google Colab as my environment.
!git clone https://github.com/Tessellate-Imaging/monk_v1.git
!cd monk_v1/installation/Misc && pip install -r requirements_colab.txt
After setting up the Monk toolkit the next step is to install Kaggle and download the NIH Chest X-Ray Dataset from Kaggle on our Colab notebook.
! pip install -q kaggle
To download any dataset from Kaggle we need to first download the kaggle.json file by going to MyAccount on Kaggle and download a new API. Then we will upload the JSON file on our Colab notebook.
from google.colab import files
files.upload()
Now we can download the zip file of the dataset from Kaggle and unzip it.
! mkdir ~/.kaggle
! cp kaggle.json ~/.kaggle/
! chmod 600 ~/.kaggle/kaggle.json
! kaggle datasets download -d 'nih-chest-xrays/sample'
! unzip -qq sample.zip
The dataset has a total of 15 classes (14 disease classes and 1 “no findings” class).
A Chest X-Ray Image from NIH Chest X-Ray Dataset in Kaggle
Monk provides us three major frameworks to work with i.e., Keras, Pytorch, and Mxnet. We are using Keras framework for this project and the Pandas library is used for visualizing and exploring the dataset. To set up a working directory of a project we initialize a prototype for the framework being used.
from keras_prototype import prototype
import pandas as pd
Two DataFrames were made, one had multi-labeled target values which comprised of 14 disease classes and 1 “no finding” class, for binary classification of images another DataFrame was formed by replacing the disease classes and the “no finding” class by **abnormal **and **normal **respectively
$ df=pd.read_csv('sample/sample_labels.csv')
$ for i in range(len(df)):
df["Finding Labels"][i] = df["Finding Labels"][i].replace("|", ",");
$ df.to_csv("sample/kush1.csv", index=False)
$ for i in range(len(df)):
if df["Finding Labels"][i] == "No Finding":
df["Finding Labels"][i] = "Normal";
else:
df["Finding Labels"][i] = "Abnormal";
$ df.to_csv("sample/kush2.csv",index=False)
#image-classification #monk #chest-x-ray #deep-learning #computer-vision #deep learning