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

ImportError: cannot import name 'keras_export' #30

Open
atinesh-s opened this issue Dec 14, 2020 · 7 comments · May be fixed by #32
Open

ImportError: cannot import name 'keras_export' #30

atinesh-s opened this issue Dec 14, 2020 · 7 comments · May be fixed by #32

Comments

@atinesh-s
Copy link

atinesh-s commented Dec 14, 2020

I am trying to run this notebook, but I am getting below error at this line from models import FaceTranslationGANInferenceModel

Using TensorFlow backend.
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-13-e0f766e65a9c> in <module>()
----> 1 from models import FaceTranslationGANInferenceModel

13 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/initializers/initializers_v1.py in <module>()
     21 from tensorflow.python.framework import dtypes
     22 from tensorflow.python.ops import init_ops
---> 23 from tensorflow.python.util.tf_export import keras_export
     24 
     25 keras_export(v1=['keras.initializers.Zeros', 'keras.initializers.zeros'])(

ImportError: cannot import name 'keras_export'

Libraries: tensorflow-gpu==1.13.1, keras==2.2.4

@amrzv
Copy link

amrzv commented Jan 7, 2021

I tried with pip install keras==2.2.4 tensorflow==1.13.1 and it works well.

@amrzv amrzv linked a pull request Jan 8, 2021 that will close this issue
@atinesh-s
Copy link
Author

atinesh-s commented Jan 9, 2021

I tried with pip install keras==2.2.4 tensorflow==1.13.1 and it works well.

Are you sure you able to run whole code successfully. I am getting below error with tensorflow==1.13.1 (CPU)

Building FAN for landmarks detection...
WARNING:tensorflow:No training configuration found in save file: the model was *not* compiled. Compile it manually.
Done.
---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-19-a57db805edd7> in <module>()
----> 1 src, mask, aligned_im, (x0, y0, x1, y1), landmarks = utils.get_src_inputs(fn_src, fd, fp, idet)
      2 tar, emb_tar = utils.get_tar_inputs(fns_tar, fd, fv)

10 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
    526             None, None,
    527             compat.as_text(c_api.TF_Message(self.status.status)),
--> 528             c_api.TF_GetCode(self.status.status))
    529     # Delete the underlying status object from memory otherwise it stays alive
    530     # as there is a reference to status from this from the traceback due to

InvalidArgumentError: Default AvgPoolingOp only supports NHWC on device type CPU
	 [[{{node 0.3562700616991372/AvgPool}}]]

Here is the notebook I am using

@amrzv
Copy link

amrzv commented Jan 9, 2021

@atinesh-s Yes, my bad, now I'm getting same error.
Try intel-tensorflow==1.15.2, now it should work.

@atinesh-s
Copy link
Author

atinesh-s commented Jan 12, 2021

@atinesh-s Yes, my bad, now I'm getting same error.
Try intel-tensorflow==1.15.2, now it should work.

@amrzv Thanks, it solved the problem but it runs very slow on the CPU.

It's strange why on colab I was getting the error with tensorflow-gpu==1.13.1, keras==2.2.4 though code runs fine on cloud machine with the same libraries

@ibtehajali67
Copy link

I solve this issue by using these command
pip uninstall -y tensorflow
pip install tensorflow-gpu==1.13.1

@molo32
Copy link

molo32 commented Jun 13, 2021

now throw this

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:526: 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:527: 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:528: 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:529: 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:530: 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:535: 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)])
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-e0f766e65a9c> in <module>()
----> 1 from models import FaceTranslationGANInferenceModel

3 frames
/usr/local/lib/python3.7/dist-packages/keras/distribute/sidecar_evaluator.py in <module>()
     16 """Python module for evaluation loop."""
     17 
---> 18 import tensorflow.compat.v2 as tf
     19 
     20 import re

ModuleNotFoundError: No module named 'tensorflow.compat.v2'

---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------

@amrzv
Copy link

amrzv commented Jul 4, 2021

now throw this

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:526: 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:527: 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:528: 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:529: 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:530: 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:535: 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)])
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-e0f766e65a9c> in <module>()
----> 1 from models import FaceTranslationGANInferenceModel

3 frames
/usr/local/lib/python3.7/dist-packages/keras/distribute/sidecar_evaluator.py in <module>()
     16 """Python module for evaluation loop."""
     17 
---> 18 import tensorflow.compat.v2 as tf
     19 
     20 import re

ModuleNotFoundError: No module named 'tensorflow.compat.v2'

---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------

Try this #32 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants