Reputation: 97
I am having a problem as i upload my model in drive and mount it in Colab module imports are working fine in previous cell as i gave the root path and sys.append() it , I am using (tf.compat.v1) you can see it in ouptut, but still getting this error also tried (tensorflow v2) and used tf.io.gfile but still same error. Kindly help me
<module 'tensorflow_core.compat.v1.version' from '/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v2/compat/v1/version/__init__.py'>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-e851eb463895> in <module>()
1 print(tf.version)
----> 2 category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)
2 frames
/content/drive/My Drive/models/research/object_detection/utils/label_map_util.py in load_labelmap(path)
136 a StringIntLabelMapProto
137 """
--> 138 with tf.gfile.GFile(path, 'r') as fid:
139 label_map_string = fid.read()
140 label_map = string_int_label_map_pb2.StringIntLabelMap()
AttributeError: module 'tensorflow' has no attribute 'gfile'
Upvotes: 1
Views: 2413
Reputation:
Try to downgrade TF 1.15
from TF 2.x
, your issue will be resolved.
Please refer code as shown below
!pip uninstall tensorflow
!pip install tensorflow==1.15
import tensorflow as tf
If you are looking for simple solution for Colab, please use %tensorflow_version 1.x
magic command, which does for you without un-installation.
%tensorflow_version 1.x
import tensorflow as tf
Upvotes: 1