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

ValueError: zero-size array to reduction operation maximum which has no identity #27

Open
sebherbert opened this issue Nov 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sebherbert
Copy link

Describe the bug
Running the stardist-napari plugin outputs a value error. Napari doesn's crash and I think the output is still ok though.

(napari-stardist) herber0000@herber0000-desktop:~$ napari
2024-11-12 10:17:35.763860: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-11-12 10:17:36.533885: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-11-12 10:17:52.689143: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2251] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
Loading network weights from 'weights_best.h5'.
Couldn't load thresholds from 'thresholds.json', using default values. (Call 'optimize_thresholds' to change that.)
Using default values: prob_thresh=0.5, nms_thresh=0.4.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniconda3/envs/napari-stardist/lib/python3.10/site-packages/superqt/utils/_qthreading.py:613, in create_worker.<locals>.reraise(e=ValueError('zero-size array to reduction operation maximum which has no identity'))
    612 def reraise(e):
--> 613     raise e
        e = ValueError('zero-size array to reduction operation maximum which has no identity')

File ~/miniconda3/envs/napari-stardist/lib/python3.10/site-packages/superqt/utils/_qthreading.py:175, in WorkerBase.run(self=<napari._qt.qthreading.GeneratorWorker object>)
    173     warnings.filterwarnings("always")
    174     warnings.showwarning = lambda *w: self.warned.emit(w)
--> 175     result = self.work()
        self = <napari._qt.qthreading.GeneratorWorker object at 0x7a6b4d5d7910>
    176 if isinstance(result, Exception):
    177     if isinstance(result, RuntimeError):
    178         # The Worker object has likely been deleted.
    179         # A deleted wrapped C/C++ object may result in a runtime
    180         # error that will cause segfault if we try to do much other
    181         # than simply notify the user.

File ~/miniconda3/envs/napari-stardist/lib/python3.10/site-packages/superqt/utils/_qthreading.py:440, in GeneratorWorker.work(self=<napari._qt.qthreading.GeneratorWorker object>)
    438 try:
    439     _input = self._next_value()
--> 440     output = self._gen.send(_input)
        self = <napari._qt.qthreading.GeneratorWorker object at 0x7a6b4d5d7910>
        _input = None
        output = ('nms', None)
        self._gen = <generator object _plugin_wrapper.<locals>.plugin.<locals>.run at 0x7a6b4ed6e960>
    441     self.yielded.emit(output)
    442 except StopIteration as exc:

File ~/miniconda3/envs/napari-stardist/lib/python3.10/site-packages/stardist_napari/_dock_widget.py:1085, in _plugin_wrapper.<locals>.plugin.<locals>.run()
   1075 @thread_worker(
   1076     connect={
   1077         "yielded": progress_update,
   (...)
   1082 )
   1083 def run():
   1084     r = None
-> 1085     for r in computation_generator:
        r = ('nms', None)
        computation_generator = <generator object _plugin_wrapper.<locals>.plugin_function_generator at 0x7a6b4ed6dee0>
   1086         if is_progress_msg(r):
   1087             yield r

File ~/miniconda3/envs/napari-stardist/lib/python3.10/site-packages/stardist_napari/_dock_widget.py:680, in _plugin_wrapper.<locals>.plugin_function_generator(model=StarDist3D(stardist_23102024_combo108_epoch200_w..., 'patience': 40, 'min_delta': 0}, use_gpu=False), image=<Image layer 'C3-03022022_Label49_t1_100x_0.21_02_POS_current_crop'>, axes='ZYX', slice_image=None, norm_image=True, perc_low=1.0, perc_high=99.8, input_scale=None, prob_thresh=0.5, nms_thresh=0.4, output_type=<Output.Polys: 'Polygons / Polyhedra'>, n_tiles=None, norm_axes='ZYX', timelapse_opts=<TimelapseLabels.Unique: 'Unique through time'>, cnn_output=False, image_data=array([[[56, 26, ..., 39, 33],
        [47, 56, ...],
        [40, 52, ..., 65, 35]]], dtype=uint16))
    672     n_objects = len(polys["points"])
    673     surface = surface_from_polys(polys)
    674     layers.append(
    675         move_layer_axes(
    676             (
    677                 surface,
    678                 dict(
    679                     name="StarDist polyhedra",
--> 680                     contrast_limits=(0, surface[-1].max()),
        layers = []
        surface = [array([], dtype=float64), array([], dtype=float64), array([], dtype=float64)]
        surface[-1] = array([], dtype=float64)
        scale_out = [1.0, 1.0, 1.0]
        n_objects = 0
        origin_out = [0, 0, 0]
        layer_axes_from = 'ZYX'
        layer_axes_to = 'ZYX'
    681                     scale=scale_out,
    682                     colormap=label_colormap(n_objects),
    683                     translate=origin_out,
    684                 ),
    685                 "surface",
    686             ),
    687             layer_axes_from,
    688             layer_axes_to,
    689         )
    690     )
    691 else:
    692     # TODO: coordinates correct or need offset (0.5 or so)?
    693     shapes = np.moveaxis(polys["coord"], -1, -2)

