This document explains how to install the improved version of SlicerNNInteractive in a computer. It adds benchmarks features to the original SlicerNNInteractive.
SlicerNNInteractive needs to be set up on the server side and the client side. The server side needs relatively heavy compute, as described here:
You need a Linux or Windows computer with Nvidia GPU. 10GB of VRAM is recommended. Small objects should work with <6GB. nnInteractive supports Python 3.10+
The client machine can be the same as the server machine.
You can install the server side of SlicerNNInteractive by following these steps:
nnInteractive supports Python 3.10+. If a compatible version is already installed on your computer, there is no need to install a new one. Otherwise, one can install the last Python version. Depending on the system, python installed version can be displayed by one off the following commands:
python --version
python3 --versionBefore passing to next steps, be sure that the displayed Python version is >= 3.10
To isolate the server configuration from the system's environment, you need to create a Python virtual environment (e.g., using conda or venv) by specifying a location on your disk and activating that environment.
For example, on Linux, with venv, you can accomplish this using these commands (after being at the chosen installation folder):
python3 -m venv .server_env
source .server_env/bin/activateIn Windows, the following commands should be used :
python3 -m venv .server_env
.server-venv\Scripts\activate.batNote that if python3 doesn't work, it could be replaced by python in the latter command. Also, .server_env is an arbitrary name we give to the virtual environment.
Next, you can install the nnInteractive server to this environment with the following command:
pip install nninteractive-slicer-serverDependancies installation may take several minutes.
By default, SlicerNNInteractive only run on GPU. To make it compatible with both CPU and GPU, replace the .server_env\Lib\site-packages\nninteractive_slicer_server\main.py file with this patched main.py file.
Note that .server_env corresponds here to the name of the virtual environment created at Step 2.
Once the server is installed and patched, you can start it with this command:
nninteractive-slicer-server --host 0.0.0.0 --port 1527 --device gpuIf you would like to use a different port, say 1627, replace --port 1527 with --port 1627.
Also, the --device option is added to the patched server so that users may directly specify their preferred execution device (cpu or gpu). It defaults to gpu, when supported.
Note
Remember that you'll have to start the server again if it was stopped for some reason (e.g., after rebooting your machine). To do so, activate your virtual Python environment with the source command at Step 2 and run nninteractive-slicer-server --host 0.0.0.0 --port 1527 again to start the server.
Note
When starting the server, you can ignore the message nnUNet_raw is not defined [...] how to set this up.. Setting up these environment variables is not necessary when using SlicerNNInteractive.
- Download and install latest version of 3D Slicer
- Clone or download the improved
SlicerNNInteractiverepository. - Install the downloaded SlicerNNInteractive extension: Open the cloned repository folder and go to the
slicer_plugin/SlicerNNInteractivesubfolder. Then, make adrag and dropof theSlicerNNInteractive.pyfile into the3D Slicerapplication window. - Confirm by
Yesto all asked questions - Go to the
nnInteractivemodule in Slicer and, in theConfigurationtab, type in the URL of the server you set up in the server side installation procedure. This should look something likehttp://localhost:1527, if the server and the clients are in the same computer.