constantinpape / torch-em

Deep-learning based semantic and instance segmentation for 3D Electron Microscopy and other bioimage analysis problems based on pytorch.
MIT License
69 stars 17 forks source link

Error messages for ROIs #274

Open lufre1 opened 1 month ago

lufre1 commented 1 month ago

Description

When using ROIs in the torch_em Dataloader (I used: torch_em.default_segmentation_loader) there is a generic error message if the ROIs do not fit (e.g. empty or incorrect size). Error message:

File "/home/freckmann15/miniforge3/envs/sam/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 631, in __next__
    data = self._next_data()
           ^^^^^^^^^^^^^^^^^
  File "/home/freckmann15/miniforge3/envs/sam/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 1319, in _next_data
    raise StopIteration
StopIteration

This message is quite difficult to interpret and therefore it is difficult to fix. The error can be fixed by having a min_shape for the ROIs so ROIs are at least the shape of the patch_shape used. I would suggest a more specific error message for this case.