Skip to main content
 首页 » 编程设计

python之Tensorflow 服务客户端/Base64 问题/错误 3

2024年10月01日28over140

我想在 Tensorflow Serving 上启动并运行以下模型:

https://github.com/mdietrichstein/tensorflow-open_nsfw

我使用以下代码导出了模型:https://github.com/mdietrichstein/tensorflow-open_nsfw/blob/master/tools/export_model.py

但在尝试使用 node.js 客户端计算结果时出现以下错误:

{ code: 3,  
  details: 'Invalid character found in base64.\n\t  
  [[Node: map/while/DecodeBase64 = DecodeBase64[_output_shapes=[[]], 
  _device="/job:localhost/replica:0/task:0/cpu:0"](map/while/TensorArrayReadV3)]]', 
  metadata: Metadata { 
   _ internal_repr: {} 
  } 
} 

我的客户端配置了测试服务器地址的代码可以在这里找到:

https://github.com/delta9/tensorflow-serving-node-client

有没有人遇到过类似的问题,如果遇到过,你们是怎么解决的?

非常感谢

请您参考如下方法:

您应该使用网络安全的 base64 编码。 base64.urlsafe_b64encode(open('test.jpg', 'rb').read()) 因为tensorflow.decode_base64使用WEB-SAFE模型解码base64编码。 tensorflow.decode_base64 的官方文档是:

解码网络安全的 base64 编码字符串。 输入末尾可能有也可能没有填充。有关填充,请参阅 EncodeBase64。 Web 安全意味着输入必须使用 - 和 _ 而不是 + 和/。