CellSeg3D icon indicating copy to clipboard operation
CellSeg3D copied to clipboard

TypeError: reshape() got an unexpected keyword argument 'newshape' when running inference

Open longyuxi opened this issue 1 year ago • 2 comments

Hello,

I am getting the error TypeError: reshape() got an unexpected keyword argument 'newshape' when I use CellSeg3D to perform inference on my data using a pretrained model.

My sequence of actions:

  1. Open Napari on a folder that consists of an image stack
  2. Go to Plugins -> CellSeg3D -> Inference
  3. In the widget that pops up, without changing any of the default parameters, click "Start"

Then after about 30 seconds, napari might crash with a segmentation fault. Even in the case that napari doesn't crash, nothing seems to change (no inferred images are created). This is the log in the terminal:

(cellseg) ┌─[yul4024@wulab-precision1] - [~/Documents/downsample_stack] - [229]
└─[$] napari cellseg_test_stack                                                                 [8:24:32]
/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/pytools/persistent_dict.py:63: RecommendedHashNotFoundWarning: Unable to import recommended hash 'siphash24.siphash13', falling back to 'hashlib.sha256'. Run 'python3 -m pip install siphash24' to install the recommended hash.!
08:24:48 INFO pydensecrf not installed, CRF post-processing will not be available. Please install by running : pip install pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=masterThis is not a hard requirement, you do not need it to install it unless you want to use the CRF post-processing step.
08:24:48 INFO wandb not installed, wandb config will not be taken into account
08:24:50 INFO Starting...
08:24:50 INFO ********************
08:24:50 INFO Worker started at 08:24:50
08:24:50 INFO Saving results to : /home/yul4024/cellseg3d/inference
08:24:50 INFO Worker is running...
08:24:50 INFO MODEL DIMS : 64
08:24:50 INFO Model name : SegResNet
08:24:50 INFO Instantiating model...
08:24:50 INFO ********************
08:24:50 INFO Weight file SegResNet_latest.pth already exists, skipping download
08:24:50 INFO Loading weights...
08:24:51 ERROR reshape() got an unexpected keyword argument 'newshape'
Traceback (most recent call last):
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/napari_cellseg3d/code_models/worker_inference.py", line 969, in inference
    input_image = self.load_layer()
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/napari_cellseg3d/code_models/worker_inference.py", line 283, in load_layer
    volume = np.reshape(volume, newshape=(1, *volume.shape))
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/dask/array/core.py", line 1753, in __array_function__
    return da_func(*args, **kwargs)
TypeError: reshape() got an unexpected keyword argument 'newshape'
08:24:51 INFO Weights status : <All keys matched successfully>
08:24:51 INFO Done
08:24:51 INFO --------------------
08:24:51 INFO Parameters summary :
08:24:51 INFO Model is : SegResNet
08:24:51 INFO Window inference is disabled
08:24:51 INFO Dataset loaded on cuda:0 device
08:24:51 INFO --------------------
08:24:51 INFO Loading layer
08:24:51 INFO 
Worker finished at 08:24:51
08:24:51 INFO ********************
08:24:51 INFO Emptying cache...
08:24:51 INFO Attempt complete : Cache emptied

Here is how I installed these packages. I uninstalled and reinstalled this environment in this exact manner to make sure it was not a one-time corrupt install of Numpy:

(base) ┌─[yul4024@wulab-precision1] - [~/Documents/downsample_stack] - [206]
└─[$] mamba create -n cellseg python=3.9 napari=0.4 pyqt                                        [8:01:37]

Looking for: ['python=3.9', 'napari=0.4', 'pyqt']

conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache
Transaction

  Prefix: /home/yul4024/miniforge3/envs/cellseg

  Updating specs:

   - python=3.9
   - napari=0.4
   - pyqt


  Package                               Version  Build                Channel           Size
──────────────────────────────────────────────────────────────────────────────────────────────
  Install:
