Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NET ERROR: index 1024 is out of bounds for axis 1 with size 1024 #1004

Open
FranJGonCal opened this issue Aug 29, 2024 · 6 comments
Open
Labels
bug Something isn't working

Comments

@FranJGonCal
Copy link

Hello, I'm new to cellpose and I find an error when upload my file to the program.
When I upload an RGB image and run the cyto3 model to segment the image (to later train a custom model) using the gui, an error NET ERROR: index 1024 is out of bounds for axis 1 with size 1024 appears, so no mask are found, and also no segmentation is performed.
I don't really know if I need to manually draw the mask of the cells that I want to segment before running the cyto3 model.

Captura de pantalla 2024-08-29 a las 12 35 43
@FranJGonCal FranJGonCal added the bug Something isn't working label Aug 29, 2024
@carsen-stringer
Copy link
Member

is this image a z-stack or a single image? does it show up correctly in the GUI? if you have a z-stack then you want to open cellpose with python -m cellpose --Zstack

@FranJGonCal
Copy link
Author

is this image a z-stack or a single image? does it show up correctly in the GUI? if you have a z-stack then you want to open cellpose with python -m cellpose --Zstack

It's a single image.

Trying different approaches, I found a way in which It's run correctly. When uploading the image to the program, I was using the "use GPU" option and the problem which I was commenting appeared. However, if I do not choose this option, the progrma runs correctly.

Anyway, thanks so much for your answer.

@carsen-stringer
Copy link
Member

Weird thanks for the update, somehow the GPU torch version isn't work, I would also try updating to the latest version v3.0.11 (pip install cellpose --upgrade) and upgrading torch in the same way

@carsen-stringer
Copy link
Member

GPU in this case is MPS

@mpiersonsmela
Copy link

I am also having this problem, only when running on GPU (CPU works OK). The error trace is:

./run_segmentation.sh 2024-09-30 13:35:19,050 - INFO - ** TORCH MPS version installed and working. ** 2024-09-30 13:35:19,050 - INFO - >>>> using GPU (MPS) 2024-09-30 13:35:19,050 - INFO - >> nuclei << model set to be used 2024-09-30 13:35:19,153 - INFO - >>>> loading model /Users/merrickpiersonsmela/.cellpose/models/nucleitorch_0 2024-09-30 13:35:19,223 - INFO - >>>> model diam_mean = 17.000 (ROIs rescaled to this size during training) 2024-09-30 13:35:23,835 - INFO - channels set to [0, 0] 2024-09-30 13:35:23,835 - INFO - ~~~ FINDING MASKS ~~~ /Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/dynamics.py:189: RuntimeWarning: invalid value encountered in divide mu /= (1e-60 + (mu**2).sum(axis=0)**0.5) Traceback (most recent call last): File "/Users/merrickpiersonsmela/Documents/Church_Lab/oogenesis/Images/Segmentation_analysis/2024-09-30_meiosis_BOLL_RNA/../src/segmentation.py", line 93, in <module> process_files(FOLDER_PATH, OUTPUT_FOLDER) File "/Users/merrickpiersonsmela/Documents/Church_Lab/oogenesis/Images/Segmentation_analysis/2024-09-30_meiosis_BOLL_RNA/../src/segmentation.py", line 61, in process_files masks, flows, styles, diams = MODEL.eval([dapi_data], diameter=DIAMETER, channels=[0,0]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/models.py", line 202, in eval masks, flows, styles = self.cp.eval(x, channels=channels, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/models.py", line 414, in eval maski, flowi, stylei = self.eval( ^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/models.py", line 454, in eval masks, styles, dP, cellprob, p = self._run_cp( ^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/models.py", line 561, in _run_cp outputs = dynamics.resize_and_compute_masks( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/dynamics.py", line 783, in resize_and_compute_masks mask, p = compute_masks(dP, cellprob, p=p, niter=niter, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/dynamics.py", line 840, in compute_masks mask = remove_bad_flow_masks(mask, dP, threshold=flow_threshold, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/dynamics.py", line 660, in remove_bad_flow_masks merrors, _ = metrics.flow_error(masks, flows, device0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/metrics.py", line 256, in flow_error dP_masks = dynamics.masks_to_flows(maski, device=device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/dynamics.py", line 360, in masks_to_flows mu, mu_c = masks_to_flows_device(masks, device=device, niter=niter) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/merrickpiersonsmela/miniforge3/envs/imageprocessing2/lib/python3.11/site-packages/cellpose/dynamics.py", line 194, in masks_to_flows_gpu mu0[:, y.cpu().numpy() - 1, x.cpu().numpy() - 1] = mu ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ IndexError: index 2834 is out of bounds for axis 1 with size 2834

@tathey1
Copy link

tathey1 commented Oct 1, 2024

Having the same issue on MacOS, cellpose 3.0.11, 2D images (IndexError in line 194 dynamics.py). However the issue went away when I reverted using pip install cellpose==3.0.8. Happy to share more info if useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants