为什么函数计算调用之后是404?我创建的是一个古文标点的测试函数,这样调用的:curl -X POST -d "婦女終嵗勤勤大半爲此" https://
biaodian-wccehmhlas.cn-hangzhou.fcapp.run
我的函数代码是这样的:
import os
import tempfile
import requests
import torch
from transformers import pipeline
from flask import Flask, request
model_dir = '/usr/src/app/guwen-biaodian'
app = Flask(name)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
pipe = pipeline("token-classification", model=model_dir, device=device)
@app.route('/invoke', methods=['POST'])
def invoke():
request_id = request.headers.get("x-fc-request-id", "")
print("FC Invoke Start RequestId: " + request_id)
text = request.get_data().decode("utf-8")
punctuated_text = pipe(text)
punctuations = [p['entity'] for p in punctuated_text]
punctuation_indices = [p['start'] for p in punctuated_text]
punctuated = "".join(text[i] if i not in punctuation_indices else text[i] + punctuations[punctuation_indices.index(i)] for i in range(len(text)))
print("FC Invoke End RequestId: " + request_id)
return punctuated + "\n"
if name == 'main':
app.run(debug=False, host='0.0.0.0', port=9000)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。