[BUG] ROIs deleted after running CPSAM in v 4.0.8
Describe the bug Disclaimer, this is my first time using cellpose and I am a relatively novice coder.
I installed the GUI for cellpose v 4.0.8 without issues and am able to open it. I uploaded an image and drew rois, but every time I run CPSAM, the rois are deleted and listed as 0. Am I missing something? What does the percentage refer to in the segmentation box? I was under the impression that after running CPSAM masks would be generated that resemble the ROIs that I drew.
To Reproduce Steps to reproduce the behavior:
- run % python -m cellpose
- Upload image to GUI
- Draw ROIs
- Click "run CPSAM"
Run log
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.6 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last): File "/opt/anaconda3/envs/cellpose/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/opt/anaconda3/envs/cellpose/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/opt/anaconda3/envs/cellpose/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/cellpose/__init__.py", line 1, in <module>
from cellpose.version import version, version_str
File "/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/cellpose/version.py", line 7, in <module>
import torch
File "/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/torch/__init__.py", line 1477, in <module>
from .functional import * # noqa: F403
File "/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/torch/functional.py", line 9, in <module>
import torch.nn.functional as F
File "/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/torch/nn/__init__.py", line 1, in <module>
from .modules import * # noqa: F403
File "/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/torch/nn/modules/__init__.py", line 35, in <module>
from .transformer import TransformerEncoder, TransformerDecoder, \
File "/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),
/opt/anaconda3/envs/cellpose/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),
2025-10-19 16:23:09,356 [INFO] WRITING LOG OUTPUT TO /Users/Name/.cellpose/run.log
2025-10-19 16:23:09,356 [INFO]
cellpose version: 4.0.7
platform: darwin
python version: 3.10.18
torch version: 2.2.2
2025-10-19 16:23:09,868 [INFO] Neither TORCH CUDA nor MPS version not installed/working.
GUI_INFO: image shape: (2253, 3007, 3)
GUI_INFO: normalization checked: computing saturation levels (and optionally filtered image)
{'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0.0, 'smooth_radius': 0.0, 'tile_norm_blocksize': 0.0, 'tile_norm_smooth3D': 1.0, 'invert': False}
[0, 255.0]
(1, 2253, 3007, 3)
GUI_INFO: 3 masks found
GUI_INFO: creating cellcolors and drawing masks
GUI_INFO: loaded in previous changes
GUI_INFO: loading image: /Users/Name/Downloads/cells.jpg
GUI_INFO: image shape: (640, 640, 3)
GUI_INFO: normalization checked: computing saturation levels (and optionally filtered image)
{'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0.0, 'smooth_radius': 0.0, 'tile_norm_blocksize': 0.0, 'tile_norm_smooth3D': 1.0, 'invert': False}
[np.float32(12.0), np.float32(255.0)]
2025-10-19 16:24:08,227 [INFO] >>>> using CPU
2025-10-19 16:24:08,227 [INFO] >>>> using CPU
2025-10-19 16:24:10,364 [INFO] >>>> loading model /Users/Name/.cellpose/models/cpsam
{'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0.0, 'smooth_radius': 0.0, 'tile_norm_blocksize': 0.0, 'tile_norm_smooth3D': 1.0, 'invert': False}
NET ERROR: Numpy is not available
GUI_INFO: 1 ROIs saved to /Users/Name/Downloads/cells_seg.npy
GUI_INFO: 2 ROIs saved to /Users/Name/Downloads/cells_seg.npy
2025-10-19 16:24:24,307 [INFO] >>>> using CPU
2025-10-19 16:24:24,307 [INFO] >>>> using CPU
2025-10-19 16:24:26,423 [INFO] >>>> loading model /Users/Name/.cellpose/models/cpsam
{'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0.0, 'smooth_radius': 0.0, 'tile_norm_blocksize': 0.0, 'tile_norm_smooth3D': 1.0, 'invert': False}
NET ERROR: Numpy is not available
GUI_INFO: 1 ROIs saved to /Users/Name/Downloads/cells_seg.npy
GUI_INFO: 2 ROIs saved to /Users/Name/Downloads/cells_seg.npy
GUI_INFO: 3 ROIs saved to /Users/Name/Downloads/cells_seg.npy
2025-10-19 16:26:05,730 [INFO] >>>> using CPU
2025-10-19 16:26:05,731 [INFO] >>>> using CPU
2025-10-19 16:26:07,806 [INFO] >>>> loading model /Users/Name/.cellpose/models/cpsam
{'lowhigh': None, 'percentile': [1.0, 99.0], 'normalize': True, 'norm3D': True, 'sharpen_radius': 0.0, 'smooth_radius': 0.0, 'tile_norm_blocksize': 0.0, 'tile_norm_smooth3D': 1.0, 'invert': False}
NET ERROR: Numpy is not available
Screenshots
Looks like there is something wrong with the numpy dependencies. If you make a new conda environment and reinstall it should work. These are the same instructions on the GH readme:
conda create -n <name for the environment> python==3.12. # create an env for this cellpose installation
conda activate <name for the environment> # activate the environment
pip install cellpose[gui] # install cellpose and the gui
cellpose # run cellpose
Thank you for your response. I deleted the conda environment and repeated the steps, but I am still getting the same error. I suspect it has something to do with the following message each time I run cellpose: "A module that was compiled using NumPy 1.x cannot be run in NumPy 2.2.6 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2."
After some reading it looks like pytorch still doesn't support all build systems numpy2+. What operating system are you using?
I think there may be two different fixes. You can try to install the latest pytorch inside your conda environment:
pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
If that doesn't work, try downgrading to numpy1:
pip install --force-reinstall -v "numpy==1.25.2"
Hi! I'm also experiencing the same problem. After masking the cells, I tried running CPSAM but then all of my ROIs disappeared. I tried your solutions and retry running CPSAM and it still happened. This is the message that shown on my terminal
"While copying the parameter named "out.bias", whose dimensions in the model are torch.Size([192]) and whose dimensions in the checkpoint are torch.Size([192]), an exception occurred : ("CUDA error: no kernel image is available for execution on the device\nSearch for cudaErrorNoKernelImageForDevice' in https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html for more information.\nCUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.\nFor debugging consider passing CUDA_LAUNCH_BLOCKING=1\nCompile with TORCH_USE_CUDA_DSA` to enable device-side assertions.\n",)."
I'm not sure where the error is. I'm a very novice beginner to CellPose so I would really appreciate any guide/direction. I'm trying to train a new model for my lab project.