-
Notifications
You must be signed in to change notification settings - Fork 1
/
__server__.py
38 lines (23 loc) · 714 Bytes
/
__server__.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
from main import *
from flask import Flask, request
from random import randint
import requests, json
import cv2
app = Flask(__name__)
app.secret_key = str(randint(1000, 10000))
# set the api to perform face recognition of certain celebs
@app.route('/api/face_recognition', methods=['POST'])
def face_recognition():
r = request
# convert string of image data to uint8
nparr = np.fromstring(r.data, np.uint8)
# decode image
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
# pass the image to the face recognition method
result = main(img, ready=True)
message = {
"data" : result
}
return json.dumps(message)
if __name__=="__main__":
app.run(port=5030)