我在 Google Colab 上使用 tensorflow 2.0 训练了一个简单的mnist模型,并将其保存为 .json 格式。 Click here来查看我在其中编写代码的Colab Notebook。然后在运行命令
!simple_tensorflow_serving --model_base_path="/" --model_platform="tensorflow"
它显示错误AttributeError:模块'tensorflow'没有属性'gfile'
simple_tensorflow_serving有助于轻松地将训练有素的张量流模型部署到生产中。
版本我正在使用:
(1)TensorFlow-2.0
(2)simple_tensorflow_serving-0.6.4
预先感谢您:)
答案 0 :(得分:4)
在2.0中,tf.gfile。*替换为tf.io.gfile。*。
出现错误时:
File "/Users/MRJ/anaconda3/envs/python37-tf2.1/lib/python3.7/
site-packages/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'
1。找到label_map_util.py
第137行。
2。将tf.gfile.GFile
替换为tf.io.gfile.GFile
对我有用。
答案 1 :(得分:3)
由于Tensorflow 2.0使用的是旧版API,因此尚未准备就绪。
在Tensorflow 2.0中,gfile
软件包已移至tf.io
。
然后,您必须使用简单Tensorflow服务将Tensorflow实例降级为TF 1.13