|
| 1 | +# 6) Creating a Segmentation app consuming a MONAI Bundle |
| 2 | + |
| 3 | +## Setup |
| 4 | + |
| 5 | +```bash |
| 6 | +# Create a virtual environment with Python 3.7. |
| 7 | +# Skip if you are already in a virtual environment. |
| 8 | +# (JupyterLab dropped its support for Python 3.6 since 2021-12-23. |
| 9 | +# See https://github.com/jupyterlab/jupyterlab/pull/11740) |
| 10 | +conda create -n monai python=3.7 pytorch torchvision jupyterlab cudatoolkit=11.1 -c pytorch -c conda-forge |
| 11 | +conda activate monai |
| 12 | + |
| 13 | +# Launch JupyterLab if you want to work on Jupyter Notebook |
| 14 | +jupyter-lab |
| 15 | +``` |
| 16 | + |
| 17 | +## Executing from Jupyter Notebook |
| 18 | + |
| 19 | +```{toctree} |
| 20 | +:maxdepth: 4 |
| 21 | +
|
| 22 | +../../notebooks/tutorials/06_monai_bundle_app.ipynb |
| 23 | +``` |
| 24 | + |
| 25 | +```{raw} html |
| 26 | +<p style="text-align: center;"> |
| 27 | + <a class="sphinx-bs btn text-wrap btn-outline-primary col-md-6 reference external" href="../../_static/notebooks/tutorials/06_monai_bundle_app.ipynb"> |
| 28 | + <span>Download 06_monai_bundle_app.ipynb</span> |
| 29 | + </a> |
| 30 | +</p> |
| 31 | +``` |
| 32 | + |
| 33 | +## Executing from Shell |
| 34 | + |
| 35 | +```bash |
| 36 | +# Clone the github project (the latest version of main branch only) |
| 37 | +git clone --branch main --depth 1 https://github.com/Project-MONAI/monai-deploy-app-sdk.git |
| 38 | + |
| 39 | +cd monai-deploy-app-sdk |
| 40 | + |
| 41 | +# Install monai-deploy-app-sdk package |
| 42 | +pip install monai-deploy-app-sdk |
| 43 | + |
| 44 | +# Download/Extract ai_spleen_bundle_data zip file from https://drive.google.com/file/d/1cJq0iQh_yzYIxVElSlVa141aEmHZADJh/view?usp=sharing |
| 45 | + |
| 46 | +# Download ai_spleen_bundle_data.zip |
| 47 | +pip install gdown |
| 48 | +gdown https://drive.google.com/uc?id=1cJq0iQh_yzYIxVElSlVa141aEmHZADJh |
| 49 | + |
| 50 | +# After downloading ai_spleen_bundle_data.zip from the web browser or using gdown, |
| 51 | +unzip -o ai_spleen_bundle_data.zip |
| 52 | + |
| 53 | +# Install necessary packages from the app; note that numpy-stl and trimesh are only |
| 54 | +# needed if the application uses the STL Conversion Operator |
| 55 | +pip install monai pydicom SimpleITK Pillow nibabel scikit-image numpy-stl trimesh |
| 56 | + |
| 57 | +# Local execution of the app directly or using MONAI Deploy CLI |
| 58 | +python examples/apps/ai_spleen_seg_app/app.py -i dcm/ -o output -m model.ts |
| 59 | +# or alternatively, |
| 60 | +monai-deploy exec ../examples/apps/ai_spleen_seg_app/app.py -i dcm/ -o output -m model.ts |
| 61 | + |
| 62 | +# Package app (creating MAP docker image) using `-l DEBUG` option to see progress. |
| 63 | +# This assumes that nvidia docker is installed in the local machine. |
| 64 | +# Please see https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker to install nvidia-docker2. |
| 65 | +monai-deploy package examples/apps/ai_spleen_seg_app --tag seg_app:latest --model model.ts -l DEBUG |
| 66 | + |
| 67 | +# Run the app with docker image and input file locally |
| 68 | +monai-deploy run seg_app:latest dcm/ output |
| 69 | +``` |
0 commit comments