项目架构调整,模型全部采用接口调用
This commit is contained in:
28
services/det_api.py
Normal file
28
services/det_api.py
Normal 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)
|
||||
Reference in New Issue
Block a user