──────────────────────────────────────────────────────────────────────────────────────────────

  + _libgcc_mutex                           0.1  conda_forge          conda-forge     Cached
  + python_abi                              3.9  5_cp39               conda-forge     Cached
  + libglvnd                              1.7.0  ha4b6fd6_0           conda-forge     Cached
  + ca-certificates                   2024.8.30  hbcca054_0           conda-forge     Cached
  + ld_impl_linux-64                       2.43  h712a8e2_1           conda-forge     Cached
  + libgomp                              14.1.0  h77fa898_1           conda-forge     Cached
  + libegl                                1.7.0  ha4b6fd6_0           conda-forge     Cached
  + _openmp_mutex                           4.5  2_gnu                conda-forge     Cached
  + libgcc                               14.1.0  h77fa898_1           conda-forge     Cached
  + libbrotlicommon                       1.1.0  hb9d3cd8_2           conda-forge     Cached
  + xorg-libxdmcp                         1.1.5  hb9d3cd8_0           conda-forge     Cached
  + pthread-stubs                           0.4  hb9d3cd8_1002        conda-forge     Cached
  + xorg-xf86vidmodeproto                 2.3.1  hb9d3cd8_1003        conda-forge     Cached
  + libgfortran5                         14.1.0  hc5f4f2c_1           conda-forge     Cached
  + xorg-xorgproto                       2024.1  hb9d3cd8_1           conda-forge     Cached
  + xorg-xextproto                        7.3.0  hb9d3cd8_1004        conda-forge     Cached
  + xorg-libice                           1.1.1  hb9d3cd8_1           conda-forge     Cached
  + xorg-libxau                          1.0.11  hb9d3cd8_1           conda-forge     Cached
  + libexpat                              2.6.3  h5888daf_0           conda-forge     Cached
  + libstdcxx                            14.1.0  hc0a3c3a_1           conda-forge     Cached
  + libgcc-ng                            14.1.0  h69a702a_1           conda-forge     Cached
  + openssl                               3.3.2  hb9d3cd8_0           conda-forge     Cached
  + libbrotlienc                          1.1.0  hb9d3cd8_2           conda-forge     Cached
  + libbrotlidec                          1.1.0  hb9d3cd8_2           conda-forge     Cached
  + libgfortran                          14.1.0  h69a702a_1           conda-forge     Cached
  + libxcb                               1.17.0  h8a09558_0           conda-forge     Cached
  + expat                                 2.6.3  h5888daf_0           conda-forge     Cached
  + zlib-ng                               2.2.2  h5888daf_0           conda-forge     Cached
  + zfp                                   1.0.1  h5888daf_2           conda-forge     Cached
  + libstdcxx-ng                         14.1.0  h4852527_1           conda-forge     Cached
  + rav1e                                 0.6.6  he8a937b_2           conda-forge     Cached
  + dav1d                                 1.2.1  hd590300_0           conda-forge     Cached
  + jxrlib                                  1.1  hd590300_3           conda-forge     Cached
  + giflib                                5.2.2  hd590300_0           conda-forge     Cached
  + libdeflate                             1.21  h4bc722e_0           conda-forge     Cached
  + libxcrypt                            4.4.36  hd590300_1           conda-forge     Cached
  + bzip2                                 1.0.8  h4bc722e_7           conda-forge     Cached
  + yaml                                  0.2.5  h7f98852_2           conda-forge     Cached
  + libjpeg-turbo                         3.0.0  hd590300_1           conda-forge     Cached
  + ncurses                                 6.5  he02047a_1           conda-forge     Cached
  + libsodium                            1.0.20  h4ab18f5_0           conda-forge     Cached
  + libwebp-base                          1.4.0  hd590300_0           conda-forge     Cached
  + attr                                  2.5.1  h166bdaf_1           conda-forge     Cached
  + libffi                                3.4.2  h7f98852_5           conda-forge     Cached
  + libgettextpo                         0.22.5  he02047a_3           conda-forge     Cached
  + gettext-tools                        0.22.5  he02047a_3           conda-forge     Cached
  + libopus                               1.3.1  h7f98852_1           conda-forge     Cached
  + lame                                  3.100  h166bdaf_1003        conda-forge     Cached
  + libzlib                               1.3.1  h4ab18f5_1           conda-forge     Cached
  + libiconv                               1.17  hd590300_2           conda-forge     Cached
  + libpciaccess                           0.18  hd590300_0           conda-forge     Cached
  + keyutils                              1.6.1  h166bdaf_0           conda-forge     Cached
  + libogg                                1.3.5  h4ab18f5_0           conda-forge     Cached
  + alsa-lib                             1.2.12  h4ab18f5_0           conda-forge     Cached
  + libuuid                              2.38.1  h0b41bf4_0           conda-forge     Cached
  + libnsl                                2.0.1  hd590300_0           conda-forge     Cached
  + xz                                    5.2.6  h166bdaf_0           conda-forge     Cached
  + mysql-common                          9.0.1  h266115a_1           conda-forge     Cached
  + libevent                             2.1.12  hf998b51_1           conda-forge     Cached
  + brotli-bin                            1.1.0  hb9d3cd8_2           conda-forge     Cached
  + libgfortran-ng                       14.1.0  h69a702a_1           conda-forge     Cached
  + xorg-libx11                          1.8.10  h4f16b4b_0           conda-forge     Cached
  + xcb-util-wm                           0.4.2  hb711507_0           conda-forge     Cached
  + xcb-util-renderutil                  0.3.10  hb711507_0           conda-forge     Cached
  + xcb-util-keysyms                      0.4.1  hb711507_0           conda-forge     Cached
  + xcb-util                              0.4.1  hb711507_2           conda-forge     Cached
  + libzopfli                             1.0.3  h9c3ff4c_0           conda-forge     Cached
  + svt-av1                               2.2.1  h5888daf_0           conda-forge     Cached
  + aom                                   3.9.1  hac33072_0           conda-forge     Cached
  + libhwy                                1.1.0  h00ab1b0_0           conda-forge     Cached
  + snappy                                1.2.1  ha2e4443_0           conda-forge     Cached
  + libaec                                1.1.3  h59595ed_0           conda-forge     Cached
  + charls                                2.4.2  h59595ed_0           conda-forge     Cached
  + lerc                                  4.0.0  h27087fc_0           conda-forge     Cached
  + graphite2                            1.3.13  h59595ed_1003        conda-forge     Cached
  + libasprintf                          0.22.5  he8f35ee_3           conda-forge     Cached
  + mpg123                               1.32.6  h59595ed_0           conda-forge     Cached
  + lz4-c                                 1.9.4  hcb278e6_0           conda-forge     Cached
  + pixman                               0.43.2  h59595ed_0           conda-forge     Cached
  + nspr                                   4.35  h27087fc_0           conda-forge     Cached
  + icu                                    75.1  he02047a_0           conda-forge     Cached
  + libedit                        3.1.20191231  he28a2e2_2           conda-forge     Cached
  + readline                                8.2  h8228510_1           conda-forge     Cached
  + libcap                                 2.69  h0f662aa_0           conda-forge     Cached
  + libgettextpo-devel                   0.22.5  he02047a_3           conda-forge     Cached
  + tk                                   8.6.13  noxft_h4845f30_101   conda-forge     Cached
  + pcre2                                 10.44  hba22ea6_2           conda-forge     Cached
  + zlib                                  1.3.1  h4ab18f5_1           conda-forge     Cached
  + zstd                                  1.5.6  ha6fb4c9_0           conda-forge     Cached
  + libpng                               1.6.44  hadc24fc_0           conda-forge     Cached
  + libsqlite                            3.46.1  hadc24fc_0           conda-forge     Cached
  + libdrm                              2.4.123  hb9d3cd8_0           conda-forge     Cached
  + libvorbis                             1.3.7  h9c3ff4c_0           conda-forge     Cached
  + xorg-libsm                            1.2.4  he73a12e_1           conda-forge     Cached
  + brotli                                1.1.0  hb9d3cd8_2           conda-forge     Cached
  + libopenblas                          0.3.27  pthreads_hac2b453_1  conda-forge     Cached
  + xkeyboard-config                       2.42  h4ab18f5_0           conda-forge     Cached
  + xorg-libxrender                      0.9.11  hb9d3cd8_1           conda-forge     Cached
  + xorg-libxext                          1.3.6  hb9d3cd8_0           conda-forge     Cached
  + libglx                                1.7.0  ha4b6fd6_0           conda-forge     Cached
  + xcb-util-image                        0.4.0  hb711507_2           conda-forge     Cached
  + libavif16                             1.1.1  h104a339_1           conda-forge     Cached
  + libjxl                               0.11.0  hdb8da77_0           conda-forge     Cached
  + libasprintf-devel                    0.22.5  he8f35ee_3           conda-forge     Cached
  + libxml2                              2.12.7  he7c6b58_4           conda-forge     Cached
  + krb5                                 1.21.3  h659f571_0           conda-forge     Cached
  + libglib                              2.82.1  h2ff4ddf_0           conda-forge     Cached
  + c-blosc2                             2.15.1  hc57e6cf_0           conda-forge     Cached
  + blosc                                1.21.6  hef167b5_0           conda-forge     Cached
  + libtiff                               4.7.0  h6565414_0           conda-forge     Cached
  + mysql-libs                            9.0.1  he0572af_1           conda-forge     Cached
  + freetype                             2.12.1  h267a509_2           conda-forge     Cached
  + nss                                   3.105  hd34e28f_0           conda-forge     Cached
  + brunsli                                 0.1  h9c3ff4c_0           conda-forge     Cached
  + libblas                               3.9.0  24_linux64_openblas  conda-forge     Cached
  + xorg-libxxf86vm                       1.1.5  hb9d3cd8_2           conda-forge     Cached
  + libgl                                 1.7.0  ha4b6fd6_0           conda-forge     Cached
  + gettext                              0.22.5  he02047a_3           conda-forge     Cached
  + libllvm15                            15.0.7  hb3ce162_4           conda-forge     Cached
  + libllvm19                            19.1.0  ha7bfdaf_0           conda-forge     Cached
  + libxkbcommon                          1.7.0  h2c5496b_1           conda-forge     Cached
  + libpq                                  16.4  h2d7952a_2           conda-forge     Cached
  + zeromq                                4.3.5  ha4adb4c_5           conda-forge     Cached
  + libcups                               2.3.3  h4637d8d_4           conda-forge     Cached
  + glib-tools                           2.82.1  h4833e2c_0           conda-forge     Cached
  + dbus                                 1.13.6  h5008d03_3           conda-forge     Cached
  + openjpeg                              2.5.2  h488ebb8_0           conda-forge     Cached
  + lcms2                                  2.16  hb7c19ff_0           conda-forge     Cached
  + fontconfig                           2.14.2  h14ed4e7_0           conda-forge     Cached
  + libcblas                              3.9.0  24_linux64_openblas  conda-forge     Cached
  + liblapack                             3.9.0  24_linux64_openblas  conda-forge     Cached
  + libgpg-error                           1.50  h4f305b6_0           conda-forge     Cached
  + libflac                               1.4.3  h59595ed_0           conda-forge     Cached
  + libclang-cpp15                       15.0.7  default_h127d8a8_5   conda-forge     Cached
  + libclang13                           19.1.0  default_h9c6a7e4_0   conda-forge     Cached
  + libgcrypt                            1.11.0  h4ab18f5_1           conda-forge     Cached
  + libsndfile                            1.2.2  hc60ed4a_1           conda-forge     Cached
  + libsystemd0                           256.6  h2774228_0           conda-forge     Cached
  + pulseaudio-client                      17.0  hb77b528_0           conda-forge     Cached
  + font-ttf-dejavu-sans-mono              2.37  hab24e00_0           conda-forge     Cached
  + font-ttf-inconsolata                  3.000  h77eed37_0           conda-forge     Cached
  + font-ttf-source-code-pro              2.038  h77eed37_0           conda-forge     Cached
  + font-ttf-ubuntu                        0.83  h77eed37_3           conda-forge     Cached
  + tzdata                                2024a  h8827d51_1           conda-forge     Cached
  + fonts-conda-forge                         1  0                    conda-forge     Cached
  + fonts-conda-ecosystem                     1  0                    conda-forge     Cached
  + python                               3.9.20  h13acc7a_1_cpython   conda-forge       24MB
  + cairo                                1.18.0  hebfffa5_3           conda-forge     Cached
  + harfbuzz                              9.0.0  hda332d3_1           conda-forge     Cached
  + wheel                                0.44.0  pyhd8ed1ab_0         conda-forge     Cached
  + setuptools                           75.1.0  pyhd8ed1ab_0         conda-forge     Cached
  + pip                                    24.2  pyh8b19718_1         conda-forge     Cached
  + hyperframe                            6.0.1  pyhd8ed1ab_0         conda-forge     Cached
  + sphinxcontrib-jsmath                  1.0.1  pyhd8ed1ab_0         conda-forge     Cached
  + hpack                                 4.0.0  pyh9f0ad1d_0         conda-forge     Cached
  + pycparser                              2.22  pyhd8ed1ab_0         conda-forge     Cached
  + pysocks                               1.7.1  pyha2e5f31_6         conda-forge     Cached
  + mdurl                                 0.1.2  pyhd8ed1ab_0         conda-forge     Cached
  + charset-normalizer                    3.3.2  pyhd8ed1ab_0         conda-forge     Cached
  + idna                                   3.10  pyhd8ed1ab_0         conda-forge     Cached
  + alabaster                            0.7.16  pyhd8ed1ab_0         conda-forge     Cached
  + imagesize                             1.4.1  pyhd8ed1ab_0         conda-forge     Cached
  + docutils                             0.21.2  pyhd8ed1ab_0         conda-forge     Cached
  + shellingham                           1.5.4  pyhd8ed1ab_0         conda-forge     Cached
  + parso                                 0.8.4  pyhd8ed1ab_0         conda-forge     Cached
  + tomli-w                               1.0.0  pyhd8ed1ab_0         conda-forge     Cached
  + snowballstemmer                       2.2.0  pyhd8ed1ab_0         conda-forge     Cached
  + tabulate                              0.9.0  pyhd8ed1ab_1         conda-forge     Cached
  + locket                                1.0.0  pyhd8ed1ab_0         conda-forge     Cached
  + ptyprocess                            0.7.0  pyhd3deb0d_0         conda-forge     Cached
  + platformdirs                          4.3.6  pyhd8ed1ab_0         conda-forge     Cached
  + wcwidth                              0.2.13  pyhd8ed1ab_0         conda-forge     Cached
  + six                                  1.16.0  pyh6c4a22f_0         conda-forge     Cached
  + pure_eval                             0.2.3  pyhd8ed1ab_0         conda-forge     Cached
  + executing                             2.1.0  pyhd8ed1ab_0         conda-forge     Cached
  + colorama                              0.4.6  pyhd8ed1ab_0         conda-forge     Cached
  + fasteners                            0.17.3  pyhd8ed1ab_0         conda-forge     Cached
  + pytz                                 2024.1  pyhd8ed1ab_0         conda-forge     Cached
  + python-tzdata                        2024.2  pyhd8ed1ab_0         conda-forge     Cached
  + networkx                              3.2.1  pyhd8ed1ab_0         conda-forge     Cached
  + tomli                                 2.0.1  pyhd8ed1ab_0         conda-forge     Cached
  + ply                                    3.11  pyhd8ed1ab_2         conda-forge     Cached
  + hsluv                                 5.0.4  pyhd8ed1ab_0         conda-forge     Cached
  + freetype-py                           2.5.1  pyhd8ed1ab_0         conda-forge     Cached
  + heapdict                              1.0.1  pyhd8ed1ab_1         conda-forge     Cached
  + in-n-out                              0.2.1  pyhd8ed1ab_0         conda-forge     Cached
  + cloudpickle                           3.0.0  pyhd8ed1ab_0         conda-forge     Cached
  + click                                 8.1.7  unix_pyh707e725_0    conda-forge     Cached
  + zipp                                 3.20.2  pyhd8ed1ab_0         conda-forge     Cached
  + nest-asyncio                          1.6.0  pyhd8ed1ab_0         conda-forge     Cached
  + exceptiongroup                        1.2.2  pyhd8ed1ab_0         conda-forge     Cached
  + traitlets                            5.14.3  pyhd8ed1ab_0         conda-forge     Cached
  + pickleshare                           0.7.5  py_1003              conda-forge     Cached
  + decorator                             5.1.1  pyhd8ed1ab_0         conda-forge     Cached
  + attrs                                24.2.0  pyh71513ae_0         conda-forge     Cached
  + pkgutil-resolve-name                 1.3.10  pyhd8ed1ab_1         conda-forge     Cached
  + docstring_parser                       0.16  pyhd8ed1ab_0         conda-forge     Cached
  + typing_extensions                    4.12.2  pyha770c72_0         conda-forge     Cached
  + toolz                                0.12.1  pyhd8ed1ab_0         conda-forge     Cached
  + pygments                             2.18.0  pyhd8ed1ab_0         conda-forge     Cached
  + fsspec                             2024.9.0  pyhff2d567_0         conda-forge     Cached
  + asciitree                             0.3.3  py_2                 conda-forge     Cached
  + pyopengl                              3.1.6  pyhd8ed1ab_1         conda-forge     Cached
  + certifi                           2024.8.30  pyhd8ed1ab_0         conda-forge     Cached
  + packaging                              24.1  pyhd8ed1ab_0         conda-forge     Cached
  + toml                                 0.10.2  pyhd8ed1ab_0         conda-forge     Cached
  + appdirs                               1.4.4  pyh9f0ad1d_0         conda-forge     Cached
  + h2                                    4.1.0  pyhd8ed1ab_0         conda-forge     Cached
  + markdown-it-py                        3.0.0  pyhd8ed1ab_0         conda-forge     Cached
  + jedi                                 0.19.1  pyhd8ed1ab_0         conda-forge     Cached
  + pexpect                               4.9.0  pyhd8ed1ab_0         conda-forge     Cached
  + prompt-toolkit                       3.0.48  pyha770c72_0         conda-forge     Cached
  + asttokens                             2.4.1  pyhd8ed1ab_0         conda-forge     Cached
  + python-dateutil                       2.9.0  pyhd8ed1ab_0         conda-forge     Cached
  + tqdm                                 4.66.5  pyhd8ed1ab_0         conda-forge     Cached
  + babel                                2.14.0  pyhd8ed1ab_0         conda-forge     Cached
  + pyproject_hooks                       1.2.0  pyh7850678_0         conda-forge     Cached
  + cachey                                0.2.1  pyh9f0ad1d_0         conda-forge     Cached
  + importlib_resources                   6.4.5  pyhd8ed1ab_0         conda-forge     Cached
  + importlib-metadata                    8.5.0  pyha770c72_0         conda-forge     Cached
  + comm                                  0.2.2  pyhd8ed1ab_0         conda-forge     Cached
  + jupyter_core                          5.7.2  pyh31011fe_1         conda-forge     Cached
  + matplotlib-inline                     0.1.7  pyhd8ed1ab_0         conda-forge     Cached
  + typer-slim                           0.12.5  pyhd8ed1ab_0         conda-forge     Cached
  + typing-extensions                    4.12.2  hd8ed1ab_0           conda-forge     Cached
  + partd                                 1.4.2  pyhd8ed1ab_0         conda-forge     Cached
  + qtpy                                  2.4.1  pyhd8ed1ab_0         conda-forge     Cached
  + rich                                 13.8.1  pyhd8ed1ab_0         conda-forge     Cached
  + stack_data                            0.6.2  pyhd8ed1ab_0         conda-forge     Cached
  + python-build                          1.2.2  pyhd8ed1ab_0         conda-forge     Cached
  + importlib_metadata                    8.5.0  hd8ed1ab_0           conda-forge     Cached
  + lazy-loader                             0.4  pyhd8ed1ab_1         conda-forge     Cached
  + napari-plugin-engine                  0.2.0  pyhd8ed1ab_2         conda-forge     Cached
  + annotated-types                       0.7.0  pyhd8ed1ab_0         conda-forge     Cached
  + flexparser                            0.3.1  pyhd8ed1ab_0         conda-forge     Cached
  + flexcache                               0.3  pyhd8ed1ab_0         conda-forge     Cached
  + typer-slim-standard                  0.12.5  hd8ed1ab_0           conda-forge     Cached
  + ipython                              8.18.1  pyh707e725_3         conda-forge     Cached
  + lazy_loader                             0.4  pyhd8ed1ab_1         conda-forge     Cached
  + pint                                 0.24.3  pyhd8ed1ab_0         conda-forge     Cached
  + typer                                0.12.5  pyhd8ed1ab_0         conda-forge     Cached
  + brotli-python                         1.1.0  py39hf88036b_2       conda-forge     Cached
  + markupsafe                            2.1.5  py39h8cd3c5a_1       conda-forge     Cached
  + msgpack-python                        1.1.0  py39h74842e3_0       conda-forge     Cached
  + kiwisolver                            1.4.7  py39h74842e3_0       conda-forge     Cached
  + debugpy                               1.8.6  py39hf88036b_0       conda-forge     Cached
  + tornado                               6.4.1  py39h8cd3c5a_1       conda-forge     Cached
  + pyzmq                                26.2.0  py39h4e4fb57_2       conda-forge     Cached
  + rpds-py                              0.20.0  py39he612d8f_1       conda-forge     Cached
  + wrapt                                1.16.0  py39h8cd3c5a_1       conda-forge     Cached
  + pyyaml                                6.0.2  py39h8cd3c5a_1       conda-forge     Cached
  + psutil                                6.0.0  py39h8cd3c5a_1       conda-forge     Cached
  + pillow                               10.4.0  py39h648eaa6_1       conda-forge     Cached
  + numpy                                1.26.4  py39h474f0d3_0       conda-forge     Cached
  + cffi                                 1.17.1  py39h15c3d72_0       conda-forge     Cached
  + cytoolz                              0.12.3  py39hd1e30aa_0       conda-forge     Cached
  + glib                                 2.82.1  h2ff4ddf_0           conda-forge     Cached
  + sip                                  6.7.12  py39h3d6467e_0       conda-forge     Cached
  + pydantic-core                        2.23.4  py39he612d8f_0       conda-forge     Cached
  + imagecodecs                        2024.6.1  py39hd2cbb1d_4       conda-forge     Cached
  + numcodecs                            0.12.1  py39h84cc369_1       conda-forge     Cached
  + pywavelets                            1.6.0  py39hd92a3bb_0       conda-forge     Cached
  + vispy                                0.14.3  py39h5876728_1       conda-forge     Cached
  + scipy                                1.13.1  py39haf93ffa_0       conda-forge     Cached
  + pandas                                2.2.3  py39h3b40f6f_1       conda-forge     Cached
  + zstandard                            0.23.0  py39h08a7858_1       conda-forge     Cached
  + gstreamer                            1.24.7  hf3bb09a_0           conda-forge     Cached
  + pyqt5-sip                           12.12.2  py39h3d6467e_5       conda-forge     Cached
  + gst-plugins-base                     1.24.7  h0a52356_0           conda-forge     Cached
  + qt-main                              5.15.8  h3155989_26          conda-forge     Cached
  + pyqt                                 5.15.9  py39h52134e7_5       conda-forge     Cached
  + jinja2                                3.1.4  pyhd8ed1ab_0         conda-forge     Cached
  + jupyter_client                        8.6.3  pyhd8ed1ab_0         conda-forge     Cached
  + referencing                          0.35.1  pyhd8ed1ab_0         conda-forge     Cached
  + psygnal                              0.11.1  pyhd8ed1ab_0         conda-forge     Cached
  + dask-core                          2024.8.0  pyhd8ed1ab_0         conda-forge     Cached
  + imageio                              2.35.1  pyh12aca89_0         conda-forge     Cached
  + pydantic                              2.9.2  pyhd8ed1ab_0         conda-forge     Cached
  + tifffile                          2024.6.18  pyhd8ed1ab_0         conda-forge     Cached
  + zarr                                 2.18.2  pyhd8ed1ab_0         conda-forge     Cached
  + urllib3                               2.2.3  pyhd8ed1ab_0         conda-forge     Cached
  + ipykernel                            6.29.5  pyh3099207_0         conda-forge     Cached
  + jsonschema-specifications         2023.12.1  pyhd8ed1ab_0         conda-forge     Cached
  + napari-svg                            0.2.0  pyhd8ed1ab_0         conda-forge     Cached
  + pydantic-compat                       0.1.2  pyhd8ed1ab_0         conda-forge     Cached
  + npe2                                  0.7.7  pyhd8ed1ab_0         conda-forge     Cached
  + requests                             2.32.3  pyhd8ed1ab_0         conda-forge     Cached
  + qtconsole-base                        5.6.0  pyha770c72_0         conda-forge     Cached
  + jsonschema                           4.23.0  pyhd8ed1ab_0         conda-forge     Cached
  + app-model                             0.2.8  pyhd8ed1ab_0         conda-forge     Cached
  + sphinx                                7.4.7  pyhd8ed1ab_0         conda-forge     Cached
  + sphinxcontrib-applehelp               2.0.0  pyhd8ed1ab_0         conda-forge     Cached
  + pyconify                              0.1.6  pyhd8ed1ab_0         conda-forge     Cached
  + pooch                                 1.8.2  pyhd8ed1ab_0         conda-forge     Cached
  + napari-console                        0.0.9  pyh9208f05_0         conda-forge     Cached
  + sphinxcontrib-qthelp                  2.0.0  pyhd8ed1ab_0         conda-forge     Cached
  + superqt                               0.6.7  pyh9208f05_0         conda-forge     Cached
  + sphinxcontrib-devhelp                 2.0.0  pyhd8ed1ab_0         conda-forge     Cached
  + magicgui                              0.8.3  pyhd8ed1ab_0         conda-forge     Cached
  + sphinxcontrib-htmlhelp                2.1.0  pyhd8ed1ab_0         conda-forge     Cached
  + sphinxcontrib-serializinghtml        1.1.10  pyhd8ed1ab_0         conda-forge     Cached
  + numpydoc                              1.8.0  pyhd8ed1ab_0         conda-forge     Cached
  + scikit-image                         0.24.0  py39h5114956_2       conda-forge     Cached
  + napari                         0.4.19.post1  pyh9208f05_0         conda-forge     Cached

  Summary:

  Install: 304 packages

  Total download: 24MB

