Learn practical skills, build real-world projects, and advance your career

XRAY PNEUMONIA DETECTION WITH CONVOLUTIONAL NEURAL NETWORKS, USING THE RESNET18 ARCHITECTURE

Using data from https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia

INTRODUCTION

Pneumonia, simply put, is a killer, accounting for over 15% of under-five deaths. It can't be caused by bacteria, viruses or even fungi. On some occassions, the nature of chest X-ray might help deduce the causative agent of pneumonia in patients.

In the lectures, wardrounds, clinics etc, we're being trained to interpret xrays. But let's face it; learning to interpret xrays perfectly, takes years of real-world practice. Training a machine learning model that can accurately interprete xray images, would really help save time for radiologists and allow them to concentrate on more specialized tasks, while helping other health personel make better interpretations (especially in areas with low workforce of medics).

In this project, i'll be training a model which aims to interprete Xray images and classify them as either normal, or has features of pneumonia.

To do this, I'll be using a chest xray dataset from kaggle (you can access the datasets here: https://www.kaggle.com/paultimothymooney/chest-xray-pneumonia)

This dataset contains almost 6000 images of both normal and abnormal chest xrays. However, the only abnormality captured in this dataset is pneumonia. In the near future, i'll be training a model with a dataset that captures a wide array of chest abnormalities

In order to train this model, I'll be using convolutional neural networks, with the resnet18 architecture, using pytorch and the fastai library.

!pip install -Uqq fastbook
!pip install opendatasets as od
|████████████████████████████████| 727kB 24.4MB/s |████████████████████████████████| 194kB 56.7MB/s |████████████████████████████████| 1.1MB 52.0MB/s |████████████████████████████████| 51kB 9.7MB/s |████████████████████████████████| 61kB 10.3MB/s Collecting opendatasets Downloading https://files.pythonhosted.org/packages/18/99/aaa3ebec81dc347302e730e0daff61735ed2f3e736129553fb3f9bf67ed3/opendatasets-0.1.10-py3-none-any.whl Collecting as Downloading https://files.pythonhosted.org/packages/b4/08/226c133ec497d25a63edb38527c02db093c7d89e6d4cdc91078834486a5d/as-0.1-py3-none-any.whl Collecting od Downloading https://files.pythonhosted.org/packages/92/5b/73044c22c5f83caebf36eb4c28dfdc6399218e8d99d89bb2057d05c68260/od-1.0-py3-none-any.whl Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from opendatasets) (4.41.1) Requirement already satisfied: kaggle in /usr/local/lib/python3.6/dist-packages (from opendatasets) (1.5.10) Requirement already satisfied: click in /usr/local/lib/python3.6/dist-packages (from opendatasets) (7.1.2) Requirement already satisfied: python-dateutil in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2.8.1) Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2.23.0) Requirement already satisfied: six>=1.10 in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (1.15.0) Requirement already satisfied: urllib3 in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (1.24.3) Requirement already satisfied: python-slugify in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (4.0.1) Requirement already satisfied: certifi in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2020.12.5) Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle->opendatasets) (2.10) Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle->opendatasets) (3.0.4) Requirement already satisfied: text-unidecode>=1.3 in /usr/local/lib/python3.6/dist-packages (from python-slugify->kaggle->opendatasets) (1.3) Installing collected packages: opendatasets, as, od Successfully installed as-0.1 od-1.0 opendatasets-0.1.10
import fastbook
fastbook.setup_book()
Mounted at /content/gdrive
import opendatasets as od
from fastbook import *
from fastai.vision.widgets import *