Open themolco opened 4 years ago
Same problem here. I think the problem is that gfile was moved to tf.io.gfile in tensorflow 2.0.
Lucid does not support TF 2.0 at present.
Has anyone managed to find any solutions to this error?
I was able to bypass the error with gfile using:
import tensorflow.compat.v1.gfile as gfile
There are also issues with tensorflow.contrib
and am not sure how to fix that yet since it seems more involved.
The Colab notebook linked from the Feature Visualization Distill article also fails now with this error. Easy fix is to add
!pip install tensorflow-gpu==1.15
In Colab you can also use the directive %tensorflow_version 1.x
before importing tensorflow.
I found I needed to completely uninstall Tensorflow, then all worked fine: !pip uninstall tensorflow -y !pip uninstall tensorflow-gpu -y !pip install tensorflow==1.15 !pip install tensorflow-gpu==1.15 !pip install lucid
I also try to get the notebook of this Feature Visualization thing to run, but when I use TensorFlow 1.15.0 to bypass the gfile-problem I get this: kapre 0.3.7 requires TensorFlow>=2.0.0, but you have TensorFlow 1.15.0 which is incompatible. Does anyone have an idea on what to do?
Full stack trace:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
[<ipython-input-3-fc76b967f420>](https://localhost:8080/#) in <module>()
12
13 # General lucid code
---> 14 from lucid.misc.io import save, show, load
15 import lucid.modelzoo.vision_models as models
16
3 frames
[/usr/local/lib/python3.7/dist-packages/lucid/misc/io/__init__.py](https://localhost:8080/#) in <module>()
1 from lucid.misc.io.showing import show
----> 2 from lucid.misc.io.loading import load
3 from lucid.misc.io.saving import save, CaptureSaveContext, batch_save
4 from lucid.misc.io.scoping import io_scope, scope_url
[/usr/local/lib/python3.7/dist-packages/lucid/misc/io/loading.py](https://localhost:8080/#) in <module>()
34 from google.protobuf.message import DecodeError
35
---> 36 from lucid.misc.io.reading import read_handle
37 from lucid.misc.io.scoping import current_io_scopes, set_io_scopes
38 from lucid.misc.io.saving import nullcontext
[/usr/local/lib/python3.7/dist-packages/lucid/misc/io/reading.py](https://localhost:8080/#) in <module>()
32 from filelock import FileLock
33
---> 34 from lucid.misc.io.writing import write_handle
35 from lucid.misc.io.scoping import scope_url
36
[/usr/local/lib/python3.7/dist-packages/lucid/misc/io/writing.py](https://localhost:8080/#) in <module>()
26 from contextlib import contextmanager
27 from urllib.parse import urlparse
---> 28 from tensorflow import gfile
29
30 from lucid.misc.io.scoping import scope_url
ImportError: cannot import name 'gfile' from 'tensorflow' (/usr/local/lib/python3.7/dist-packages/tensorflow/__init__.py)
Also, the title of this issue should probably be updated to "Activation Atlas Google Colab notebook - ImportError: cannot import name 'gfile' from 'tensorflow'" or similar, if @themolco is still around. Thought about making a new issue for better visibility.
Fixed with https://github.com/tensorflow/lucid/issues/201#issuecomment-626165841
I am trying to run the lucid notebook on my machine but it barfs on lucid.modelzoo.vision_models. After a long stream of files it eventually informs me
The file that initiates the call is vision_base.py. I am using the most recent stable versions of tensorflow and lucid.