我开发了一个android应用程序,可以拍下一个数字的照片并发送到服务器。在服务器中,图像将通过神经网络识别数字并将结果发送回。我得到的是错误500而不是结果。在
以下是我的android代码://sendbmp is the photo taken from the camera. Its file type is .bmp
sendbmp = Tools.getFocusedBitmap(getApplicationContext(), camera, data, focusBox.getBox());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
jpgbitmap = sendbmp.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byteArray = stream.toByteArray();
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mJSONArray = new JSONArray(byteArray);
base64array = Base64.encodeToString(byteArray,Base64.DEFAULT);
}
} catch (JSONException e) {
e.printStackTrace();
}
new Networkconnection().execute();
这是Networkconnection()的代码这是我将照片发送到服务器的地方。我正在使用okhttp:
^{pr2}$
这是我使用烧瓶的服务器端:@app.route('/', methods=['GET','POST'])
def hello_world():
received_img = request.args.get('body')
decode_Imge = pic.open(BytesIO(base64.b64decode(received_img)))
result = Net.image_function(decode_Imge)
return result
if __name__ == '__main__':
Net = Network([784, 100,10])
for x in range(0,4):
training_data, validation_data,test_data = load_data_wrapper()
Net.SGD(training_data, 30, 10, 5.0, test_data = test_data)
app.run(host ="MyIP") //In my code I actually have my ip address and not "MYIP"
注意:当我运行服务器时,我没有得到任何错误。所有的类都在服务器的一个文档中。当我打印回溯时,我得到以下信息:
Traceback (most recent call last): File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 648, in inner fd = int(os.environ['WERKZEUG_SERVER_FD']) File "C:\Python27\lib\os.py", line 425, in __getitem__ return self.data[key.upper()] KeyError: 'WERKZEUG_SERVER_FD'
这是我得到的错误,不幸的是,部分错误被按钮阻止了:
博主开发了一个Android应用,可拍照并上传到服务器,服务器用神经网络识别数字后返回结果,但上传时出现500错误。文中给出了Android端和服务器端代码,服务器使用Flask框架,运行时无错误,但打印回溯出现KeyError: 'WERKZEUG_SERVER_FD'。
2709

被折叠的 条评论
为什么被折叠?



