BodenmillerGroup / steinbock

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

deepcell segmenting error #256

Closed megankmckie closed 1 month ago

megankmckie commented 2 months ago

Hi there

I'm trying to run steinbock segment deepcell --minmax and it's working fine for all my ROIs except one where I'm getting the following error:

ERROR steinbock.segmentation.deepcell - Error segmenting objects in img/IMC1 slide 94_008.tiff: in user code:

    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1801, in predict_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1790, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1783, in run_step  **
        outputs = model.predict_step(data)
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1751, in predict_step
        return self(x, training=False)
    File "/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/input_spec.py", line 264, in assert_input_compatibility
        raise ValueError(f'Input {input_index} of layer "{layer_name}" is '

    ValueError: Input 0 of layer "panopticnet" is incompatible with the layer: expected shape=(None, 256, 256, 2), found shape=(1, 2908, 256, 2)
Traceback (most recent call last):
  File "/app/steinbock/steinbock/segmentation/deepcell.py", line 134, in try_segment_objects
    mask = predict(img, **predict_kwargs)
  File "/app/steinbock/steinbock/segmentation/deepcell.py", line 54, in predict
    mask = app.predict(
  File "/opt/steinbock-venv/lib/python3.8/site-packages/deepcell/applications/mesmer.py", line 306, in predict
    return self._predict_segmentation(image,
  File "/opt/steinbock-venv/lib/python3.8/site-packages/deepcell/applications/application.py", line 442, in _predict_segmentation
    output_images = self._run_model(
  File "/opt/steinbock-venv/lib/python3.8/site-packages/deepcell/applications/application.py", line 381, in _run_model
    output_tiles = self._batch_predict(tiles=tiles, batch_size=batch_size)
  File "/opt/steinbock-venv/lib/python3.8/site-packages/deepcell/applications/application.py", line 338, in _batch_predict
    batch_outputs = self.model.predict(batch_inputs, batch_size=batch_size)
  File "/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/func_graph.py", line 1147, in autograph_handler
    raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:

    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1801, in predict_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1790, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1783, in run_step  **
        outputs = model.predict_step(data)
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1751, in predict_step
        return self(x, training=False)
    File "/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/usr/local/lib/python3.8/dist-packages/keras/engine/input_spec.py", line 264, in assert_input_compatibility
        raise ValueError(f'Input {input_index} of layer "{layer_name}" is '

    ValueError: Input 0 of layer "panopticnet" is incompatible with the layer: expected shape=(None, 256, 256, 2), found shape=(1, 2908, 256, 2)

I can't figure out why this is happening for just one ROI so any help would be really appreciated - thanks!

Milad4849 commented 2 months ago

Hi @megankmckie

It must be something about the particular ROI that is causing issues, please check its dimensions and compare it to the non-problematic ROIs.

Milad4849 commented 1 month ago

closing due to inactivity