──────────────────────────────────────────────────────────────────────────────────────────────


Confirm changes: [Y/n] 
python                                              23.7MB @  46.2MB/s  0.5s

Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

To activate this environment, use

     $ mamba activate cellseg

To deactivate an active environment, use

     $ mamba deactivate

(base) ┌─[yul4024@wulab-precision1] - [~/Documents/downsample_stack] - [207]
└─[$] conda activate cellseg                                                                    [8:02:24]

(cellseg) ┌─[yul4024@wulab-precision1] - [~/Documents/downsample_stack] - [209]
└─[$] mamba install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia       [8:02:33]

Looking for: ['pytorch', 'torchvision', 'torchaudio', 'pytorch-cuda=12.4']

conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache
pytorch/noarch                                                No change
nvidia/linux-64                                               No change
nvidia/noarch                                                 No change
pytorch/linux-64                                              No change

Pinned packages:
  - python 3.9.*


Transaction

  Prefix: /home/yul4024/miniforge3/envs/cellseg

  Updating specs:

   - pytorch
   - torchvision
   - torchaudio
   - pytorch-cuda=12.4
   - ca-certificates
   - certifi
   - openssl


  Package                                    Version  Build                        Channel           Size
───────────────────────────────────────────────────────────────────────────────────────────────────────────
  Install:
