1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| import os from flask import Flask,request,make_response,send_from_directory from src.PreProcessing import prepare_function from src.OptimizedProcessing import optimized_processing from src.infer import infer from src.MeshToJson import MeshToJson app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = "data/" model_upper_path = "models/model_upper.onnx" model_lower_path = "models/model_lower.onnx" devices = 'CUDAExecutionProvider' UPLOAD_FOLDER ="data/"
@app.route('/Seg/', methods=['GET', 'POST']) def MeshSeg(): if 'file' not in request.files: return "Please upload the file" file = request.files['file'] if not file: return "The file is empty" save_path=os.path.join(app.config['UPLOAD_FOLDER'], file.filename) file.save(save_path)
prepare_args = prepare_function(save_path) output_u = infer(prepare_args, model_upper_path, devices) output_l = infer(prepare_args, model_lower_path, devices) data = optimized_processing(output_l, output_u, prepare_args) MeshToJson(data, out_path="data/out.json")
response = make_response(send_from_directory(path = "data/out.json",directory="./data/", filename ="out.json", as_attachment=True)) return response
if __name__ == '__main__': app.run(host='0.0.0.0',debug=True, port=9999)
|