-
Notifications
You must be signed in to change notification settings - Fork 0
/
clientApp.py
41 lines (31 loc) · 1022 Bytes
/
clientApp.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
39
40
41
from flask import Flask, request, jsonify, render_template
import os
from flask_cors import CORS, cross_origin
from ai_utils.utils import decodeImage
from research.obj import MultiClassObj
os.putenv('LANG', 'en_US.UTF-8')
os.putenv('LC_ALL', 'en_US.UTF-8')
app = Flask(__name__)
CORS(app)
# @cross_origin()
class ClientApp:
def __init__(self):
self.filename = "inputImage.jpg"
modelPath = 'research/ssd_mobilenet_v1_coco_2017_11_17'
self.objectDetection = MultiClassObj(self.filename, modelPath)
@app.route("/")
def home():
return render_template("index.html")
@app.route("/predict", methods=['POST'])
@cross_origin()
def predictRoute():
image = request.json['image']
decodeImage(image, clApp.filename)
result = clApp.objectDetection.getPrediction()
return jsonify(result)
#port = int(os.getenv("PORT"))
if __name__ == "__main__":
clApp = ClientApp()
#port = 5000
#app.run(host='0.0.0.0', port=port)
app.run(host='127.0.0.1', port=5000, debug=True)