───────────────────────────────────────────────────────────────────────────────────────────────────────────

  + pytorch-mutex                                1.0  cuda                         pytorch         Cached
  + llvm-openmp                               15.0.7  h0cdce71_0                   conda-forge     Cached
  + libvpx                                    1.14.1  hac33072_0                   conda-forge     Cached
  + openh264                                   2.4.1  h59595ed_0                   conda-forge     Cached
  + gmp                                        6.3.0  hac33072_2                   conda-forge     Cached
  + x264                                  1!164.3095  h166bdaf_2                   conda-forge     Cached
  + x265                                         3.5  h924138e_3                   conda-forge     Cached
  + pugixml                                     1.14  h59595ed_0                   conda-forge     Cached
  + wayland                                   1.23.1  h3e06ad9_0                   conda-forge     Cached
  + libhwloc                                  2.11.1  default_hecaa2ac_1000        conda-forge     Cached
  + xorg-libxfixes                             6.0.1  hb9d3cd8_0                   conda-forge     Cached
  + libabseil                             20240722.0  cxx17_h5888daf_1             conda-forge     Cached
  + ocl-icd                                    2.3.2  hd590300_1                   conda-forge     Cached
  + fribidi                                   1.0.10  h36c2ea0_0                   conda-forge     Cached
  + mpfr                                       4.2.1  h90cbb55_3                   conda-forge     Cached
  + tbb                                    2021.13.0  h84d6215_0                   conda-forge     Cached
  + libprotobuf                               5.27.5  h5b01275_2                   conda-forge     Cached
  + libass                                    0.17.3  h1dc1e6a_0                   conda-forge     Cached
  + mpc                                        1.3.1  h24ddda3_1                   conda-forge     Cached
  + libopenvino                             2024.4.0  hac27bb2_1                   conda-forge     Cached
  + mkl                                     2022.2.1  h84fe81f_16997               conda-forge     Cached
  + gmpy2                                      2.1.5  py39h7196dd7_2               conda-forge     Cached
  + libopenvino-auto-batch-plugin           2024.4.0  h4d9b6c2_1                   conda-forge     Cached
  + libopenvino-auto-plugin                 2024.4.0  h4d9b6c2_1                   conda-forge     Cached
  + libopenvino-hetero-plugin               2024.4.0  h3f63f65_1                   conda-forge     Cached
  + libopenvino-intel-cpu-plugin            2024.4.0  hac27bb2_1                   conda-forge     Cached
  + libopenvino-intel-gpu-plugin            2024.4.0  hac27bb2_1                   conda-forge     Cached
  + libopenvino-intel-npu-plugin            2024.4.0  hac27bb2_1                   conda-forge     Cached
  + libopenvino-ir-frontend                 2024.4.0  h3f63f65_1                   conda-forge     Cached
  + libopenvino-onnx-frontend               2024.4.0  he882d9a_1                   conda-forge     Cached
  + libopenvino-paddle-frontend             2024.4.0  he882d9a_1                   conda-forge     Cached
  + libopenvino-pytorch-frontend            2024.4.0  h5888daf_1                   conda-forge     Cached
  + libopenvino-tensorflow-frontend         2024.4.0  h9718a47_1                   conda-forge     Cached
  + libopenvino-tensorflow-lite-frontend    2024.4.0  h5888daf_1                   conda-forge     Cached
  + blas                                         1.0  mkl                          conda-forge     Cached
  + filelock                                  3.16.1  pyhd8ed1ab_0                 conda-forge     Cached
  + mpmath                                     1.3.0  pyhd8ed1ab_0                 conda-forge     Cached
  + wayland-protocols                           1.37  hd8ed1ab_0                   conda-forge     Cached
  + sympy                                     1.13.3  pypyh2585a3b_103             conda-forge     Cached
  + cuda-cudart                             12.4.127  0                            nvidia          Cached
  + cuda-cupti                              12.4.127  0                            nvidia          Cached
  + cuda-nvrtc                              12.4.127  0                            nvidia          Cached
  + cuda-nvtx                               12.4.127  0                            nvidia          Cached
  + libcublas                              12.4.2.65  0                            nvidia          Cached
  + libcufft                               11.2.0.44  0                            nvidia          Cached
  + libcusolver                            11.6.0.99  0                            nvidia          Cached
  + libcusparse                           12.3.0.142  0                            nvidia          Cached
  + libnpp                                  12.2.5.2  0                            nvidia          Cached
  + libnvjitlink                             12.4.99  0                            nvidia          Cached
  + libnvjpeg                              12.3.1.89  0                            nvidia          Cached
  + cuda-version                                12.6  3                            nvidia          Cached
  + libva                                     2.22.0  h8a09558_1                   conda-forge     Cached
  + ffmpeg                                     7.0.2  gpl_h8657690_705             conda-forge     Cached
  + libnvfatbin                              12.6.68  0                            nvidia          Cached
  + libcurand                              10.3.7.68  0                            nvidia          Cached
  + libcufile                               1.11.1.6  0                            nvidia          Cached
  + cuda-opencl                              12.6.68  0                            nvidia          Cached
  + cuda-libraries                            12.4.0  0                            nvidia          Cached
  + cuda-runtime                              12.4.0  0                            nvidia          Cached
  + pytorch-cuda                                12.4  hc786d27_6                   pytorch         Cached
  + pytorch                                    2.4.0  py3.9_cuda12.4_cudnn9.1.0_0  pytorch            1GB
  + torchtriton                                3.0.0  py39                         pytorch          245MB
  + torchaudio                                 2.4.0  py39_cu124                   pytorch            7MB
  + torchvision                               0.19.0  py39_cu124                   pytorch            8MB

  Change:
