-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclientApp.py
53 lines (41 loc) · 1.32 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
from flask import Flask, request, jsonify, render_template,Response
import os
from flask_cors import CORS, cross_origin
from apparel.utils_.utils import decodeImage
from apparel.predictor_yolo_detector.detector_test import Detector
# import sys
# sys.path.insert(0, './com_ineuron_apparel')
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 = Detector(self.filename)
@app.route("/")
def home():
return render_template("index.html")
@app.route("/predict", methods=['POST','GET'])
@cross_origin()
def predictRoute():
try:
image = request.json['image']
decodeImage(image, clApp.filename)
result = clApp.objectDetection.detect_action()
except ValueError as val:
print(val)
return Response("Value not found inside json data")
except KeyError:
return Response("Key value error incorrect key passed")
except Exception as e:
print(e)
result = "Invalid input"
return jsonify(result)
#port = int(os.getenv("PORT"))
if __name__ == "__main__":
clApp = ClientApp()
port = 8500
app.run(host='0.0.0.0', port=port)