Update 'face_recognition/app/app.py'
This commit is contained in:
parent
2a0ba99894
commit
414b0bd8fb
@ -4,6 +4,7 @@ from minio.error import (ResponseError, BucketAlreadyOwnedByYou, BucketAlreadyEx
|
||||
import os
|
||||
import uuid
|
||||
import pickle
|
||||
import face_recognition
|
||||
app = Flask(__name__)
|
||||
minioClient = Minio('minio:9000', access_key=os.environ['s3-name'], secret_key=os.environ['s3-password'], secure=False)
|
||||
|
||||
@ -36,6 +37,12 @@ def new_user_id():
|
||||
def new_face():
|
||||
id = request.args.get('id', None)
|
||||
upload_id = request.args.get('upload_id', None)
|
||||
minioClient.fget_object('uploads', upload_id, '/tmp/'+str(upload_id))
|
||||
face = face_recognition.load_image_file('/tmp/'+str(upload_id))
|
||||
face_encoding = face_recognition.face_encodings(face)[0]
|
||||
with open('/tmp/'+str(id)+'.pkl', 'wb') as file:
|
||||
pickle.dump(face_encoding, file)
|
||||
minioClient.fput_object('users', str(id), '/tmp/'+str(id)+'.pkl')
|
||||
return str(id) + str(upload_id)
|
||||
|
||||
def check_id(id):
|
||||
@ -59,6 +66,14 @@ def setup():
|
||||
pass
|
||||
except ResponseError as err:
|
||||
raise
|
||||
try:
|
||||
minioClient.make_bucket("uploads")
|
||||
except BucketAlreadyOwnedByYou as err:
|
||||
pass
|
||||
except BucketAlreadyExists as err:
|
||||
pass
|
||||
except ResponseError as err:
|
||||
raise
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user