-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCNNServer.py
More file actions
32 lines (26 loc) · 939 Bytes
/
CNNServer.py
File metadata and controls
32 lines (26 loc) · 939 Bytes
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
# -*- coding: utf-8 -*-
import sys
sys.path.append('./CNN/model')
import os,base64,json,datetime
import datetime
from flask import Flask, request,render_template
from flask_uploads import UploadSet, configure_uploads, IMAGES
import mnistLeNet
app = Flask(__name__)
m_predict = mnistLeNet.LeNetModel_io()
@app.route('/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
dataList = json.loads(request.data.decode('utf-8'))
imagedata = base64.b64decode(dataList['image'])
date = datetime.datetime.now()
datestr = date.strftime('%Y-%m-%d_%H-%M-%S')
image_path = './ImageFiles/'+datestr+'.png'
file=open(image_path,'wb')
file.write(imagedata)
file.close()
full_path=os.getcwd()+'/ImageFiles/'+datestr+'.png'
return str(m_predict.predict(full_path))
return render_template('draw.html')
if __name__ == '__main__':
app.run()