개정판 c64be242
issue #1366: fix path
Change-Id: I2ec81696a73fbc8ffb1b96e2c3289f33f507aebd
DTI_PID/WebServer/app.py | ||
---|---|---|
3 | 3 |
import numpy as np |
4 | 4 |
import sys, os |
5 | 5 |
|
6 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\CRAFT_pytorch_master') |
|
7 |
|
|
6 | 8 |
app = Flask(__name__) |
7 | 9 |
|
8 | 10 |
@app.route('/') |
... | ... | |
11 | 13 |
|
12 | 14 |
@app.route('/text_box', methods=['POST']) |
13 | 15 |
def text_box(): |
14 |
from CRAFT_pytorch_master import text_craft
|
|
16 |
import text_craft |
|
15 | 17 |
|
16 | 18 |
r = request |
17 | 19 |
nparr = np.fromstring(r.data, np.uint8) |
18 | 20 |
|
19 |
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR) |
|
21 |
buff = cv2.imdecode(nparr, cv2.IMREAD_COLOR) |
|
22 |
img = buff.reshape(1, -1) |
|
20 | 23 |
|
21 |
boxes = text_craft.get_text_box(img, img_path=None, score_path=None) |
|
24 |
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')
|
|
22 | 25 |
|
23 | 26 |
return jsonify({'text_box': boxes}) |
24 | 27 |
|
내보내기 Unified diff