───────────────────────────────────────────────────────────────────────────────────────────────────────────

  - _openmp_mutex                                4.5  2_gnu                        conda-forge     Cached
  + _openmp_mutex                                4.5  2_kmp_llvm                   conda-forge     Cached
  - libblas                                    3.9.0  24_linux64_openblas          conda-forge     Cached
  + libblas                                    3.9.0  16_linux64_mkl               conda-forge     Cached
  - libcblas                                   3.9.0  24_linux64_openblas          conda-forge     Cached
  + libcblas                                   3.9.0  16_linux64_mkl               conda-forge     Cached
  - liblapack                                  3.9.0  24_linux64_openblas          conda-forge     Cached
  + liblapack                                  3.9.0  16_linux64_mkl               conda-forge     Cached

  Summary:

  Install: 64 packages
  Change: 4 packages

  Total download: 2GB

───────────────────────────────────────────────────────────────────────────────────────────────────────────


Confirm changes: [Y/n] 
torchvision                                          8.3MB @  50.2MB/s  0.2s
torchaudio                                           6.6MB @  29.7MB/s  0.2s
torchtriton                                        244.9MB @  42.3MB/s  5.8s
pytorch                                              1.4GB @  91.8MB/s 15.7s

Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(cellseg) ┌─[yul4024@wulab-precision1] - [~/Documents/downsample_stack] - [213]
└─[$] pip install napari-cellseg3d                                                              [8:07:20]
Collecting napari-cellseg3d
  Using cached napari_cellseg3d-0.2.0-py3-none-any.whl.metadata (10 kB)
