def face_match(): if request.method == 'POST': # check if the post request has the file part if ('file1' not in request.files) or ('file2' not in request.files): print('No file part') return redirect(request.url) file1 = request.files.get('file1') file2 = request.files.get('file2') # if user does not select file, browser also submit an empty part without filename if file1.filename == '' or file2.filename == '': print('No selected file') return redirect(request.url) if allowed_file(file1.filename) and allowed_file(file2.filename): #file1.save( os.path.join(UPLOAD_FOLDER, secure_filename(file1.filename)) ) #file2.save( os.path.join(UPLOAD_FOLDER, secure_filename(file2.filename)) ) ret = compare_faces(file1, file2) resp_data = { "match": bool(ret) } # convert numpy._bool of ret to bool for json.dumps return json.dumps(resp_data) # Return a demo page for GET request return '''
def face_match(): if request.method == 'POST': # check if the post request has the file part if ('file1' in request.files) and ('file2' in request.files): file1 = request.files.get('file1') file2 = request.files.get('file2') ret = compare_faces(file1, file2) resp_data = {"match": bool(ret)} # convert numpy._bool to bool for json.dumps return json.dumps(resp_data)
def face_match(): if(request.method == 'POST'): file1=request.files['file1'] file2=request.files['file2'] npimg1=np.fromfile(file1,np.uint8) img1=cv2.imdecode(npimg1,cv2.IMREAD_COLOR) npimg2=np.fromfile(file2,np.uint8) img2=cv2.imdecode(npimg2,cv2.IMREAD_COLOR) value=compare_faces(read_img(img1),read_img(img2)) if(value): return json.dumps(True) else: return json.dumps(False)