royerlab / ultrack

Cell tracking and segmentation software
https://royerlab.github.io/ultrack
BSD 3-Clause "New" or "Revised" License
95 stars 13 forks source link

AttributeError: module 'numpy' has no attribute 'bool8' #153

Closed jazberna1 closed 4 weeks ago

jazberna1 commented 4 weeks ago

Hello,

I am getting the following error when running this cell of the tribolium_cartograph.ipynb notebook AttributeError: module 'numpy' has no attribute 'bool8'

This the cell I am refering to:

detection = create_zarr(image.shape, bool, "detection.zarr", overwrite=True)
array_apply(
    image,
    out_array=detection,
    func=on_gpu(detect_foreground),
)

viewer.add_labels(detection, visible=True).contour = 2

nbscreenshot(viewer)

I reverted numpy from 2.0.2 to 1.23.5 in order to avoid the error.

Jorge

JoOkuma commented 4 weeks ago

@jazberna1, can you include the whole traceback? I wonder which package is using bool8. Your code looks fine.

jazberna1 commented 4 weeks ago

Hi!

This is the whole traceback.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[4], line 2
      1 detection = create_zarr(image.shape, bool, "detection.zarr", overwrite=True)
----> 2 array_apply(
      3     image,
      4     out_array=detection,
      5     func=on_gpu(detect_foreground),
      6 )
      8 viewer.add_labels(detection, visible=True).contour = 2
     10 nbscreenshot(viewer)

File ~\miniconda3\envs\ultrack\Lib\site-packages\ultrack\utils\array.py:157, in array_apply(func, out_array, axis, out_zarr_kwargs, *in_arrays, **kwargs)
    154     stub_slicing[a] = i
    155 indexing = tuple(stub_slicing)
--> 157 func_result = func(*[a[indexing] for a in in_arrays], **kwargs)
    158 output_shape = out_array[indexing].shape
    159 out_array[indexing] = np.broadcast_to(func_result, output_shape)

File ~\miniconda3\envs\ultrack\Lib\site-packages\ultrack\utils\cuda.py:162, in on_gpu.<locals>.wrapper(*args, **kwargs)
    154     args = [
    155         cp.asarray(a) if isinstance(a, (np.ndarray, da.Array)) else a
    156         for a in args
    157     ]
    158     kwargs = {
    159         k: cp.asarray(v) if isinstance(v, (np.ndarray, da.Array)) else v
    160         for k, v in kwargs.items()
    161     }
--> 162 return func(*args, **kwargs)

File ~\miniconda3\envs\ultrack\Lib\site-packages\ultrack\imgproc\segmentation.py:91, in detect_foreground(image, voxel_size, sigma, remove_hist_mode, min_foreground, channel_axis)
     89 ndi = import_module("scipy", "ndimage")
     90 filters = import_module("skimage", "filters")
---> 91 exposure = import_module("skimage", "exposure")
     93 voxel_size = _parse_voxel_size(voxel_size, image.ndim, channel_axis)
     95 shape = list(image.shape)

File ~\miniconda3\envs\ultrack\Lib\site-packages\ultrack\utils\cuda.py:116, in import_module(module, submodule, arr)
    114 cupy_module_name = f"{CUPY_MODULES[module]}.{submodule}"
    115 try:
--> 116     pkg = importlib.import_module(cupy_module_name)
    117     LOG.info(f"{cupy_module_name} found.")
    118     return pkg

File ~\miniconda3\envs\ultrack\Lib\importlib\__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1204, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1176, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1147, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:690, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:940, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File c:\users\xxx\ultrack\src\cucim\python\cucim\src\cucim\skimage\exposure\__init__.py:1
----> 1 from ._adapthist import equalize_adapthist
      2 from .exposure import (adjust_gamma, adjust_log, adjust_sigmoid,
      3                        cumulative_distribution, equalize_hist, histogram,
      4                        is_low_contrast, rescale_intensity)
      5 from .histogram_matching import match_histograms

File c:\users\xxx\ultrack\src\cucim\python\cucim\src\cucim\skimage\exposure\_adapthist.py:27
     25 # TODO: replace _misc.prod with math.prod once minimum Python >= 3.88
     26 from cucim import _misc
---> 27 from cucim.skimage.exposure.exposure import rescale_intensity
     29 from .._shared.utils import _supported_float_type
     30 from ..color.adapt_rgb import adapt_rgb, hsv_value

File c:\users\xxx\ultrack\src\cucim\python\cucim\src\cucim\skimage\exposure\exposure.py:5
      2 import numpy as np
      4 from .._shared import utils
----> 5 from ..util.dtype import dtype_limits, dtype_range
      7 __all__ = ['histogram', 'cumulative_distribution', 'equalize_hist',
      8            'rescale_intensity', 'adjust_gamma', 'adjust_log', 'adjust_sigmoid']
     11 DTYPE_RANGE = dtype_range.copy()

File c:\users\xxx\ultrack\src\cucim\python\cucim\src\cucim\skimage\util\__init__.py:1
----> 1 from ._invert import invert
      2 from ._map_array import map_array
      3 from .arraycrop import crop

File c:\users\xxx\ultrack\src\cucim\python\cucim\src\cucim\skimage\util\_invert.py:4
      1 import cupy as cp
      2 import numpy as np
----> 4 from .dtype import dtype_limits
      7 def invert(image, signed_float=False):
      8     """Invert an image.
      9 
     10     Invert the intensity range of the input image, so that the dtype maximum
   (...)
     63     array([[-0.  , -1.  ,  1.  ,  0.25]])
     64     """

File c:\users\xxx\ultrack\src\cucim\python\cucim\src\cucim\skimage\util\dtype.py:28
     19 _integer_types = (cp.byte, cp.ubyte,          # 8 bits
     20                   cp.short, cp.ushort,        # 16 bits
     21                   cp.intc, cp.uintc,          # 16 or 32 or 64 bits
     22                   int, cp.int_, cp.uint,      # 32 or 64 bits
     23                   cp.longlong, cp.ulonglong)  # 64 bits
     24 _integer_ranges = {t: (cp.iinfo(t).min, cp.iinfo(t).max)
     25                    for t in _integer_types}
     26 dtype_range = {bool: (False, True),
     27                cp.bool_: (False, True),
---> 28                cp.bool8: (False, True),
     29                float: (-1, 1),
     30                cp.float_: (-1, 1),
     31                cp.float16: (-1, 1),
     32                cp.float32: (-1, 1),
     33                cp.float64: (-1, 1)}
     34 dtype_range.update(_integer_ranges)
     36 _supported_types = list(dtype_range.keys())

File ~\miniconda3\envs\ultrack\Lib\site-packages\cupy\__init__.py:1085, in __getattr__(name)
   1083 def __getattr__(name):
   1084     if name in _deprecated_apis:
-> 1085         return getattr(_numpy, name)
   1087     raise AttributeError(f"module 'cupy' has no attribute {name!r}")

File ~\miniconda3\envs\ultrack\Lib\site-packages\numpy\__init__.py:424, in __getattr__(attr)
    421     import numpy.char as char
    422     return char.chararray
--> 424 raise AttributeError("module {!r} has no attribute "
    425                      "{!r}".format(__name__, attr))

AttributeError: module 'numpy' has no attribute 'bool8'

Thanks so much for your help!

Jorge