(omitted due to github comment length limit)
Installing collected packages: napari-cellseg3d
Successfully installed napari-cellseg3d-0.2.0

Thanks in advance.

longyuxi avatar Oct 01 '24 16:10 longyuxi

I installed CellSeg via pip install -e ., edited the erroneous line

volume = np.reshape(volume, newshape=(1, *volume.shape))

to

volume = np.reshape(volume, (1, *volume.shape))

which should be equivalent to the original code since newshape is also a positional argument. And now I am getting a different error trying to run the inference function:

(cellseg) ┌─[yul4024@wulab-precision1] - [~/Documents/downsample_stack] - [236]
└─[$] napari cellseg_test_stack                                                                 [8:28:25]
/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/pytools/persistent_dict.py:63: RecommendedHashNotFoundWarning: Unable to import recommended hash 'siphash24.siphash13', falling back to 'hashlib.sha256'. Run 'python3 -m pip install siphash24' to install the recommended hash.!
08:28:34 INFO pydensecrf not installed, CRF post-processing will not be available. Please install by running : pip install pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=masterThis is not a hard requirement, you do not need it to install it unless you want to use the CRF post-processing step.
08:28:34 INFO wandb not installed, wandb config will not be taken into account
08:28:36 INFO Starting...
08:28:36 INFO ********************
08:28:36 INFO Worker started at 08:28:36
08:28:36 INFO Saving results to : /home/yul4024/cellseg3d/inference
08:28:36 INFO Worker is running...
08:28:36 INFO MODEL DIMS : 64
08:28:36 INFO Model name : SegResNet
08:28:36 INFO Instantiating model...
08:28:36 INFO ********************
08:28:36 INFO Weight file SegResNet_latest.pth already exists, skipping download
08:28:36 INFO Loading weights...
Numpy version: 1.26.4
08:28:36 INFO Weights status : <All keys matched successfully>
Numpy source: /home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/numpy/__init__.py
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 1024.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 2048.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 4096.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 8192.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 1024.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 2048.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 4096.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 8192.
08:28:36 WARNING Warning : a very large dimension for automatic padding has been computed.
Ensure your images are of an appropriate size and/or that you have enough memory.The padding value is currently 16384.
2024-10-01 08:28:36,724 - INFO - Apply pending transforms - lazy: False, pending: 0, upcoming 'QuantileNormalization', transform is not lazy

