统一模型接口,新增文本分类接口
This commit is contained in:
30
services/paddle_services/clas_orientation.py
Normal file
30
services/paddle_services/clas_orientation.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import logging.config
|
||||
|
||||
from flask import Flask, request
|
||||
from paddleclas import PaddleClas
|
||||
|
||||
from log import LOGGING_CONFIG
|
||||
from utils import process_request
|
||||
|
||||
app = Flask(__name__)
|
||||
CLAS = PaddleClas(model_name='text_image_orientation')
|
||||
|
||||
|
||||
@app.route(rule='/', methods=['POST'])
|
||||
@process_request
|
||||
def main():
|
||||
"""
|
||||
判断图片旋转角度,逆时针旋转该角度后为正。可能值['0', '90', '180', '270']
|
||||
:return: 最有可能的两个角度
|
||||
"""
|
||||
img_path = request.form.get('img_path')
|
||||
clas_result = CLAS.predict(input_data=img_path)
|
||||
clas_result = next(clas_result)[0]
|
||||
if clas_result['scores'][0] < 0.5:
|
||||
return ['0', '90']
|
||||
return clas_result['label_names']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
app.run('0.0.0.0', 5005)
|
||||
Reference in New Issue
Block a user