hytos / DTI_PID / WebServer / app.py @ 4d2aa82f
이력 | 보기 | 이력해설 | 다운로드 (878 Bytes)
1 |
from flask import Flask, jsonify, request |
---|---|
2 |
import cv2 |
3 |
import numpy as np |
4 |
import sys, os |
5 |
|
6 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\CRAFT_pytorch_master') |
7 |
#sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\deep_text_recognition_benchmark_master')
|
8 |
|
9 |
app = Flask(__name__) |
10 |
|
11 |
@app.route('/') |
12 |
def index(): |
13 |
return 'Hello Flask' |
14 |
|
15 |
@app.route('/text_box', methods=['POST']) |
16 |
def text_box(): |
17 |
import text_craft |
18 |
|
19 |
r = request |
20 |
nparr = np.fromstring(r.data, np.uint8) |
21 |
|
22 |
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR) |
23 |
#img = img.reshape(1, -1)
|
24 |
|
25 |
boxes = text_craft.get_text_box(img, img_path=None, score_path=None, trained_model=os.path.dirname(os.path.realpath(__file__)) + '\\CRAFT_pytorch_master\\weights\\craft_mlt_25k.pth') |
26 |
|
27 |
return jsonify({'text_box': boxes}) |
28 |
|
29 |
|
30 |
if __name__ == '__main__': |
31 |
app.run(debug=True)
|