Skip to content

SoniaPujolLab/SlicerNNInteractive

Repository files navigation

SlicerNNInteractive: nnInteractive meets 3D Slicer

This document explains how to install the improved version of SlicerNNInteractive in a computer. It adds benchmarks features to the original SlicerNNInteractive.

Table of contents

Installation

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 nnInteractive README

The client machine can be the same as the server machine.

Server side

Server running on Linux

You can install the server side of SlicerNNInteractive by following these steps:

Step 1. Install a recent version of Python

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 --version

Before passing to next steps, be sure that the displayed Python version is >= 3.10

Step 2. Create a Python virtual environment

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/activate

In Windows, the following commands should be used :

python3 -m venv .server_env
.server-venv\Scripts\activate.bat

Note 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.

Step 3. Install the server

Next, you can install the nnInteractive server to this environment with the following command:

pip install nninteractive-slicer-server

Dependancies installation may take several minutes.

Step 4. Patch the server for CPU compatibilty

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.

Step 5. Run the server

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 gpu

If 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.

Client side: Installation in 3D Slicer

  1. Download and install latest version of 3D Slicer
  2. Clone or download the improved SlicerNNInteractive repository.
  3. Install the downloaded SlicerNNInteractive extension: Open the cloned repository folder and go to the slicer_plugin/SlicerNNInteractive subfolder. Then, make a drag and drop of the SlicerNNInteractive.py file into the 3D Slicer application window.
  4. Confirm by Yes to all asked questions
  5. Go to the nnInteractive module in Slicer and, in the Configuration tab, type in the URL of the server you set up in the server side installation procedure. This should look something like http://localhost:1527, if the server and the clients are in the same computer.

About

A 3D Slicer extension for efficient segmentation with nnInteractive.

Resources

License

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors