I am using the Chest X-Ray Images (Pneumonia) dataset from Kaggle to train a simple CNN for pneumonia detection. The dataset splits pneumonia into two categories: viral and bacterial. The model does not differentiate between these two categories.
Classifier is deployed via FastAPI + Docker. The endpoint accepts uploaded files and infers from the image whether there is pneumonia.
Next steps: push to a public URL.
Steps to spin the server on your local network:
- Setup Docker
- Run
pip install -r requirements.txt
- Create a Kaggle account and generate an API token from
kaggle.com/USERNAME/account
(this will prompt you to download akaggle.json
file which contains the credentials) - a) Set the Kaggle credentials as environment variables with:
export KAGGLE_USERNAME = [kaggle username]
export KAGGLE_KEY = [generated key]
- b) OR use
direnv
to populate credentials in.envrc
(see.envrc.example
for formatting) - Run
python classifier/train.py
to train the model (Note: this step is optional as repo already comes with model weights) - Build Docker container using
docker build . -t app
- Run container using
docker run -d -p 8080:5000 app
This deploys the app to local network http://localhost:8080/
. You may have to replace localhost
with your ip address if it doesn't work.
The easiest way to make a POST request is to go to http://localhost:8080/docs
and uploading an image from the /pneumonia/predict
.