zadosaadi purwanto
zadosaadi purwanto

Reputation: 35

tensorflow TypeError: ParseFromString() missing 1 required positional argument: 'serialized'

this is my first time using tensor flow i want to try captcha solver i found in the internet but i got an error the link the tutorial https://pylessons.com/TensorFlow-CAPTCHA-final-detection/

TypeError: ParseFromString() missing 1 required positional argument: 'serialized'

here is my code

# Load a (frozen) Tensorflow model into memory.
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = label_map_util.create_category_index(categories)

detection_graph = tf.Graph()
with detection_graph.as_default():
    od_graph_def = tf.GraphDef
    with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
        serialized_graph = fid.read()
        od_graph_def.ParseFromString(serialized_graph)
        tf.import_graph_def(od_graph_def, name='')

Upvotes: 3

Views: 1357

Answers (1)

Pratik Goyal
Pratik Goyal

Reputation: 68

If you are using tensorflow version >= 2.0 then above code won't work. Below is the updated code which will work on tensorflow version > 2.0

 with detection_graph.as_default():
        od_graph_def = tf.compat.v1.GraphDef()
        with tf.compat.v1.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
            serialized_graph = fid.read()
            od_graph_def.ParseFromString(serialized_graph)
            tf.compat.v1.import_graph_def(od_graph_def, name='')

Upvotes: 2

Related Questions