python - Tensorflow 与 contrib 操作一起服务

标签 python tensorflow tensorflow-serving

如何使用 tensorflow-serving 提供模型,如果有 tf.contrib 操作。我通过 Docker 使用 Tensorflow Serving(最新)(tf 1.11 版本),当我提供模型时,出现下一条消息:

“Failed to start server. Error: Unknown: 1 servable(s) did not become available: {{{name: slider_universal version: 1} due to error: Not found: Op type not registered ‘ImageProjectiveTransformV2’ in binary running on 254345a5d9f1. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) tf.contrib.resampler should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.}, }”

我也用bazel构建但有同样的错误

我使用tf.contrib.image.transform

如果我在导出模型期间删除此操作,它可以由tensorflow服务提供服务

最佳答案

我在使用相同的操作时遇到了问题,似乎唯一的方法就是构建它。

tensorflow_serving/model_servers/BUILD 定义了哪些 Tensorflow 操作将包含在变量 SUPPORTED_TENSORFLOW_OPS 中,我对此有点困惑,因为它指定应包含 contrib 操作。但是,由于tensorflow contrib构建规则似乎不包含contrib.image下的操作,因此我通过将此变量更新为以下内容来显式添加这些操作

SUPPORTED_TENSORFLOW_OPS = [
    "@org_tensorflow//tensorflow/contrib:contrib_kernels",
    "@org_tensorflow//tensorflow/contrib:contrib_ops_op_lib",
    "@org_tensorflow//tensorflow/contrib/image:image_ops_kernels",
    "@org_tensorflow//tensorflow/contrib/image:image_ops_op_lib",
]

关于python - Tensorflow 与 contrib 操作一起服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53284674/

相关文章:

python - Tensorflow 服务类型 : Object is not of expected type: uint8

Tensorflow 服务 - 有状态 LSTM

node.js - Tensorflow 服务 grpc 客户端错误 12

python - 如何在 Django REST 框架中使用事务?

python - Pycharm:无法导入 lightfm

python - 根据相同的值但不同的键名称连接两个 Python 字典(如 SQL 的 JOIN)

tensorflow - 验证准确性高于使用 Tensorflow 和 Keras 的训练准确性

python - tf.random.Normal() 不生成不同的值

python - 无法安装 TensorFlow Python 依赖项

machine-learning - 如何将tensorflow的word2vec保存在文本/二进制文件中以供以后使用kNN输出?