cellpose icon indicating copy to clipboard operation
cellpose copied to clipboard

[BUG] Cellpose model exported from 3.1.1.1 silently fails to work properly on latests 4.0 version

Open jianluz opened this issue 5 months ago • 2 comments

Title
[BUG] Cellpose model exported from 3.1.1.1 silently fails to work properly on latest 4.0 version

Describe the bug
A custom, fine-tuned model (cyto3_train0327) exported from Cellpose version 3.1.1.1 does not work correctly when run with Cellpose 4.0.x (tested on 4.0.6).
The evaluation code runs without throwing any errors, but the output masks array is completely zero, resulting in a black image upon visualization.
The same model and code produce correct segmentation results when run on Cellpose 3.1.1.1, so the issue seems to be a compatibility problem between models exported from older versions and the latest 4.0 release.

To Reproduce
Steps to reproduce the behavior:

  1. Export a fine-tuned model from Cellpose version 3.1.1.1 (example: cyto3_train0327).
  2. Install Cellpose 4.0.6.
  3. Run the following code:
    masks, flows, styles = cellpose_model.eval(frame_image, diameter=None, channels=[0, 0])
    
  4. Observe that masks is all zeros (black when visualized), despite no errors being raised.

Expected behavior The same segmentation results as in Cellpose 3.1.1.1, where the model correctly outputs masks with segmented cells.

Run log In 4.0.6: no errors, masks all zeros. In 3.1.1.1: works as expected.

To reproduce correct behavior, I had to downgrade to the specific commit of 3.1.1.1:

pip install git+https://github.com/mouseland/cellpose.git@fb22843e70d03f7884c301b7b72bedd7d9c3d2d9

jianluz avatar Aug 08 '25 14:08 jianluz

Hi @jianluz Cellpose4 is not backwards compatible with cellpose3. They use completely different network architectures. You'll need to train a cp4.0 model with your data

mrariden avatar Aug 08 '25 17:08 mrariden

This is the same issue as Issue 1216. I think it would make sense to either let Cellpose3 models explicitly fail using Cellpose4 or documenting this behaviour more explicit, for example in the docs where other issues of switching between cp3 and cp4 are documented or in the README?

phaleanopsis avatar Aug 16 '25 17:08 phaleanopsis