cellpose icon indicating copy to clipboard operation
cellpose copied to clipboard

[BUG] merging cells sometimes freeezes cellpose/system

Open jan-glx opened this issue 1 year ago • 6 comments

In cellpose v2.2.2 and current main, under windows, w/o CUDA, trying to merge objects with (alt+click & alt+click) leads to memory spike of varying size (0 to > 20 GB).

To Reproduce open an image, add labels, observe system memory while merging two labels (with alt+click & alt+click)

Run log

(cellpose2) C:\Users\jan>python -m cellpose --verbose
2023-06-08 11:27:49,716 [INFO] WRITING LOG OUTPUT TO C:\Users\jan\.cellpose\run.log
2023-06-08 11:27:49,716 [INFO]
cellpose version:       2.2.2
platform:               win32
python version:         3.11.3
torch version:          2.0.1+cpu
2023-06-08 11:27:50,639 [INFO] TORCH CUDA version not installed/working.
GUI_INFO: loading image: C:/1_nobackup/0data/new_microscopy_out/JGG_163_SSOC_4x_3d_BF_1/A_1_fld_1_focused.tif
(1998, 2002, 4)
GUI_INFO: auto-adjust enabled, computing saturation levels
GUI_INFO: 1 ROIs saved to C:/1_nobackup/0data/new_microscopy_out/JGG_163_SSOC_4x_3d_BF_1/A_1_fld_1_focused_seg.npy
GUI_INFO: 2 ROIs saved to C:/1_nobackup/0data/new_microscopy_out/JGG_163_SSOC_4x_3d_BF_1/A_1_fld_1_focused_seg.npy
GUI_INFO: removed cell 1
GUI_INFO: 1 ROIs saved to C:/1_nobackup/0data/new_microscopy_out/JGG_163_SSOC_4x_3d_BF_1/A_1_fld_1_focused_seg.npy
GUI_INFO: merged two cells
GUI_INFO: 1 ROIs saved to C:/1_nobackup/0data/new_microscopy_out/JGG_163_SSOC_4x_3d_BF_1/A_1_fld_1_focused_seg.npy
GUI_INFO: 2 ROIs saved to C:/1_nobackup/0data/new_microscopy_out/JGG_163_SSOC_4x_3d_BF_1/A_1_fld_1_focused_seg.npy

system almost froze after starting second merge (see screenshots).

Screenshots image

image

jan-glx avatar Jun 08 '23 09:06 jan-glx

Just tested this on another system. Same problem. It's a more powerful machine. Here, all 60 GB RAM will be used by cellpose for a few minutes at times, when merging labels.

cellpose version:     2.2 
platform:           win32 
python version:     3.8.16 
torch version:      1.12.0
2023-06-09 17:40:33,058 [INFO] ** TORCH CUDA version installed and working. **
2023-06-09 17:52:40,569 [INFO] >> cyto2 << model set to be used
2023-06-09 17:52:40,585 [INFO] ** TORCH CUDA version installed and working. **
2023-06-09 17:52:40,585 [INFO] >>>> using GPU

jan-glx avatar Jun 09 '23 16:06 jan-glx

😅 looking at the code cellpose-noob-I realized that one can select objects. Selecting an object with left click and merging it with another by clicking the other one now while holding alt works fine (not particularly but sufficiently fast). So, the issue only manifests when trying to merge objects with objects with alt+click & alt+click.

jan-glx avatar Jun 09 '23 16:06 jan-glx

oh that's very weird thanks for tracking this down, will look into it

carsen-stringer avatar Feb 13 '24 00:02 carsen-stringer

I had been facing the same problem. Is there any way we can merge masks using Jupyter? I create masks in batch in Jupyter but need to use GUI to merge masks. Also the GUI Alt+click was working few days back and though it was slow (as mentioned) - sometimes it took a very long time and freezed everything, however now I am trying to use Alt+click its not working. I would be really grateful if you found a fix for this! Thank you

anoshqa avatar Apr 21 '24 13:04 anoshqa

😅 looking at the code cellpose-noob-I realized that one can select objects. Selecting an object with left click and merging it with another by clicking the other one now while holding alt works fine (not particularly but sufficiently fast). So, the issue only manifests when trying to merge objects with objects with alt+click & alt+click.

@anoshqa -did you try this? If there is no reaction at all, make sure the alt key is actually working. Also, probably no the issue here, but some other programs have issues correctly tracking the alt key state when switching windows with alt+tab.

jan-glx avatar Apr 21 '24 16:04 jan-glx

Hi Jan, I cannot understand what you mean by selecting objects in a row. I can't seem to select 2 cells in a row and merge them. I select one cell by left click and then when I click on another, the previous selection goes away. I tried using shift but then the brush button starts. I will make sure Alt key works, my PC actually hanged today after I attempted Alt+Click - I believe its because of big image size and this bug that you mentioned that Alt + Click takes too much of memory sometimes.

anoshqa avatar Apr 24 '24 14:04 anoshqa