kevinjohncutler / omnipose

Omnipose: a high-precision solution for morphology-independent cell segmentation
https://omnipose.readthedocs.io
Other
96 stars 29 forks source link

Using omnipose models in Matlab Cellpose integration #60

Open smury opened 11 months ago

smury commented 11 months ago

Not really an issue with omnipose as such but I'm trying to use the omnipose models in the Cellpose add-on for Matlab 2023b.

I found the model folder to which the models are downloaded and passed them to the Matlabs cellpose function. However there is a problem with bact_phase_omnitorch_0

`Error using module>load_state_dict Python Error: RuntimeError: Error(s) in loading state_dict for CPnet: size mismatch for output.2.weight: copying a param with shape torch.Size([4, 32, 1, 1]) from checkpoint, the shape in current model is torch.Size([3, 32, 1, 1]). size mismatch for output.2.bias: copying a param with shape torch.Size([4]) from checkpoint, the shape in current model is torch.Size([3]).

Error in resnet_torch>load_model (line 233)

Error in models>init (line 369)

Error in MWCellposeWrapper>createmodel (line 41)

Error in untitled (line 1) cp=cellpose(Model='bact_phase_omnitorch_0',ModelFolder='C:\Users\murrays.TER.cellpose\models')`

The bact_phase_cptorch_0 model doesn't give an error but it does not segment my image no matter the parameters.

Any idea how to get either of these models working? Or are they specifc to omnipose and simply do not work with cellpose?

kevinjohncutler commented 9 months ago

@smury sorry for the delay. Correct, the Omnipose models do not work with stock Cellpose, as the network initialization is a bit different (nclasses 3 for published Omnipose models, 2 for Cellpose). However, there is an implementation by another member of my lab (@tlo-bot) that will show you how to integrate Omnipose into Matlab (just calling it from terminal, as I recall): https://github.com/tlo-bot/supersegger-omnipose