Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
akihikoueda opened this issue Dec 16, 2024 · 1 comment · May be fixed by #578
Closed

Comments

@akihikoueda
Copy link

akihikoueda commented Dec 16, 2024

  • 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
@shaneahmed
Copy link
Member

mapde-conic is a nucleus detection model. It is not an instance segmentation model. We are working on Nucleus detection model in #538

@shaneahmed shaneahmed linked a pull request Jan 24, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants