Skip to content

Tuple index out of range error during post-processing step in Nucleus Instance Segmentation task #899

@akihikoueda

Description

@akihikoueda
  • TIA Toolbox version: 1.6.0
  • Python version: 3.10.15
  • Operating System: Ubuntu 22.04.5

Description

I attempted to perform a Nucleus Instance Segmentation task using the mapde-conic model pre-trained on the CoNIC Dataset and tried generating patches. While the predictions work well, an error occurs during the post-processing step. Could you kindly advise on how to address this issue?

What I Did

[Execution Code]

img_file_name_lists = ["sample_tile.png"]

from tiatoolbox.models import IOSegmentorConfig
ioconfig = IOSegmentorConfig(
    input_resolutions=[
        {'units': 'mpp', 'resolution': 0.25}
    ],
    output_resolutions=[
        {'units': 'mpp', 'resolution': 0.25},
        {'units': 'mpp', 'resolution': 0.25},
        {'units': 'mpp', 'resolution': 0.25},
        {'units': 'mpp', 'resolution': 0.25}
    ],
    margin=26,
    tile_shape=[1024, 1024],
    patch_input_shape=(252, 252),
    patch_output_shape=(150, 150),
    stride_shape=(150, 150),
    save_resolution={'units': 'mpp', 'resolution': 0.25}
)

# Tile prediction
inst_segmentor = NucleusInstanceSegmentor(
    pretrained_model="mapde-conic",
    num_loader_workers=2,
    num_postproc_workers=2,
    batch_size=4,
)

tile_output = inst_segmentor.predict(
    img_file_name_lists,
    save_dir="sample_tile_results/",
    mode="tile",
    on_gpu=False,
    crash_on_exception=False,
    ioconfig=ioconfig
)
"""

[Error Code]
"""
Traceback (most recent call last):
  File "/home/ueda/.pyenv/versions/3.10.15/lib/python3.10/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/home/ueda/kobe/lib/python3.10/site-packages/tiatoolbox/models/engine/nucleus_instance_segmentor.py", line 281, in _process_tile_predictions
    head_predictions = [v[idx][0] for v in predictions]
  File "/home/ueda/kobe/lib/python3.10/site-packages/tiatoolbox/models/engine/nucleus_instance_segmentor.py", line 281, in <listcomp>
    head_predictions = [v[idx][0] for v in predictions]
IndexError: tuple index out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ueda/kobe/lib/python3.10/site-packages/tiatoolbox/models/engine/semantic_segmentor.py", line 1225, in _predict_wsi_handle_exception
    self._predict_one_wsi(wsi_idx, ioconfig, str(wsi_save_path), mode)
  File "/home/ueda/kobe/lib/python3.10/site-packages/tiatoolbox/models/engine/nucleus_instance_segmentor.py", line 753, in _predict_one_wsi
    self._merge_post_process_results()
  File "/home/ueda/kobe/lib/python3.10/site-packages/tiatoolbox/models/engine/nucleus_instance_segmentor.py", line 805, in _merge_post_process_results
    raise future.exception()  # noqa: RSE102
IndexError: tuple index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions