forked from YichenQiu/deepdesign.space
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
executable file
·38 lines (30 loc) · 1.09 KB
/
app.py
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
from flask import Flask, render_template, json, jsonify, request, Response
import io
import jsonpickle
import numpy as np
# import cv2
from PIL import Image
from Model.ModelClass import inception_retrain
#from scripts.label_image import predict_result
app = Flask(__name__)
# app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024 # 64 mb image
model=None
@app.route("/")
def home():
return render_template('Interior_design.html')
@app.route("/classify", methods=['POST'])
def get_image():
global model
Predictions = {}
file_object = request.files['photo']
photo = file_object.read()
if model is None:
model=inception_retrain()
pred1,pred2,pred3,pred4 = model.predict(photo)
Predictions.update({'Bohemian':'{:.1%}'.format(pred1),'Coastal':'{:.1%}'.format(pred2),'Industrial':'{:.1%}'.format(pred3),'Scandinavian':'{:.1%}'.format(pred4)})
return jsonify(Predictions)
# def get_filename():
# user_data = request.get_json[]
# n,r=int(user_data['n'])
if __name__ == '__main__':
app.run(host='0.0.0.0', threaded=True)