zl程序教程

您现在的位置是:首页 >  其他

当前栏目

torchserve 接口调用报错TypeError: expected string or bytes-like object

接口 报错 string 调用 or object like TypeError
2023-09-11 14:14:27 时间

return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object
把数据打印出来就知道了,传入的是列表形式的字典,不是直接的字符串

curl -X POST http://localhost:8080/predictions/epidemic_hsy -d “data=牛牛牛牛牛女女”
在这里插入图片描述

data = text_s[0]
input_text = data.get("data")
   if input_text is None:
       input_text = data.get("body")
   if isinstance(input_text, (bytes, bytearray)):
       input_text = input_text.decode('utf-8')