|
@@ -1,10 +1,19 @@
|
|
|
-from flask import Blueprint, request, jsonify, redirect, url_for, current_app, send_from_directory, make_response
|
|
|
+#!/usr/bin/env python
|
|
|
+# -*- encoding: utf-8 -*-
|
|
|
+'''
|
|
|
+@Contact : liuyuqi.gov@msn.cn
|
|
|
+@Time : 2023/11/09 14:21:52
|
|
|
+@License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
|
|
|
+@Desc : api v1
|
|
|
+'''
|
|
|
+
|
|
|
+from flask import Blueprint, request, jsonify, current_app, send_from_directory, make_response
|
|
|
import datetime
|
|
|
import os
|
|
|
import shutil
|
|
|
+from medical_assist import predict
|
|
|
|
|
|
bp = Blueprint('v1', __name__, url_prefix='/api/v1')
|
|
|
-# get flask app
|
|
|
|
|
|
def allowed_file(filename):
|
|
|
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'JPG', 'PNG', 'bmp'])
|
|
@@ -17,8 +26,16 @@ def home():
|
|
|
'msg': "api/v1"
|
|
|
}))
|
|
|
|
|
|
-@bp.route('/upload', methods=['GET', 'POST'])
|
|
|
+@bp.route('/upload', methods=['GET','POST'])
|
|
|
def upload_file():
|
|
|
+ ''' upload file '''
|
|
|
+
|
|
|
+ if 'file' not in request.files:
|
|
|
+ return jsonify({
|
|
|
+ 'status': -1,
|
|
|
+ 'msg': 'no file part'
|
|
|
+ })
|
|
|
+
|
|
|
file = request.files['file']
|
|
|
print(datetime.datetime.now(), file.filename)
|
|
|
if file and allowed_file(file.filename):
|
|
@@ -27,7 +44,7 @@ def upload_file():
|
|
|
shutil.copy(src_path, './tmp/ct')
|
|
|
image_path = os.path.join('./tmp/ct', file.filename)
|
|
|
print(src_path, image_path)
|
|
|
- pid, image_info = paddlex.main.c_main(image_path, current_app.model)
|
|
|
+ pid, image_info = predict(image_path, current_app.pdx_model)
|
|
|
return jsonify({'status': 1,
|
|
|
'image_url': 'http://127.0.0.1:5003/tmp/ct/' + pid,
|
|
|
'draw_url': 'http://127.0.0.1:5003/tmp/draw/' + pid,
|