@app.route('/diseases_bpnn', methods=["POST"]) def diseases_bp_app(): request = flask.request # 获取请求IP地址 if request.headers.getlist("X-Forwarded-For"): ip = request.headers.getlist("X-Forwarded-For")[-1] else: ip = request.remote_addr print(">>>>>>>>ip:{}<<<<<<<<<<".format(ip)) returnData = {} params = request.json input = diseases_preprocessing(params["input"]) pred = F.softmax(diseases_bpnn(torch.from_numpy(input).float()), dim=1)[0][1] returnData['prob'] = f'{pred:.4f}' return returnData
时间: 2023-06-08 19:07:52 浏览: 81
automatic-diagnosis.rar_leaf diseases_病叶_病斑_病斑特征_颜色纹理形状
5星 · 资源好评率100%
这段代码是一个 Flask 应用的路由函数,@app.route('/diseases_bpnn', methods=["POST"]) 表示当访问路径为 /diseases_bpnn 且 HTTP 请求方法为 POST 时,会调用这个函数。函数名为 diseases_bp_app,它从 Flask.request 对象中获取请求数据。
阅读全文