kreshuklab / plant-seg

A tool for cell instance aware segmentation in densely packed 3D volumetric images
https://kreshuklab.github.io/plant-seg/
MIT License
89 stars 30 forks source link

Error reading and writing tiff in plantseg environment #243

Closed Buglakova closed 1 month ago

Buglakova commented 2 months ago

Hello,

I installed the newest plantseg (1.7.1) in a fresh environment according to the installation instructions from the README. When I run the pipeline from the config and want to output tiff, it gives me the error:

ValueError: <COMPRESSION.ADOBE_DEFLATE: 8> requires the 'imagecodecs' package

Same error if I try to save a layer from napari using napari's standard save layer functionality. Running conda install imagecodecs didn't help. I ended up removing conda's imagecodecs and doing pip install imagecodecs like written here. Does napari/plantseg require some very specific version of imagecodecs?

It's very confusing and I think imagecodecs should be part of the default environment, since reading and writing tiff is a very basic functionality.

lorenzocerrone commented 1 month ago

As you have also experienced, there is some weird issue with installing imagecodecs via conda. That's the reason why it's not in the default envs. Plantseg does not use imagecodecs directly, but tifffile does, and for them, it is an optional dependency. To be honest, I am not sure how to fix this. Have you checked if the conda version of imagecodecs differs from the one installed using pip?

cgohlke commented 1 month ago

ValueError: <COMPRESSION.ADOBE_DEFLATE: 8> requires the 'imagecodecs' package

This happens if imagecodecs < 2023.3.16 is used with recent versions of tifffile. Try to either remove imagecodecs (deflate compression works without imagecodecs) or upgrade imagecodecs.

lorenzocerrone commented 1 month ago

Hey @cgohlke, thanks for the clarification!

I have investigated the issue. The problem is related to the channel priority.

If I try to install imagecodecs=2024** with our current channel priority (pytorch>nvidia>conda-forge, assuming mamba), we get the following error:

$mamba create -n test imagecodecs=2024 -c pytorch -c nvidia
...
Could not solve for environment specs
The following package could not be installed
└─ imagecodecs 2024**  is not installable because it requires
   └─ libjpeg-turbo >=3.0.0,<4.0a0 , which conflicts with any installable versions previously reported.

That explains why pip can install the latest version; it just ignores the conda-channels! This can be fixed just by ignoring the channel priority --no-channel-priority

@Buglakova For now, the easiest fix would be to install plantseg using the following:

$mamba create -n plant-seg-t -c pytorch -c nvidia -c conda-forge pytorch pytorch-cuda=12.1 pyqt plant-seg --no-channel-priority 

I will change this in the documentation.