BodenmillerGroup / steinbock

A toolkit for processing multiplexed tissue images
https://bodenmillergroup.github.io/steinbock
MIT License
49 stars 14 forks source link

cellpose not included in steinbock:0.16.0 #185

Closed dingxm closed 1 year ago

dingxm commented 1 year ago

Hi I have tried to use the cellpose for the segmentation in steinbock:0.16.0. However only cellprofiler and deepcell are available. Thanks

$steinbock segment --help

Usage: steinbock segment [OPTIONS] COMMAND [ARGS]...

Perform image segmentation to create object masks

Options: --help Show this message and exit.

Commands: cellprofiler Segment objects in probability images using CellProfiler deepcell Run an object segmentation batch using DeepCell

Milad4849 commented 1 year ago

Hi dingxm,

Thanks for your question. Can you please confirm that you are using a -cellpose flavor of the steinbock Docker container as pointed out here in the documentation. You can view the available steinbock Docker container flavors here.

dingxm commented 1 year ago

Hi Milad4849, Thanks for your help. I used docker pull ghcr.io/bodenmillergroup/steinbock:latest-cellpose. I can use cellpose for the segmentation. However I got the error below,

Error segmenting objects in img/NBL_N0351.tiff: The following operation failed in the TorchScript interpreter. Traceback of TorchScript (most recent call last): File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/utils/mkldnn.py", line 64, in forward @torch.jit.script_method def forward(self, x): return torch.mkldnn_convolution(


            x,
            self.weight,
RuntimeError: could not create a primitive
Traceback (most recent call last):
  File "/app/steinbock/steinbock/segmentation/cellpose.py", line 102, in try_segment_objects
    masks, flows, styles, diams = model.eval(
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/models.py", line 216, in eval
    diams, _ = self.sz.eval(x, channels=channels, channel_axis=channel_axis, invert=invert, batch_size=batch_size,
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/models.py", line 889, in eval
    diam, diam_style = self.eval(x[i],
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/models.py", line 910, in eval
    styles = self.cp.eval(x,
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/models.py", line 552, in eval
    masks, styles, dP, cellprob, p = self._run_cp(x,
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/models.py", line 616, in _run_cp
    yf, style = self._run_nets(img, net_avg=net_avg,
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/core.py", line 363, in _run_nets
    y, style = self._run_net(img, augment=augment, tile=tile, tile_overlap=tile_overlap,
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/core.py", line 447, in _run_net
    y, style = self.network(imgs, return_conv=return_conv)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/core.py", line 315, in network
    y, style = self.net(X)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/resnet_torch.py", line 202, in forward
    T0    = self.downsample(data)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/resnet_torch.py", line 84, in forward
    xd.append(self.down[n](y))
  File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/cellpose/resnet_torch.py", line 47, in forward
    x = self.proj(x) + self.conv[1](self.conv[0](x))
  File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/nn/modules/container.py", line 204, in forward
    input = module(input)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
  File "/opt/steinbock-venv/lib/python3.8/site-packages/torch/utils/mkldnn.py", line 64, in forward
    @torch.jit.script_method
    def forward(self, x):
        return torch.mkldnn_convolution(
               ~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
            x,
            self.weight,
RuntimeError: could not create a primitive
Any suggestion?
Milad4849 commented 1 year ago

I am not certain but this can potentially be related to your CPU, what operating system, computer and CPU are you using?

dingxm commented 1 year ago

The CPU is zen3 by AMD. Likely it is AMD CPU related problem. I will try the Intel CPU. Thanks