项目架构调整,模型全部采用接口调用

This commit is contained in:
2024-09-25 14:46:37 +08:00
parent 7647df7d74
commit b8c1202957
25 changed files with 467 additions and 222 deletions

26
services/clas_api.py Normal file
View File

@@ -0,0 +1,26 @@
from flask import Flask, request
from paddleclas import PaddleClas
from utils import process_request
app = Flask(__name__)
CLAS = PaddleClas(model_name='text_image_orientation')
@app.route('/clas/orientation', methods=['POST'])
@process_request
def orientation():
"""
判断图片旋转角度,逆时针旋转该角度后为正。可能值['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__':
app.run('0.0.0.0', 5005)