Noise 2 void update?

Hello, It seems that the noise 2 void package has some dependency issue because I tried to run this minimal example code on Colab and it does not work:

!pip install n2v 
!pip install tensorflow-gpu==1.14 keras==2.2.4
from n2v.models import N2V

It throws an error:

ImportError: cannot import name 'keras_export' from 'tensorflow.python.util.tf_export' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/tf_export.py)

Any ideas on how to resolve the dependencies for this? @fjug @akrull @uschmidt83 @mweigert

Hi,

This is a Google Colab specific issue. Since Colab upgraded to TF 2.5, keras nightly are also installed in Google Colab.

Here keras is causing the issue, even though you install a specific version.

I suggest:

!pip uninstall -y keras-nightly

!pip3 install h5py==2.10.0

!pip install n2v

!pip install q keras==2.2.5

You then need to restart your session. Then N2V will run in Colab.
Feel free to check our ZeroCostDL4mic notebook if that’s useful.

Cheers

Guillaume

1 Like

Thanks @Guillaume_Jacquemet, I ran into problem even with an import tensorflow now, un related to noise2void package, with just these code lines:

from google.colab import drive
drive.mount('/content/drive', force_remount = True)
%tensorflow_version 1.x
import tensorflow as tf

I get the error message:

Mounted at /content/drive
TensorFlow 1.x selected.
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-4d71835971ad> in <module>()
      2 drive.mount('/content/drive', force_remount = True)
      3 get_ipython().magic('tensorflow_version 1.x')
----> 4 import tensorflow as tf

8 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/saving/__init__.py in <module>()
     31 from tensorflow.python.keras.saving.save import load_model
     32 from tensorflow.python.keras.saving.save import save_model
---> 33 from tensorflow.python.keras.saving.saved_model import export_saved_model
     34 from tensorflow.python.keras.saving.saved_model import load_from_saved_model
     35 from tensorflow.python.keras.saving.saving_utils import trace_model_call

ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/saving/saved_model/__init__.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
-------------------------------------------------------

Strange :slight_smile:

Did you restart your session after installing the new dependencies?

Still works in our notebook at least

I did, I will test more to see whats wrong on my side. But should we not just upgrade n2v n release a more compatible version?

Are you using python3.7?

Yes, we use the python version already installed in Google Colab.

If it helps, here is the full installation cell we use

%tensorflow_version 1.x
import tensorflow

!pip uninstall -y keras-nightly

!pip3 install h5py==2.10.0

!pip install n2v
!pip install wget
!pip install fpdf
!pip install memory_profiler

!pip install q keras==2.2.5

#Force session restart
exit(0)

1 Like

Yeah this worked, I just had to shut the session and then not run this cell but this is not a long term fix though, is a n2v update coming out in the next few days?