We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这是服务端代码
from paddlenlp import Taskflow, SimpleServer car_schema = ["大众","丰田","别克","奥迪","本田","奔驰","无"] car_utc = Taskflow("zero_shot_text_classification", model="utc-nano", schema=car_schema, precision="fp32") book_schema = ["水浒传","三国演义","西游记","红楼梦","无"] book_utc = Taskflow("zero_shot_text_classification", model="utc-nano", schema=book_schema, precision="fp32") app = SimpleServer() app.register_taskflow("taskflow/car_utc", car_utc) app.register_taskflow("taskflow/book_utc", book_utc)
这是客户端代码
import json from pprint import pprint import requests if __name__ == "__main__": url = "http://127.0.0.1:8990/taskflow/car_utc" headers = {"Content-Type": "application/json"} texts = ["三国志"] data = {"data": {"text": texts}} r = requests.post(url=url, headers=headers, data=json.dumps(data)) datas = json.loads(r.text) pprint(datas) results = [] for item in datas['result']: if len(item['predictions']) > 0: label = item['predictions'][0]['label'] score = item['predictions'][0]['score'] else: label = '' score = 0 results.append({"text":item['text_a'],"label":label,"score":score}) print(results) # [{'text': '三国志', 'label': '三国演义', 'score': 0.9488116450766004}]
问题是:为什么我调用的是car_utc服务,但是预测结果出来的labels是book_schema里面的结果,请问要如何使用,才能使得car_utc对应的是car_schema呢
paddlenlp版本:2.5.2.post
The text was updated successfully, but these errors were encountered:
您好,SimpleServer已经停止更新了,不过SimpleServer是基于fastAPI来写的,您可以直接使用fastAPI,另外,欢迎开发者进行贡献。
Sorry, something went wrong.
wawltor
No branches or pull requests
请提出你的问题
这是服务端代码
这是客户端代码
问题是:为什么我调用的是car_utc服务,但是预测结果出来的labels是book_schema里面的结果,请问要如何使用,才能使得car_utc对应的是car_schema呢
paddlenlp版本:2.5.2.post
The text was updated successfully, but these errors were encountered: