A plugin to leverage ML segmentation in napari
Project description
Allencell-segmenter-ml
This version is a release candidate currently undergoing testing and development.
What is Allen Cell Segmenter ML
A deep learning-based segmentation Napari plugin to curate datasets, train your own model (UNET), and run inference on 2D and 3D cell data.
📰 News
- [2024.09.24] :tada: Initial release of the plugin and Megaseg models!
:hammer_and_wrench: Installation
System Requirements
We currently support Windows
, MacOS
, and Linux
operating systems. The minimum system requirements are:
- 8GB of RAM
- 8 CPU Cores
- 1 NVIDIA GPU with 8GB of VRAM (optional)
NOTE: If you plan to use the plugin without a GPU, training will default to using your CPU and will be significantly slower. A GPU is highly recommended for training models. Depending on how large your images are---2D vs 3D, resolution, model size---running inference may also be slow without a GPU.
Pre-Installation
STEP 1. Install Python
Before installing the plugin, please make sure you have the following installed:
- Python 3.10 or later
New to Python
? We recommend installing Python 3.10
through the official Python
website. This will include the pip
package manager, which is required to install the plugin.
If you are unsure if you have Python installed or which version you may have, you can check by running the following command in your terminal or powershell:
# Check version of python
python --version
# If the above does not work, try this one
python3 --version
# Specifically check for Python 3.10
python3.10 --version
STEP 2. Create a Virtual Environment
Next we will create a new Python
environment to install the plugin. This will help avoid conflicts with other packages you may have installed by creating an isolated environment for the plugin to live in. In general, it is good practice to choose a name for your environment that is related to either the project you are working on or the software you are installing. In this case, we use venv-allen-segmenter-ml
where venv
stands for virtual environment.
Navigate to where you want to create a new environment (Example. Documents
), run the following command in your terminal or powershell:
# Create a new environment
python3.10 -m venv venv-allen-segmenter-ml
# Activate the environment
source venv-allen-segmenter-ml/bin/activate
Confirm Virtual Environment is Activated
To confirm that the virtual environment has been successfully activated, you can follow these steps:
-
Check that the prompt includes the name of your virtual environment,
venv-allen-segmenter-ml
. It should look something like this:(venv-allen-segmenter-ml) $ # Example on a Windows machine (venv-allen-segmenter-ml) PS C:\Users\Administrator\Documents>
-
Run the following command to verify
Python 3.10
is being used within the virtual environment:python --version # Python 3.10.11 <-- Example output
Install the Plugin
To install the latest version of the plugin:
pip install allencell-segmenter-ml
:rotating_light: Post-Installation :rotating_light:
:memo: NOTE: This section is specifically for users with at least one NVIDIA GPU installed on their machine. Not sure if you have an NVIDIA GPU? You can check by running
nvidia-smi
as shown below. If you do not have an NVIDIA GPU system, you can skip this section.
Required Package
torch
(PyTorch) 2.0 or later
After installing the plugin, you need to install a PyTorch version that is compatible with your system. PyTorch is a deep learning library that is used to train and run the models in the plugin. We understand that everyone manages CUDA drivers and PyTorch versions differently depending on their system and use cases, and we want to respect those decisions because CUDA drivers can be a pain.
STEP 1. Checking CUDA Version
To check your CUDA version, you can run the following command in your terminal or powershell:
nvidia-smi
As an example, the output will look similar to this. My CUDA Version
is 11.8
:
PS C:\Users\Administrator> nvidia-smi
Fri Sep 13 03:22:15 2024
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 522.06 Driver Version: 522.06 CUDA Version: 11.8 |
|-------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 TCC | 00000000:00:1E.0 Off | 0 |
| N/A 27C P8 9W / 70W | 0MiB / 15360MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
STEP 2. PyTorch Installation
To Install PyTorch, please visit the PyTorch website and select the appropriate installation options for your system. An example is provided below.
PyTorch Installation for Windows, MacOS, and Linux
Example
For instance, if I am using
Windows
workstationpip
package managerPython
(3.10)CUDA 11.8
Then the command for me would be:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
If the installation is successful, let's test just to be sure that your GPU is detected by PyTorch. Run the following command in your terminal or powershell:
python -c "import torch; print(torch.cuda.is_available())"
You should see True
if your GPU is detected (see below). If you see False
, then PyTorch is not detecting your GPU. You may need to reinstall PyTorch or check your CUDA drivers. Double check that your virtual environement is activated (venv-allen-segmenter-ml
).
(venv-allen-segmenter-ml) PS C:\Users\Administrator\Documents> python -c "import torch; print(torch.cuda.is_available())"
True
:tada: You have successfully installed the plugin and PyTorch. You are now ready to use the plugin!
Running the Plugin
To run the plugin (and verify the installation), you can use the following command in your terminal or powershell:
napari
You should see the below window pop up. To start using the plugin, click on the Plugins
tab and select Allen Cell Segmenter ML
:
Allen Cell Segmenter ML Launching the Plugin.
Models
Model | Model Name | Available in Plugin | Model Size (MB) | Supported Magnifications |
---|---|---|---|---|
MegaSeg-S | megaseg_light |
✅ | 4.8MB | 100X |
MegaSeg-M | megaseg_medium |
Coming soon! | TBD | TBD |
MegaSeg-L | megaseg_large |
✅ | 191MB | 20X, 40X, 67X, 100X |
Download and using the Megaseg Models
To use the MegaSeg models in the plugin, you can download them from the dropdown menu shown below:
Download the MegaSeg Model for use in the Plugin
A popup window will appear and you can select which model you would like to download. Once the download is complete, another popup will let you know the download was successful and where the model was downloaded.
Select the MegaSeg model to Run Inference
To use the model for inference on your images, choose Select an existing model
, select the megaseg model you downloaded, and click Apply
. You can now use the model to segment your images!
License
Distributed under the terms of the Allen Institute Software License license.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file allencell_segmenter_ml-0.1.16rc2.tar.gz
.
File metadata
- Download URL: allencell_segmenter_ml-0.1.16rc2.tar.gz
- Upload date:
- Size: 4.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 575782712918a536fba96cc50f421ec423074f51932ae62944c2eb736b256cf3 |
|
MD5 | 06f41a4c294dcae53c8630ce34e31e54 |
|
BLAKE2b-256 | 1d907ac3e27e8665ea55ce1750e17061465b4456953803f9a3ddd2bad4e488dc |
File details
Details for the file allencell_segmenter_ml-0.1.16rc2-py3-none-any.whl
.
File metadata
- Download URL: allencell_segmenter_ml-0.1.16rc2-py3-none-any.whl
- Upload date:
- Size: 243.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e6c40821226fc33bb12991172d2456f7ef60b03bb5a9293caa358e6b7c1dfa0 |
|
MD5 | 453df3d428ef141ce9782e0a562722f9 |
|
BLAKE2b-256 | 827b995d610bfd2e92e3aa4f6c8f1a6f00ed97da88381972f80ca7dcf456a276 |