Commit 39aae5aad324d8d97b6293ab7e29ff37387f2c8e
1 parent
6aa1e66d
Adding script to compare attributes to equal fusion of attributes and faceRecogn…
…ition and plot; adding script to do weighted fusion comparison plots of facerecognition, attributes and the weighted fusion of the two
Showing
2 changed files
with
73 additions
and
0 deletions
scripts/attributesWeighted.py
0 → 100644
| 1 | +import os | |
| 2 | +import sys | |
| 3 | + | |
| 4 | +if not (len(sys.argv)) == 3: | |
| 5 | + print("ERROR: Input requires 3 parameters\nUsage: attributesWeighted.py <min-weight-FR> <max-weight-FR>") | |
| 6 | +else: | |
| 7 | + mask = "MEDS.mask" | |
| 8 | + fr_matrix = "faceRecognition.mtx" | |
| 9 | + attr_matrix = "attributes.mtx" | |
| 10 | + min_weight = sys.argv[1] | |
| 11 | + max_weight = sys.argv[2] | |
| 12 | + constant = 1 | |
| 13 | + | |
| 14 | + if not os.path.isfile(mask): | |
| 15 | + print("ERROR: No mask found, run compareFaceRecognitionToAttributes.py first then try again") | |
| 16 | + elif not os.path.isfile(fr_matrix): | |
| 17 | + print("ERROR: No face recognition matrix found, run compareFaceRecognitionToAttributes.py first then try again") | |
| 18 | + elif not os.path.isfile(attr_matrix): | |
| 19 | + print("ERROR: No attributes matrix found, run compareFaceRecognitionToAttributes.py first then try again") | |
| 20 | + else: | |
| 21 | + for i in range(int(min_weight), int(max_weight)): | |
| 22 | + print("Using weights " + str(i) + ":" + str(constant)) | |
| 23 | + os.system("br -fuse " + fr_matrix + " " + attr_matrix + " ZScore Sum" + str(i) + ":" + str(constant) + " weightedFusion.mtx") | |
| 24 | + os.system("br -eval weightedFusion.mtx " + mask + " weightedFusion.csv") | |
| 25 | + os.system("br -eval faceRecognition.mtx " + mask + " faceRecognition.csv") | |
| 26 | + os.system("br -eval attributes.mtx " + mask + " attributes.csv") | |
| 27 | + os.system("br -plot faceRecognition.csv attributes.csv weightedFusion.csv weightedFusion_" + str(i) + ".pdf") | ... | ... |
scripts/compareFaceRecognionToAttributes.py
0 → 100755
| 1 | +import os | |
| 2 | +import sys | |
| 3 | + | |
| 4 | +if not (len(sys.argv) == 2 or len(sys.argv) == 4): | |
| 5 | + print("ERROR: Input requires 1 or 3 input parameters\n Usage: compareFaceRecognitionToAttributes.py <path_to_data> [optional]<<path_to_query_parameter> <path_to_target_parameter>>") | |
| 6 | +else: | |
| 7 | + data = sys.argv[1] | |
| 8 | + compareData = "../data/MEDS/img" | |
| 9 | + attrDir = "Attributes" | |
| 10 | + attrPath = attrDir + "/all.model" | |
| 11 | + mask = "MEDS.mask" | |
| 12 | + if len(sys.argv) == 4: | |
| 13 | + query = sys.argv[2] | |
| 14 | + target = sys.argv[3] | |
| 15 | + else: | |
| 16 | + query = "../data/MEDS/sigset/MEDS_frontal_query.xml" | |
| 17 | + target = "../data/MEDS/sigset/MEDS_frontal_target.xml" | |
| 18 | + | |
| 19 | + #Create Evaluation Mask | |
| 20 | + if not os.path.isfile(mask): | |
| 21 | + os.system("br -makeMask ../data/MEDS/sigset/MEDS_frontal_target.xml ../data/MEDS/sigset/MEDS_frontal_query.xml " + mask) | |
| 22 | + | |
| 23 | + #Train FaceRecognition Algorithm (Already trained from "make install") | |
| 24 | + #os.system("br -algorithm FaceRecognition -path " + data + " -train results1194v2.turk faceRecognition.model") | |
| 25 | + #Train Attributes Algorithm | |
| 26 | + if not os.path.isfile(attrPath): | |
| 27 | + os.system("mkdir -p " + attrDir) | |
| 28 | + os.system("br -algorithm AllAttributesMatching -path " + data + " -train results1194v2.turk " + attrPath) | |
| 29 | + | |
| 30 | + #Run FaceRecognition Comparison | |
| 31 | + os.system("br -path " + compareData + " -algorithm FaceRecognition -compare " + target + " " + query + " faceRecognition.mtx") | |
| 32 | + #Run Attributes Comparison | |
| 33 | + os.system("br -path " + compareData + " -TurkTargetHuman false -TurkQueryMachine true -algorithm " + attrPath + " -compare " + target + " " + query + " attributes.mtx") | |
| 34 | + | |
| 35 | + #Fuse the Matricies | |
| 36 | + os.system("br -fuse faceRecognition.mtx attributes.mtx ZScore Sum fusion.mtx") | |
| 37 | + | |
| 38 | + #Evaluate all three matricies | |
| 39 | + os.system("br -eval faceRecognition.mtx " + mask + " faceRecognition.csv") | |
| 40 | + os.system("br -eval attributes.mtx " + mask + " attributes.csv") | |
| 41 | + os.system("br -eval fusion.mtx " + mask + " faceRecognitionVSAttributes.csv") | |
| 42 | + | |
| 43 | + #Plot results | |
| 44 | + os.system("br -plot faceRecognition.csv faceRecognition.pdf") | |
| 45 | + os.system("br -plot attributes.csv attributes.pdf") | |
| 46 | + os.system("br -plot faceRecognition.csv attributes.csv faceRecognitionVSAttributes.csv faceRecognitionVSAttributes.pdf") | ... | ... |