Update 'face_recognition/app/app.py'

This commit is contained in:
fabrice 2019-06-25 13:47:30 +00:00
parent dfaa7fb034
commit 7408b83a54

View File

@ -35,7 +35,7 @@ def new_user_id():
with open('/tmp/demo_object.pkl', 'wb') as f: with open('/tmp/demo_object.pkl', 'wb') as f:
pickle.dump(demo_object, f) pickle.dump(demo_object, f)
minioClient.fput_object('users', str(id), '/tmp/demo_object.pkl') minioClient.fput_object('users', str(id), '/tmp/demo_object.pkl')
return(jsonify({'id':id})) return jsonify({'id':id, 'id2':'test2'})
@app.route('/init_face') @app.route('/init_face')
#call like https://face.sguba.de/init_face?id=123&encoded_string=abc #call like https://face.sguba.de/init_face?id=123&encoded_string=abc
@ -56,7 +56,7 @@ def new_face():
with open('/tmp/'+str(id)+'.pkl', 'wb') as file: with open('/tmp/'+str(id)+'.pkl', 'wb') as file:
pickle.dump(face_encoding, file) pickle.dump(face_encoding, file)
minioClient.fput_object('users', str(id), '/tmp/'+str(id)+'.pkl') minioClient.fput_object('users', str(id), '/tmp/'+str(id)+'.pkl')
return str(id) return jsonify({'id':id})
@app.route('/check_face') @app.route('/check_face')
#call like https://face.sguba.de/check_face?id=123&encoded_string=abc #call like https://face.sguba.de/check_face?id=123&encoded_string=abc
@ -71,7 +71,7 @@ def check_face():
minioClient.fget_object('users', str(id), '/tmp/'+str(id)) minioClient.fget_object('users', str(id), '/tmp/'+str(id))
with open('/tmp/'+str(id), 'rb') as file: with open('/tmp/'+str(id), 'rb') as file:
face2_encoding = pickle.load(file) face2_encoding = pickle.load(file)
return str(face_recognition.compare_faces([face_encoding], face2_encoding)) return jsonify({'result':face_recognition.compare_faces([face_encoding], face2_encoding)})
def check_id(id): def check_id(id):