Skip to content

Pneumonia Detection

This is an example to demonstrate how to use Deep Java Library to detect Pneumonia based on Chest X-ray images.

For more details, please follow Chest X-Ray Images (Pneumonia) on Kaggle and this Kernel.

You can obtain the training script from the above Kernel. We will use the model and DJL for prediction.

Setup

run the following command to build the project:

./gradlew build

Run prediction on images

Prepare images

You can download some of the X-ray images for testing dataset on kaggle. We will use a default image for prediction if no input image is specified.

Prepare trained model

You can find a trained model here, download and unzip it.

Run prediction

run the following command for linux/macOS:

mkdir models
cd models
curl https://djl-ai.s3.amazonaws.com/resources/demo/pneumonia-detection-model/saved_model.zip | jar xv
cd ..

./gradlew run -Dai.djl.repository.zoo.location=models/saved_model

run the following command for Windows:

mkdir models
cd models
curl https://djl-ai.s3.amazonaws.com/resources/demo/pneumonia-detection-model/saved_model.zip | jar xv
cd ..

..\gradlew run -Dai.djl.repository.zoo.location=models/saved_model

Reference:

  1. Detecting Pneumonia based on chest X-ray images using Depthwise Convolution
  2. DJL TensorFlow Engine
  3. DJL TensorFlow Documentation