Creating MedNIST Classifier App

This tutorial demos the process of packaging up a trained model using MONAI Deploy App SDK into an artifact which can be run as a local program performing inference, a workflow job doing the same, and a Docker containerized workflow execution.


# Create a virtual environment with Python 3.8.
# Skip if you are already in a virtual environment.
conda create -n mednist python=3.8 pytorch jupyterlab cudatoolkit=11.1 -c pytorch -c conda-forge
conda activate mednist

# Launch JupyterLab if you want to work on Jupyter Notebook

Executing from Shell

# Clone the github project (the latest version of the main branch only)
git clone --branch main --depth 1

cd monai-deploy-app-sdk

# Install monai-deploy-app-sdk package
pip install monai-deploy-app-sdk

# Download/Extract from

# Download
pip install gdown

# After downloading from the web browser or using gdown
unzip -o

# Install necessary packages required by the app
pip install -r examples/apps/mednist_classifier_monaideploy/requirements.txt

# Local execution of the app using environment variables for input, output, and model paths
# instead of command line options, `-i input/AbdomenCT_007000.jpeg -o output -m`
export HOLOSCAN_INPUT_PATH="input/AbdomenCT_007000.jpeg"
export HOLOSCAN_OUTPUT_PATH="output"

python examples/apps/mednist_classifier_monaideploy/

# See the classification result
cat output/output.json

# Package app (creating MAP docker image) using `-l DEBUG` option to see progress.
# This assumes that nvidia docker is installed in the local machine.
# Please see to install nvidia-docker2.

# Need to move the model file to a clean folder as a workaround of an known packaging issue in v0.6
mkdir -p mednist_model && rm -rf mednist_model/* && cp mednist_model/

monai-deploy package examples/apps/mednist_classifier_monaideploy/ \
    --config examples/apps/mednist_classifier_monaideploy/app.yaml \
    --tag mednist_app:latest \
    --models mednist_model/ \
    --platform x64-workstation \
    -l DEBUG

# Note: for AMD GPUs, nvidia-docker is not required, but the dependency of the App SDK, namely Holoscan SDK
#       has not been tested to work with a ROCM base image.

# Run the app with docker image and input file locally
rm -rf output
monai-deploy run mednist_app-x64-workstation-dgpu-linux-amd64:latest -i input -o output
cat output/output.json