=== Transform input info -- QuantileNormalization ===
08:28:36 ERROR 
=== Transform input info -- QuantileNormalization ===
Data statistics:
Type: <class 'dask.array.core.Array'> float32
Value: dask.array<reshape, shape=(1, 7489, 8804, 12), dtype=float32, chunksize=(1, 7489, 8804, 1), chunktype=numpy.ndarray>
08:28:36 INFO Data statistics:
Type: <class 'dask.array.core.Array'> float32
Value: dask.array<reshape, shape=(1, 7489, 8804, 12), dtype=float32, chunksize=(1, 7489, 8804, 1), chunktype=numpy.ndarray>
08:28:36 INFO Done
08:28:36 ERROR applying transform <napari_cellseg3d.code_models.workers_utils.QuantileNormalization object at 0x714353fb7790>
Traceback (most recent call last):
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/monai/transforms/transform.py", line 141, in apply_transform
    return _apply_transform(transform, data, unpack_items, lazy, overrides, log_stats)
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/monai/transforms/transform.py", line 98, in _apply_transform
    return transform(data, lazy=lazy) if isinstance(transform, LazyTrait) else transform(data)
  File "/home/yul4024/Downloads/CellSeg3D/napari_cellseg3d/code_models/workers_utils.py", line 240, in __call__
    return utils.quantile_normalization(img)
  File "/home/yul4024/Downloads/CellSeg3D/napari_cellseg3d/utils.py", line 599, in quantile_normalization
    raise TypeError("image needs to be torch tensor or numpy array")
