cellpose icon indicating copy to clipboard operation
cellpose copied to clipboard

[BUG] aggregated_jaccard_index function in metrics.py still calls removed _label_overlap numba function

Open hzwirnmann opened this issue 7 months ago • 0 comments

Hi all,

Thank you for your great work for years already.

In this commit, numba dependencies were removed. This included the _label_overlap function in metrics.py. In the _intersection_over_union function a call to the function was replaced with some other code. However, in the aggregated_jaccard_index, the call is still there (line 75). I guess the same replacement can be used here. Currently, using the function leads to a NameError.

Log:

Python 3.10.15 | packaged by Anaconda, Inc. | (main, Oct  3 2024, 07:22:19) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cellpose
Welcome to CellposeSAM, cellpose v
cellpose version:       4.0.4
platform:               win32
python version:         3.10.15
torch version:          2.2.2! The neural network component of
CPSAM is much larger than in previous versions and CPU excution is slow.
We encourage users to use GPU/MPS if available.
>>> from cellpose.metrics import aggregated_jaccard_index
>>> import numpy as np
>>> a = np.array([[2,3], [3,4]])
>>> aggregated_jaccard_index(a,a)
C:\Users\HP\miniconda3\envs\napari-env\lib\site-packages\cellpose\metrics.py:172: RuntimeWarning: invalid value
encountered in divide
  iou = overlap / (n_pixels_pred + n_pixels_true - overlap)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\HP\miniconda3\envs\napari-env\lib\site-packages\cellpose\metrics.py", line 75, in aggregated_ja
ccard_index
    overlap = _label_overlap(masks_true[n], masks_pred[n])
NameError: name '_label_overlap' is not defined

Best wishes Henning

hzwirnmann avatar Jun 05 '25 12:06 hzwirnmann