justin2341 commited on
Commit
597c49e
1 Parent(s): 38daf3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -102,8 +102,7 @@ def check_liveness():
102
  file = request.files['file']
103
 
104
  try:
105
- #image = apply_exif_rotation(Image.open(file)).convert('RGB')
106
- image = Image.open(file).convert('RGB')
107
  except:
108
  result = "Failed to open file"
109
  faceState = {"is_not_front": isNotFront, "is_occluded": isOcclusion, "eye_closed": isEyeClosure, "mouth_opened": isMouthOpening,
@@ -118,17 +117,7 @@ def check_liveness():
118
  image_np = np.asarray(image)
119
 
120
  faceBoxes = (FaceBox * maxFaceCount)()
121
- faceCount = faceDetection(image_np, image_np.shape[1], image_np.shape[0], faceBoxes, maxFaceCount)
122
- if faceCount == 0:
123
- image = image.rotate(90, expand=True)
124
- faceCount = faceDetection(image_np, image_np.shape[1], image_np.shape[0], faceBoxes, maxFaceCount)
125
- if faceCount == 0:
126
- image = image.rotate(90, expand=True)
127
- faceCount = faceDetection(image_np, image_np.shape[1], image_np.shape[0], faceBoxes, maxFaceCount)
128
- if faceCount == 0:
129
- image = image.rotate(90, expand=True)
130
- faceCount = faceDetection(image_np, image_np.shape[1], image_np.shape[0], faceBoxes, maxFaceCount)
131
-
132
 
133
  for i in range(faceCount):
134
  landmark_68 = []
@@ -225,8 +214,7 @@ def check_liveness_base64():
225
  try:
226
  imageBase64 = content['base64']
227
  image_data = base64.b64decode(imageBase64)
228
- #image = apply_exif_rotation(Image.open(io.BytesIO(image_data))).convert("RGB")
229
- image = Image.open(io.BytesIO(image_data)).convert("RGB")
230
  except:
231
  result = "Failed to open file"
232
  faceState = {"is_not_front": isNotFront, "is_occluded": isOcclusion, "eye_closed": isEyeClosure, "mouth_opened": isMouthOpening,
 
102
  file = request.files['file']
103
 
104
  try:
105
+ image = apply_exif_rotation(Image.open(file)).convert('RGB')
 
106
  except:
107
  result = "Failed to open file"
108
  faceState = {"is_not_front": isNotFront, "is_occluded": isOcclusion, "eye_closed": isEyeClosure, "mouth_opened": isMouthOpening,
 
117
  image_np = np.asarray(image)
118
 
119
  faceBoxes = (FaceBox * maxFaceCount)()
120
+ faceCount = faceDetection(image_np, image_np.shape[1], image_np.shape[0], faceBoxes, maxFaceCount)
 
 
 
 
 
 
 
 
 
 
121
 
122
  for i in range(faceCount):
123
  landmark_68 = []
 
214
  try:
215
  imageBase64 = content['base64']
216
  image_data = base64.b64decode(imageBase64)
217
+ image = apply_exif_rotation(Image.open(io.BytesIO(image_data))).convert("RGB")
 
218
  except:
219
  result = "Failed to open file"
220
  faceState = {"is_not_front": isNotFront, "is_occluded": isOcclusion, "eye_closed": isEyeClosure, "mouth_opened": isMouthOpening,