# Install extensions

QuPath extensions can add extra features.
We may not have time to explore them in the workshop, but these instructions show how to install one that we'll mention - and that you may find useful later.

```{admonition} What to do
1. Start QuPath.
2. Navigate to {menuselection}`Extensions --> Manage extensions`.
   This will open a dialog window showing a list of extensions maintained by the QuPath team.
  :::{figure} ../images/setup/1-extension-manager.png
  QuPath's extension manager.
  :::
3. Click the green plus (+) icon on the row reading {guilabel}`QuPath InstanSeg extension` to open an install dialog for the InstanSeg extension.
4. In the dialog that appears, click "Install" for the latest version.
  :::{figure} ../images/setup/2-instanseg-install.png
  Install dialog for the InstanSeg extension
  :::
```

You can find more instructions for installing extensions in [the QuPath docs](https://qupath.readthedocs.io/en/latest/docs/intro/extensions.html).

## Deep Java Library and PyTorch

In order to use InstanSeg and other deep learning models in QuPath, we usually use Deep Java Library.

QuPath {{ qupath_version }} includes the Deep Java Library extension by default.
However, you'll still need to download "engines" to run deep learning models.

Specifially, the InstanSeg extension you just installed needs the "PyTorch engine".

```{admonition} What to do
1. Navigate to {menuselection}`Extensions --> Deep Java Library --> Manage DJL engines`.
  This will open a dialog as follows:
  :::{figure} ../images/setup/3-djl.png
  A dialog to manage Deep Java Library engines for QuPath.
  :::
2. Click {guilabel}`Check/Download` under PyTorch, and DJL should attempt to download and install the appropriate version for your system.
  :::{figure} ../images/setup/4-djl-installed.png
  Deep Java Library engine management window, showing PyTorch available
  :::
3. If your computer contains an NVIDIA GPU, you may also want to attempt to [install GPU support, as explained in the QuPath docs](https://qupath.readthedocs.io/en/stable/docs/deep/gpu.html).
  This can hugely speed up models for large images... although configuration *can* be a bit of a pain, so let us know if you get stuck.
```
