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

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

28
services/det_api.py Normal file
View File

@@ -0,0 +1,28 @@
import os.path
import cv2
from flask import Flask, request
from paddle_services.paddle_detection import detector
from utils import process_request, parse_img_path
app = Flask(__name__)
@app.route('/det/books', methods=['POST'])
@process_request
def books():
img_path = request.form.get('img_path')
result = detector.get_book_areas(img_path)
dirname, img_name, ext = parse_img_path(img_path)
books_path = []
for i in range(len(result)):
save_path = os.path.join(dirname, img_name + '_book_' + str(i) + '.' + ext)
cv2.imwrite(save_path, result[i])
books_path.append(save_path)
return books_path
if __name__ == '__main__':
app.run('0.0.0.0', 5006)