kevinjohncutler / omnipose

Omnipose: a high-precision solution for morphology-independent cell segmentation
https://omnipose.readthedocs.io
Other
85 stars 29 forks source link

Omnipose crash with the --verbose flag when no objects are found in an image #96

Closed tinevez closed 4 days ago

tinevez commented 3 weeks ago

If omnipose processes an image in which there are no objects found, it crashes with the message:

omnipose_logger.info('\texecution time per pixel: {:.6g} sec/px'.format(executionTime0/np.prod(labels.shape)))
AttributeError: 'NoneType' object has no attribute 'shape'

The faulty lines in the current code are: https://github.com/kevinjohncutler/omnipose/blob/main/omnipose/core.py#L1611-L1615

It appears that the labels object is None when no objects are found, and the message printed in this line therefore crashes. Noticed by @marieanselmet