文本分类增加判空
This commit is contained in:
@@ -9,7 +9,7 @@ from utils import process_request
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
schema = ['基本医保结算单', '出院记录', '费用清单']
|
schema = ['基本医保结算单', '出院记录', '费用清单']
|
||||||
CLAS = Taskflow('zero_shot_text_classification', model='utc-xbase', schema=schema,
|
CLAS = Taskflow('zero_shot_text_classification', model='utc-xbase', schema=schema,
|
||||||
task_path='model/text_classification', precision='fp32')
|
task_path='model/text_classification', precision='fp16')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/', methods=['POST'])
|
@app.route('/', methods=['POST'])
|
||||||
@@ -17,6 +17,8 @@ CLAS = Taskflow('zero_shot_text_classification', model='utc-xbase', schema=schem
|
|||||||
def main():
|
def main():
|
||||||
text = request.form.get('text')
|
text = request.form.get('text')
|
||||||
cls_result = CLAS(text)
|
cls_result = CLAS(text)
|
||||||
|
if not cls_result:
|
||||||
|
return None
|
||||||
cls_result = cls_result[0].get('predictions')[0]
|
cls_result = cls_result[0].get('predictions')[0]
|
||||||
if cls_result['score'] < 0.8:
|
if cls_result['score'] < 0.8:
|
||||||
logging.info(f"识别结果置信度{cls_result['score']}过低!text: {text}")
|
logging.info(f"识别结果置信度{cls_result['score']}过低!text: {text}")
|
||||||
|
|||||||
Reference in New Issue
Block a user