Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Module 'tensorflow' has no attribute 'gfile' error while running tensorflow object detection api tutorial

I am trying to use the object detection tutorial from tensor flow api. I am using python 3 and tensor flow version 2. But getting the below error.I tried several ways:

File "C:\Aniruddhya\object_detection\object_detection\utils\label_map_util.py", line 137, in load_labelmap
    with tf.gfile.GFile(path, 'r') as fid:

AttributeError: module 'tensorflow' has no attribute 'gfile'

can someone help me to run this? code link: https://drive.google.com/drive/u/3/folders/1XHpnr5rsENzOOSzoWNTvRqhEbLKXaenL

like image 797
Andy Avatar asked Oct 13 '19 11:10

Andy


2 Answers

It's not called that in TensorFlow 2. You might be using a TensorFlow 1 tutorial.

Version 1 tf.gfile.GFile https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/io/gfile/GFile

Version 2 tf.io.gfile.GFile https://www.tensorflow.org/api_docs/python/tf/io/gfile/GFile

like image 60
user1318499 Avatar answered Oct 01 '22 01:10

user1318499


If you have Tensorflow version 2. You can use the next module compatible with the version 1, too.

import tensorflow.compat.v1 as tf
like image 38
Yerry Aguirre Avatar answered Oct 01 '22 03:10

Yerry Aguirre