tensorflow - tensorflow TypeError:ParseFromString() 缺少 1 个必需的位置参数:“序列化”
问题描述
这是我第一次使用张量流我想尝试我在互联网上找到的验证码求解器但我收到了一个错误链接教程https://pylessons.com/TensorFlow-CAPTCHA-final-detection/
TypeError:ParseFromString() 缺少 1 个必需的位置参数:“序列化”
这是我的代码
# 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='')
解决方案
如果您使用的是 tensorflow 版本 >= 2.0,那么上面的代码将不起作用。以下是适用于 tensorflow 版本 > 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='')
推荐阅读
- android - SparseArray 错误:调用需要 API 级别 S
- java - JacksonNode迭代器,获取键值
- node.js - Mongoose EJS SubCategory - 如何查看嵌套类别
- reactjs - 下一个图像组件不加载图像
- python - 刷新页面并在未找到时再次尝试 find_element 的简单条件
- templates - 错误:无法识别“apps.yml”:没有匹配 /,Kind=Template
- systemtap - polkit-0.115-11.el8.x86_64 的调试信息
- mysql - Model::Create() 方法没有插入 InnoDB 存储引擎
- java - 无法使用 Scala/Java 中的模式从日期创建时间戳
- javascript - 流量{| 定义类型的语法