4

I am trying to call a function from tensorflow to decode a tiff image, while i am running the notebook on kaggle notebooks and in this line:

img = tfio.experimental.image.decode_tiff(img, channels=1)

It gives me the error:

AttributeError: in user code:

<ipython-input-5-d30698f56813>:11 load  *
    img = tfio.experimental.image.decode_tiff(img, channels=1)

AttributeError: module 'tensorflow.io' has no attribute 'experimental'

I'm currently importing tensorflow.io like this:

import tensorflow.io as tfio

And my current version of: print(f"Tensorflow ver. {tf.__version__}") is

Tensorflow ver. 2.3.0

1 Answer 1

5

Tensorflow I/O does not come with Tensorflow, and it must be installed separately via pip; from the repo (emphasis mine):

TensorFlow I/O is a collection of file systems and file formats that are not available in TensorFlow's built-in support.

Moreover, it is not imported like that.

What you should do is install it via pip:

!pip install tensorflow-io

and verify that you get the latest version v0.15.0, as it is currently the only one compatible with TF 2.3 (source):

import tensorflow_io as tfio
tfio.__version__
# 0.15.0

Notice the different import - tensorflow_io, not tensorflow.io; this is demonstrated also in the simple usage examples in Github.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep. I got error "AttributeError: module 'tensorflow' has no attribute 'io'" at "tensorboard\summary\writer\event_file_writer.py", line 72, in __init__ tf.io.gfile.makedirs(logdir)". The installation of tensorflow-io fixed the error. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.