Doodleverse / segmentation_zoo

A collection of geoscientific image segmentation models
MIT License
8 stars 3 forks source link

Error importing doodleverse_utils.prediction_imports #35

Closed WHBSpeiser closed 1 year ago

WHBSpeiser commented 1 year ago

Hello! I just did a fresh install of segmentation_zoo and am running on Pop!_OS 22.04 (aka Ubuntu). When trying to use the SDSmodels notebook, I run into an error when trying to import seg_file2tensor_3band, seg_file2tensor_ND from `doodleverse_utils.prediction_imports. I successfully downloaded all of the supporting libraries and the notebook was working before the fresh install. It looks like the error is from scripy. I tried redownloading scipy which didn't fix the error.

Below is the code and the error:

Running:

from doodleverse_utils.prediction_imports import seg_file2tensor_3band, seg_file2tensor_ND yields:

--------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 8
      5 from glob import glob
      6 from tqdm import tqdm
----> 8 from doodleverse_utils.prediction_imports import seg_file2tensor_3band, seg_file2tensor_ND
     10 def download_url(url, save_path, chunk_size=128):
     11     r = requests.get(url, stream=True)

File ~/anaconda3/envs/zoo/lib/python3.9/site-packages/doodleverse_utils/prediction_imports.py:39
     37 from numpy.lib.stride_tricks import as_strided as ast
     38 from glob import glob
---> 39 from skimage.transform import resize
     40 from skimage.filters import threshold_otsu
     41 import matplotlib.pyplot as plt

File ~/anaconda3/envs/zoo/lib/python3.9/site-packages/skimage/transform/__init__.py:4
      1 from .hough_transform import (hough_line, hough_line_peaks,
      2                               probabilistic_hough_line, hough_circle,
      3                               hough_circle_peaks, hough_ellipse)
----> 4 from .radon_transform import (radon, iradon, iradon_sart,
      5                               order_angles_golden_ratio)
      6 from .finite_radon_transform import frt2, ifrt2
      7 from .integral import integral_image, integrate

File ~/anaconda3/envs/zoo/lib/python3.9/site-packages/skimage/transform/radon_transform.py:5
      3 from scipy.interpolate import interp1d
      4 from scipy.constants import golden_ratio
----> 5 from scipy.fft import fft, ifft, fftfreq, fftshift
      6 from ._warps import warp
      7 from ._radon_transform import sart_projection_update

File ~/anaconda3/envs/zoo/lib/python3.9/site-packages/scipy/fft/__init__.py:91
     89 from ._realtransforms import dct, idct, dst, idst, dctn, idctn, dstn, idstn
     90 from ._fftlog import fht, ifht, fhtoffset
---> 91 from ._helper import next_fast_len
     92 from ._backend import (set_backend, skip_backend, set_global_backend,
     93                        register_backend)
     94 from numpy.fft import fftfreq, rfftfreq, fftshift, ifftshift

File ~/anaconda3/envs/zoo/lib/python3.9/site-packages/scipy/fft/_helper.py:3
      1 from functools import update_wrapper, lru_cache
----> 3 from ._pocketfft import helper as _helper
      6 def next_fast_len(target, real=False):
      7     """Find the next fast size of input data to ``fft``, for zero-padding, etc.
      8 
      9     SciPy's FFT algorithms gain their speed by a recursive divide and conquer
   (...)
     59 
     60     """

File ~/anaconda3/envs/zoo/lib/python3.9/site-packages/scipy/fft/_pocketfft/__init__.py:3
      1 """ FFT backend using pypocketfft """
----> 3 from .basic import *
      4 from .realtransforms import *
      5 from .helper import *

File ~/anaconda3/envs/zoo/lib/python3.9/site-packages/scipy/fft/_pocketfft/basic.py:6
      4 import numpy as np
      5 import functools
----> 6 from . import pypocketfft as pfft
      7 from .helper import (_asfarray, _init_nd_shape_and_axes, _datacopied,
      8                      _fix_shape, _fix_shape_1d, _normalization,
      9                      _workers)
     11 def c2c(forward, x, n=None, axis=-1, norm=None, overwrite_x=False,
     12         workers=None, *, plan=None):

ImportError: /home/williamcoast/anaconda3/envs/zoo/lib/python3.9/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/williamcoast/anaconda3/envs/zoo/lib/python3.9/site-packages/scipy/fft/_pocketfft/pypocketfft.cpython-39-x86_64-linux-gnu.so)
ebgoldstein commented 1 year ago

I have never seen that type of meesage before... but can you try this and report back:

conda install -c conda-forge libstdcxx-ng=12

via: https://stackoverflow.com/questions/72540359/glibcxx-3-4-30-not-found-for-librosa-in-conda-virtual-environment-after-tryin/74533050#74533050

WHBSpeiser commented 1 year ago

Tried the suggested a couple of times and each time it made it so the environment could no longer run jupyter notebook. I also tried updating the system's C++ but didn't work (sudo apt-get upgrade libstdc++6) ... I will try running the notebook on a different OS later.

ebgoldstein commented 1 year ago

arg - too bad.. let us know if it works on a different OS...

WHBSpeiser commented 1 year ago

Hey, sorry it took me a while to get back around to this. I got it to run on windows, but had to retry it a couple of times. It seems like the way the zoo install instructions are ordered on the github page, there is a dependency issue between the numpy version downloaded initially and what tensorflow prefers: ```

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
scipy 1.8.1 requires numpy<1.25.0,>=1.17.3, but you have numpy 1.26.0 which is incompatible.
Successfully installed absl-py-2.0.0 aiohttp-3.8.6 aiosignal-1.3.1 astunparse-1.6.3 async-timeout-4.0.3 cachetools-5.3.1 doodleverse_utils-0.0.29 flatbuffers-23.5.26 frozenlist-1.4.0 gast-0.5.4 google-auth-2.23.3 google-auth-oauthlib-1.0.0 google-pasta-0.2.0 grpcio-1.59.0 h5py-3.10.0 ipyfilechooser-0.6.0 ipywidgets-8.1.1 jupyterlab-widgets-3.0.9 keras-2.14.0 libclang-16.0.6 markdown-3.5 ml-dtypes-0.2.0 multidict-6.0.4 numpy-1.26.0 oauthlib-3.2.2 opt-einsum-3.3.0 protobuf-4.24.4 pyasn1-0.5.0 pyasn1-modules-0.3.0 requests-oauthlib-1.3.1 rsa-4.9 tensorboard-2.14.1 tensorboard-data-server-0.7.1 tensorflow-2.14.0 tensorflow-estimator-2.14.0 tensorflow-intel-2.14.0 tensorflow-io-gcs-filesystem-0.31.0 termcolor-2.3.0 versioneer-0.29 werkzeug-3.0.0 widgetsnbextension-4.0.9 wrapt-1.14.1 yarl-1.9.2

I was able to get it to properly download by installing tensorflow first and then the remaining packages not associated with tensorflow. I'll try doing this on Ubuntu as well and see if it fixes the overall issue.

WHBSpeiser commented 1 year ago

Yep! Installing tensorflow before all other packages fixed both the numpy dependency issue on windows and the error that I received on pop/ubuntu. Weird!

ebgoldstein commented 1 year ago

Very good info- @WHBSpeiser , do you want to give close this issue? Or make a PR on the readme/wiki to explain?

dbuscombe-usgs commented 1 year ago

Thanks @WHBSpeiser for figuring this out