diff --git a/utils/label_map_util.py b/utils/label_map_util.py index 709c86a..c10e12d 100644 --- a/utils/label_map_util.py +++ b/utils/label_map_util.py @@ -113,7 +113,7 @@ def load_labelmap(path): Returns: a StringIntLabelMapProto """ - with tf.gfile.GFile(path, 'r') as fid: + with tf.compat.v2.io.gfile.GFile(path, 'r') as fid: label_map_string = fid.read() label_map = string_int_label_map_pb2.StringIntLabelMap() try: diff --git a/vehicle_detection_main.py b/vehicle_detection_main.py index ffa86ea..4cb55ad 100644 --- a/vehicle_detection_main.py +++ b/vehicle_detection_main.py @@ -66,8 +66,8 @@ # Load a (frozen) Tensorflow model into memory. detection_graph = tf.Graph() with detection_graph.as_default(): - od_graph_def = tf.GraphDef() - with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: + od_graph_def = tf.compat.v1.GraphDef() + with tf.compat.v2.io.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') @@ -95,7 +95,7 @@ def object_detection_function(): size = 'waiting...' color = 'waiting...' with detection_graph.as_default(): - with tf.Session(graph=detection_graph) as sess: + with tf.compat.v1.Session(graph=detection_graph) as sess: # Definite input and output Tensors for detection_graph image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')