MouseLand / cellpose

a generalist algorithm for cellular segmentation with human-in-the-loop capabilities
https://www.cellpose.org/
BSD 3-Clause "New" or "Revised" License
1.31k stars 376 forks source link

No ROIs found #851

Open miadamczyk opened 7 months ago

miadamczyk commented 7 months ago

Hello,

I would like to traing my model using gpu. I follow instructions shown on video: https://www.youtube.com/watch?v=3Y1VKcxjNy4

I enter an image, then use "cyto" option from zoo (chan to segment - grey, chan2 - None). A few hundred ROIs are found (300 - 900, depending on an image). I go to models, "Train new model..." (I use default settings).

That is what i get; from turning cellpose on to loading next image and using trained model (as you can see it finds 0 masks)

(cellpose) C:\Users\Bartosz>python -m cellpose 2024-02-01 22:28:49,400 [INFO] WRITING LOG OUTPUT TO C:\Users\Bartosz.cellpose\run.log 2024-02-01 22:28:49,400 [INFO] cellpose version: 2.2.3 platform: win32 python version: 3.8.18 torch version: 2.1.2 2024-02-01 22:28:49,669 [INFO] TORCH CUDA version installed and working. GUI_INFO: loading image: C:/Users/Bartosz/Desktop/TrainImgs/Escherichia.coli_0.tif (2762, 4912, 4) GUI_INFO: auto-adjust enabled, computing saturation levels 2024-02-01 22:29:15,004 [INFO] TORCH CUDA version installed and working. 2024-02-01 22:29:15,004 [INFO] >>>> using GPU 2024-02-01 22:29:15,004 [INFO] >> cyto << model set to be used 2024-02-01 22:29:15,257 [INFO] >>>> model diam_mean = 30.000 (ROIs rescaled to this size during training) 2024-02-01 22:29:15,307 [INFO] ~ FINDING MASKS ~ 2024-02-01 22:29:26,619 [INFO] >>>> TOTAL TIME 11.31 sec 2024-02-01 22:29:27,179 [INFO] 433 cells found with model in 12.249 sec GUI_INFO: 433 masks found GUI_INFO: creating cellcolors and drawing masks GUI_INFO: 434 ROIs saved to C:/Users/Bartosz/Desktop/TrainImgs/Escherichia.coli_0_seg.npy GUI_INFO: 435 ROIs saved to C:/Users/Bartosz/Desktop/TrainImgs/Escherichia.coli_0_seg.npy GUI_INFO: removed cell 434 GUI_INFO: 434 ROIs saved to C:/Users/Bartosz/Desktop/TrainImgs/Escherichia.coli_0_seg.npy GUI_INFO: removed cell 195 GUI_INFO: 433 ROIs saved to C:/Users/Bartosz/Desktop/TrainImgs/Escherichia.coli_0_seg.npy 2024-02-01 22:30:10,914 [INFO] training with ['Escherichia.coli_0.tif'] 2024-02-01 22:30:10,914 [INFO] training new model starting at model cyto 2024-02-01 22:30:10,916 [INFO] training with chan = 0: gray, chan2 = 0: none 2024-02-01 22:30:10,917 [INFO] >> cyto << model set to be used 2024-02-01 22:30:10,919 [INFO] TORCH CUDA version installed and working. 2024-02-01 22:30:10,919 [INFO] >>>> using GPU 2024-02-01 22:30:11,176 [INFO] >>>> model diam_mean = 30.000 (ROIs rescaled to this size during training) GUI_INFO: name of new model: CP_20240201_222850 2024-02-01 22:30:12,038 [INFO] computing flows for labels 100%|███████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1.18it/s] 2024-02-01 22:30:13,792 [INFO] >>>> median diameter set to = 30 2024-02-01 22:30:13,793 [INFO] >>>> mean of training label mask diameters (saved to model) 33.719 2024-02-01 22:30:13,795 [INFO] >>>> training network with 2 channel input <<<< 2024-02-01 22:30:13,796 [INFO] >>>> LR: 0.10000, batch_size: 8, weight_decay: 0.00010 2024-02-01 22:30:13,798 [INFO] >>>> ntrain = 1 2024-02-01 22:30:13,801 [INFO] >>>> nimg_per_epoch = 8 2024-02-01 22:30:15,747 [INFO] Epoch 0, Time 1.9s, Loss 2.4839, LR 0.0000 2024-02-01 22:30:17,168 [INFO] saving network parameters to C:/Users/Bartosz/Desktop/TrainImgs\models/CP_20240201_222850 2024-02-01 22:30:23,556 [INFO] Epoch 5, Time 9.8s, Loss 1.6193, LR 0.0556 2024-02-01 22:30:51,564 [INFO] Epoch 10, Time 37.8s, Loss 0.2173, LR 0.1000 2024-02-01 22:31:07,158 [INFO] Epoch 20, Time 53.4s, Loss 0.2023, LR 0.1000 2024-02-01 22:31:22,635 [INFO] Epoch 30, Time 68.8s, Loss 0.2051, LR 0.1000 2024-02-01 22:31:38,394 [INFO] Epoch 40, Time 84.6s, Loss 0.2694, LR 0.1000 2024-02-01 22:31:54,104 [INFO] Epoch 50, Time 100.3s, Loss 0.1900, LR 0.1000 2024-02-01 22:32:09,829 [INFO] Epoch 60, Time 116.0s, Loss 0.2401, LR 0.1000 2024-02-01 22:32:24,206 [INFO] Epoch 70, Time 130.4s, Loss 0.2114, LR 0.1000 2024-02-01 22:32:40,137 [INFO] Epoch 80, Time 146.3s, Loss 0.1327, LR 0.1000 2024-02-01 22:32:55,663 [INFO] Epoch 90, Time 161.9s, Loss 0.2379, LR 0.1000 2024-02-01 22:33:09,841 [INFO] saving network parameters to C:/Users/Bartosz/Desktop/TrainImgs\models/CP_20240201_222850 C:/Users/Bartosz/Desktop/TrainImgs\models/CP_20240201_222850 copied to models folder C:\Users\Bartosz.cellpose\models GUI_INFO: loading image: C:/Users/Bartosz/Desktop/TrainImgs\Escherichia.coli_1.tif (2762, 4912, 4) GUI_INFO: auto-adjust enabled, computing saturation levels 2024-02-01 22:33:11,405 [INFO] >>>> diameter set to diam_labels ( = 33.719 ) 2024-02-01 22:33:11,977 [INFO] >>>> loading model C:\Users\Bartosz.cellpose\models\CP_20240201_222850 2024-02-01 22:33:11,978 [INFO] TORCH CUDA version installed and working. 2024-02-01 22:33:11,979 [INFO] >>>> using GPU 2024-02-01 22:33:12,154 [INFO] >>>> model diam_mean = 30.000 (ROIs rescaled to this size during training) 2024-02-01 22:33:12,155 [INFO] >>>> model diam_labels = 33.719 (mean diameter of training ROIs) 2024-02-01 22:33:21,936 [INFO] 0 cells found with model in 10.021 sec GUI_INFO: 0 masks found GUI_INFO: creating cellcolors and drawing masks 2024-02-01 22:33:22,393 [INFO] !!! computed masks for Escherichia.coli_1.tif from new model !!!

carsen-stringer commented 6 months ago

could you maybe try training with 2-3 labeled images? I'm not sure why it would have failed without seeing the images

jzeng22 commented 3 months ago

Hi,

I'm having the same issue where after training, the model detects 0 masks. I tried training with multiple (4) labeled images as suggested, but ended up with the same issue. Attached are the images I'm using (images.zip), an example of one of the masks (generated by the untrained model) that I trained on (example_mask.zip), and the terminal output (terminal_output.txt). I started training from the cyto3 model and changed the diameter to 10 pixels and the upper normalization percentile to 99.99 (to account for the sparsity in my images).

Thank you!