Spaces:
Sleeping
Sleeping
Update
Browse files
app.py
CHANGED
|
@@ -5,13 +5,14 @@ import json
|
|
| 5 |
from PIL import Image
|
| 6 |
|
| 7 |
def get_attributes(json):
|
|
|
|
| 8 |
liveness = "GENUINE" if json.get('liveness') >= 0.5 else "FAKE"
|
| 9 |
attr = json.get('attribute')
|
| 10 |
age = attr.get('age')
|
| 11 |
gender = attr.get('gender')
|
| 12 |
emotion = attr.get('emotion')
|
| 13 |
ethnicity = attr.get('ethnicity')
|
| 14 |
-
|
| 15 |
mask = [attr.get('face_mask')]
|
| 16 |
if attr.get('glasses') == 'USUAL':
|
| 17 |
mask.append('GLASSES')
|
|
@@ -23,13 +24,15 @@ def get_attributes(json):
|
|
| 23 |
eye.append('LEFT')
|
| 24 |
if attr.get('eye_right') >= 0.5:
|
| 25 |
eye.append('RIGHT')
|
| 26 |
-
|
| 27 |
facehair = attr.get('facial_hair')
|
| 28 |
haircolor = attr.get('hair_color')
|
| 29 |
hairtype = attr.get('hair_type')
|
| 30 |
headwear = attr.get('headwear')
|
| 31 |
-
|
| 32 |
activity = []
|
|
|
|
|
|
|
| 33 |
if attr.get('phone_recording') >= 0.5:
|
| 34 |
activaty.append('PHONE_RECORDING')
|
| 35 |
if attr.get('phone_use') >= 0.5:
|
|
@@ -38,12 +41,12 @@ def get_attributes(json):
|
|
| 38 |
activaty.append('SEATBELT')
|
| 39 |
if attr.get('smoking') >= 0.5:
|
| 40 |
activaty.append('SMOKING')
|
| 41 |
-
|
| 42 |
pitch = attr.get('pitch')
|
| 43 |
roll = attr.get('roll')
|
| 44 |
yaw = attr.get('yaw')
|
| 45 |
quality = attr.get('quality')
|
| 46 |
-
|
| 47 |
return liveness, age, gender, emotion, ethnicity, mask, eye, facehair, haircolor, hairtype, headwear, activity, pitch, roll, yaw, quality
|
| 48 |
|
| 49 |
def compare_face(frame1, frame2):
|
|
@@ -60,6 +63,7 @@ def compare_face(frame1, frame2):
|
|
| 60 |
|
| 61 |
face1 = Image.new('RGBA',(150, 150), (80,80,80,0))
|
| 62 |
face2 = Image.new('RGBA',(150, 150), (80,80,80,0))
|
|
|
|
| 63 |
liveness1, age1, gender1, emotion1, ethnicity1, mask1, eye1, facehair1, haircolor1, hairtype1, headwear1, activity1, pitch1, roll1, yaw1, quality1 = [None] * 16
|
| 64 |
liveness2, age2, gender2, emotion2, ethnicity2, mask2, eye2, facehair2, haircolor2, hairtype2, headwear2, activity2, pitch2, roll2, yaw2, quality2 = [None] * 16
|
| 65 |
res1 = r.json().get('image1')
|
|
|
|
| 5 |
from PIL import Image
|
| 6 |
|
| 7 |
def get_attributes(json):
|
| 8 |
+
print("1------------------")
|
| 9 |
liveness = "GENUINE" if json.get('liveness') >= 0.5 else "FAKE"
|
| 10 |
attr = json.get('attribute')
|
| 11 |
age = attr.get('age')
|
| 12 |
gender = attr.get('gender')
|
| 13 |
emotion = attr.get('emotion')
|
| 14 |
ethnicity = attr.get('ethnicity')
|
| 15 |
+
print("2------------------")
|
| 16 |
mask = [attr.get('face_mask')]
|
| 17 |
if attr.get('glasses') == 'USUAL':
|
| 18 |
mask.append('GLASSES')
|
|
|
|
| 24 |
eye.append('LEFT')
|
| 25 |
if attr.get('eye_right') >= 0.5:
|
| 26 |
eye.append('RIGHT')
|
| 27 |
+
print("3------------------")
|
| 28 |
facehair = attr.get('facial_hair')
|
| 29 |
haircolor = attr.get('hair_color')
|
| 30 |
hairtype = attr.get('hair_type')
|
| 31 |
headwear = attr.get('headwear')
|
| 32 |
+
print("4------------------")
|
| 33 |
activity = []
|
| 34 |
+
if attr.get('food_consumption') >= 0.5:
|
| 35 |
+
activaty.append('EATING')
|
| 36 |
if attr.get('phone_recording') >= 0.5:
|
| 37 |
activaty.append('PHONE_RECORDING')
|
| 38 |
if attr.get('phone_use') >= 0.5:
|
|
|
|
| 41 |
activaty.append('SEATBELT')
|
| 42 |
if attr.get('smoking') >= 0.5:
|
| 43 |
activaty.append('SMOKING')
|
| 44 |
+
print("5------------------")
|
| 45 |
pitch = attr.get('pitch')
|
| 46 |
roll = attr.get('roll')
|
| 47 |
yaw = attr.get('yaw')
|
| 48 |
quality = attr.get('quality')
|
| 49 |
+
print("6------------------")
|
| 50 |
return liveness, age, gender, emotion, ethnicity, mask, eye, facehair, haircolor, hairtype, headwear, activity, pitch, roll, yaw, quality
|
| 51 |
|
| 52 |
def compare_face(frame1, frame2):
|
|
|
|
| 63 |
|
| 64 |
face1 = Image.new('RGBA',(150, 150), (80,80,80,0))
|
| 65 |
face2 = Image.new('RGBA',(150, 150), (80,80,80,0))
|
| 66 |
+
|
| 67 |
liveness1, age1, gender1, emotion1, ethnicity1, mask1, eye1, facehair1, haircolor1, hairtype1, headwear1, activity1, pitch1, roll1, yaw1, quality1 = [None] * 16
|
| 68 |
liveness2, age2, gender2, emotion2, ethnicity2, mask2, eye2, facehair2, haircolor2, hairtype2, headwear2, activity2, pitch2, roll2, yaw2, quality2 = [None] * 16
|
| 69 |
res1 = r.json().get('image1')
|