File ~/miniconda3/envs/napari-stardist/lib/python3.10/site-packages/numpy/core/_methods.py:41, in _amax(a=array([], dtype=float64), axis=None, out=None, keepdims=False, initial=<no value>, where=True)
     39 def _amax(a, axis=None, out=None, keepdims=False,
     40           initial=_NoValue, where=True):
---> 41     return umr_maximum(a, axis, None, out, keepdims, initial, where)
        umr_maximum = <built-in method reduce of numpy.ufunc object at 0x7a6bf747ce40>
        a = array([], dtype=float64)
        axis = None
        out = None
        keepdims = False
        initial = <no value>
        where = True

ValueError: zero-size array to reduction operation maximum which has no identity

To reproduce
Python env
Create a conda environment with python 3.10
pip install tensorflow[and-cuda] (GPU compatibility test )
pip install stardist
pip install stardist-napari
pip install PyQt5
pip install tensorflow==2.16.1 (to fix the numpy crash in v2.1.0, downgrade to 1.24 is only possible if downgrade for tf 2.18.0 to 2.16.1)
stardist-napari now boots in napari

Expected behavior
No erro message

Data and screenshots
Test dataset and custom network can be found here: https://drive.switch.ch/index.php/s/gxpHKj0Pg4esmE2

Environment:

  1. Please copy and paste the information at napari info option in the help menubar.
napari: 0.5.4
Platform: Linux-6.8.0-48-generic-x86_64-with-glibc2.39
System: Ubuntu 24.04.1 LTS
Python: 3.10.15 | packaged by conda-forge | (main, Oct 16 2024, 01:24:24) [GCC 13.3.0]
Qt: 5.15.14
PyQt5: 5.15.11
NumPy: 1.24.0
SciPy: 1.14.1
Dask: 2024.11.0
VisPy: 0.14.3
magicgui: 0.9.1
superqt: 0.6.7
in-n-out: 0.2.1
app-model: 0.3.0
psygnal: 0.11.1
npe2: 0.7.7
pydantic: 2.9.2

OpenGL:
- GL version: 4.6.0 NVIDIA 535.183.01
- MAX_TEXTURE_SIZE: 32768
- GL_MAX_3D_TEXTURE_SIZE: 16384

Screens:
- screen 1: resolution 1920x1200, scale 1.0
- screen 2: resolution 1600x1200, scale 1.0

Optional:
- numba: 0.60.0
- triangle not installed
- napari-plugin-manager not installed

Settings path:
- /home/herber0000/.config/napari/napari-stardist_3a606daac139f953f571ad550336c6fe9e3198c3/settings.yaml
  1. Please run this code and paste the output:
os: Linux-6.8.0-48-generic-x86_64-with-glibc2.39
stardist_napari: 2024.8.6.1
stardist: 0.9.1
csbdeep: 0.8.1
napari: 0.5.4
magicgui: 0.9.1
2024-11-12 14:22:47.855205: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-11-12 14:22:48.477994: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
tensorflow: 2.16.1
@sebherbert sebherbert added the bug Something isn't working label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant