48 Star 458 Fork 161

PaddlePaddle / PaddleHub

 / 详情

win10 在线lac分词服务demo 验证报错

已完成
创建于  
2021-09-28 15:04

源自github用户liuzengzhen1:

-版本、环境信息
1)PaddleHub和PaddlePaddle版本:PaddleHub1.6.1,PaddlePaddle1.7.0
2)系统环境:win10,python版本 3.7.4

  • 复现信息:如为报错,请给出复现环境、复现步骤
    参考文档:Demo——部署一个在线lac分词服务步骤,最后客户端python调用报错,提示如下,我点开链接跟我粘的代码一样啊
    `# coding: utf8
    import requests
    import json

if name == "main":
# 指定用于用于预测的文本并生成字典{"text": [text_1, text_2, ... ]}
text_list = ["今天是个好日子", "天气预报说今天要下雨"]
text = {"text": text_list}
# 指定预测方法为lac并发送post请求
url = "http://127.0.0.1:8866/predict/text/lac"
r = requests.post(url=url, data=text)

# 打印预测结果
print(json.dumps(r.json(), indent=4, ensure_ascii=False))`

提示如下 { "msg": "This usage is out of date, please use 'application/json' as content-type to post to /predict/lac. See 'https://github.com/PaddlePaddle/PaddleHub/blob/release/v1.6/docs/tutorial/serving.md' for more details.", "results": "", "status": "-1" }
图片

评论 (3)

PaddlePaddle-Gardener 创建了任务
展开全部操作日志

源自github用户ShenYuhan:
您使用的lac模型版本是多少呢?如果是2.1.0的话,客户端请求的方式应该是

    data = {"texts": text}
    # 指定预测方法为lac并发送post请求
    url = "http://127.0.0.1:8866/predict/lac"
    # 指定post请求的headers为application/json方式
    headers = {"Content-Type": "application/json"}

    r = requests.post(url=url, headers=headers, data=json.dumps(data))

您可以看下文档的说明: https://github.com/PaddlePaddle/PaddleHub/blob/release/v1.6/docs/tutorial/serving.md#%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%AF%B7%E6%B1%82%E6%96%B0%E7%89%88%E6%A8%A1%E5%9E%8B%E7%9A%84%E6%96%B9%E5%BC%8F

源自github用户liuzengzhen1:
@神雨涵 已解决哈,非常感谢,根据最新的文档已经可以访问了

源自github用户haoyuying:
Since you haven't replied for more than 3 months, we have closed this issue/pr.
If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up.
由于您超过三个月未回复,我们将关闭这个issue/pr。
若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。

PaddlePaddle-Coordinator 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
Python
1
https://gitee.com/paddlepaddle/PaddleHub.git
git@gitee.com:paddlepaddle/PaddleHub.git
paddlepaddle
PaddleHub
PaddleHub

搜索帮助