TypeError: image needs to be torch tensor or numpy array

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/yul4024/Downloads/CellSeg3D/napari_cellseg3d/code_models/worker_inference.py", line 973, in inference
    input_image = self.load_layer()
  File "/home/yul4024/Downloads/CellSeg3D/napari_cellseg3d/code_models/worker_inference.py", line 321, in load_layer
    input_image = load_transforms(volume)
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/monai/transforms/compose.py", line 335, in __call__
    result = execute_compose(
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/monai/transforms/compose.py", line 111, in execute_compose
    data = apply_transform(
  File "/home/yul4024/miniforge3/envs/cellseg/lib/python3.9/site-packages/monai/transforms/transform.py", line 171, in apply_transform
    raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <napari_cellseg3d.code_models.workers_utils.QuantileNormalization object at 0x714353fb7790>
08:28:36 INFO --------------------
08:28:36 INFO Parameters summary :
08:28:36 INFO Model is : SegResNet
08:28:36 INFO Window inference is disabled
08:28:36 INFO Dataset loaded on cuda:0 device
08:28:36 INFO --------------------
08:28:36 INFO Loading layer
08:28:36 INFO Checking dimensions...
08:28:36 INFO 
Worker finished at 08:28:36
08:28:36 INFO ********************
08:28:36 INFO Emptying cache...
08:28:36 INFO Attempt complete : Cache emptied

longyuxi avatar Oct 01 '24 16:10 longyuxi

Hello @longyuxi,

Thanks for trying the plugin !

To me it seems your issues are due to using dask. While it would be a great addition, I'm afraid we do not currently support it in the plugin.

Converting (a crop) of your volume to a numpy array should fix these; depending on what you're trying to segment you could also downsample your images a bit to reduce the memory requirements.

(Just to be thorough, your first error is due to the dask implementation of reshape not having the "newshape" keyword. It's interesting that it is being re-routed to the dask implementation however. Your second error is simply due to the quantile normalization not accepting dask arrays.)

Let me know if you need any further help !

Best,

Cyril

C-Achard avatar Oct 02 '24 16:10 C-Achard

Hello, since this is a week old I will go ahead and close it. Feel free to reopen if you need further help !

C-Achard avatar Oct 09 '24 08:10 C-Achard