统一模型接口,新增文本分类接口
This commit is contained in:
31
services/paddle_services/det_book.py
Normal file
31
services/paddle_services/det_book.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import logging.config
|
||||
import os.path
|
||||
|
||||
import cv2
|
||||
from flask import Flask, request
|
||||
|
||||
from log import LOGGING_CONFIG
|
||||
from paddle_detection import detector
|
||||
from utils import process_request, parse_img_path
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
@process_request
|
||||
def main():
|
||||
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__':
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
app.run('0.0.0.0', 5006)
|
||||
Reference in New Issue
Block a user