-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting.py
More file actions
59 lines (38 loc) · 1.55 KB
/
Copy pathTesting.py
File metadata and controls
59 lines (38 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#import userdata
import data
#import test
import requests
#import urllib.request
import Image_properties
import os
#userdata = data.professors[13]
def dif(a, b):
return abs(a-b)
def main(url):
userdata = Image_properties.get_data(url)
minnum = 10.0
minindex = 0
for index in range(len(data.professors)):
score = testing(index, userdata)
if(score < minnum):
minindex = index
minnum = score
name = os.listdir("ProfImages")[minindex]
print(name)
return name
def testing(index, userdata):
score = []
sum = 0.0
for i in range(len(data.professors[index][0]["faceAttributes"]["hair"]["hairColor"])):
score.append(dif(data.professors[index][0]["faceAttributes"]["hair"]["hairColor"][i]["confidence"],userdata[0]["faceAttributes"]["hair"]["hairColor"][i]["confidence"]))
score.append(dif(data.professors[index][0]["faceAttributes"]["smile"], userdata[0]["faceAttributes"]["smile"]))
if(data.professors[index][0]["faceAttributes"]["gender"] == userdata[0]["faceAttributes"]["gender"]):
score.append(0.0)
else:
score.append(10.0)
for i in {"beard", "moustache", "sideburns"}:
score.append(dif(data.professors[index][0]["faceAttributes"]["facialHair"][i], userdata[0]["faceAttributes"]["facialHair"][i]))
for i in range(len(score)):
sum += score[i]/len(score)
return sum
main('https://scontent-iad3-1.xx.fbcdn.net/v/t31.0-8/13323364_1556287674668112_7385276195470315606_o.jpg?oh=1fdebefb6977aac54190f6d68ccfb782&oe=5B1A81AC')