From 86f6e1128858b755dbf4dc3d91a847f0857bc9b1 Mon Sep 17 00:00:00 2001 From: "BIJAN_G16\\bijan" Date: Wed, 21 May 2025 11:08:18 +0200 Subject: [PATCH] adapted score computation, to folder-wise aggregation. --- project/__pycache__/config.cpython-310.pyc | Bin 1020 -> 1020 bytes .../__pycache__/comparator.cpython-310.pyc | Bin 9523 -> 9130 bytes .../meta_data_extractor.cpython-310.pyc | Bin 5532 -> 5532 bytes project/meta_data/comparator.py | 257 +++++++++--------- project/meta_data/meta_data_extractor.py | 1 - 5 files changed, 127 insertions(+), 131 deletions(-) diff --git a/project/__pycache__/config.cpython-310.pyc b/project/__pycache__/config.cpython-310.pyc index 76a78032d057da47fe9ebd3edf2aaedc65acebec..b7f204807293c4cf3e666934cb82665dfa1f77ed 100644 GIT binary patch delta 20 acmeyv{)e4ApO=@50SN56bT@K;WCj2_83jrJ delta 20 acmeyv{)e4ApO=@50SNkAl{a#KWCj2{00oQy diff --git a/project/meta_data/__pycache__/comparator.cpython-310.pyc b/project/meta_data/__pycache__/comparator.cpython-310.pyc index 2ddb5d10029bb6a1632f82c17f022fd86191fb5f..e7a3955fd537e22613937dbbe4be863473a1bf72 100644 GIT binary patch delta 3359 zcmaJ@Z*Ut&6~EovJDp`&K1;GB+wtFo5XDX65Qd~lN>h@yw9`1WX_`bNh_mi&E4C$h z@0{3Sg+c|x2l^*7JIoYHQ=2qEpfec=pZUTU-~$667&_NshT#KDzwp15hPLqDN>&_q z25IiMZ{NP#ef!>T-`?%VzyD~w($y8!;P>p;cg;>7`(gauh`iBb*9}k|g~$IMfFLgE zL!^CLR;y8vbk%37uM6#%cK*Q{6AUeyc5{^Pf<9P49}xR4MT^6lYT03JF|qNDtkxXG zw~FhpDJ7WVkfDK=4r;ol`b_opW`8l^YA3au#^hTR9OeYzEghwO2x)+v5$bbQpYH`Z zB$q-WZ&?#{9I=T_EHXkZ5+x};MQoZN>}`GohKe}b`Y!^436F})b0EOZ{%>4nG>8et zW>3uk*%aogC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jEZY2eH-*Xf!F*K|15jVa{%s9etu|t>;*5JpFy&d1mz%+Z-(H$ z5hN-~;SG`)v?_43@Q>&z_+@~~06mI*+2MzXtnv@jyZ8s=FNM}&4qFv2yv^r!q;eGR zGw;A_;(g68#YpCq;N=L#zfQRw6#sJ3+dRKLL(cN%_Df#4s%q8(|7iQJSAUK&kt^d! zVSZ7O7yFPBsdEykSp>Z0I7x)LV*6^kMya++%gBF}NESGDu0QDa`IG)&H0W3Tp_upo DPT9yf diff --git a/project/meta_data/__pycache__/meta_data_extractor.cpython-310.pyc b/project/meta_data/__pycache__/meta_data_extractor.cpython-310.pyc index d1defd487eca6573f9e6579353a9d3b163e5602c..e90291241a0732766dd13d563012ed9e8fe1d02a 100644 GIT binary patch delta 29 jcmbQEJx7~2pO=@50SFGX>1Isb$ZIUj$hg^2IGPCnY^( 0 else len(kps_a) + same_estimation = 0 + for idx, kp_a in enumerate(kps_a): + kp_b = kps_b[idx] + if ((kp_a[0] == 0) and (kp_a[1] == 0)) and ((kp_b[0] == 0) and (kp_b[1] == 0)): + same_estimation += 1 + elif ((kp_a[0] > 0) or (kp_a[1] > 0)) and ((kp_b[0] > 0) or (kp_b[1] > 0)): + same_estimation += 1 + + person_keypoint_accuracy = (same_estimation / len(kps_a)) * 100.0 #Then check the accuracy and deviation of the keypoints - point_wise_deviations = [] + point_position_similarities = [] for kp_a, kp_b in zip(kps_a, kps_b): if (kp_a[0] == 0) and (kp_a[1] == 0): continue if (kp_b[0] == 0) and (kp_b[1] == 0): continue - deviation = np.linalg.norm(np.array(kp_a) - np.array(kp_b)) - point_wise_deviations.append(deviation) + deviation = (1.0 - (np.linalg.norm(np.array(kp_a) - np.array(kp_b)) / math.sqrt(2))) * 100.0 + point_position_similarities.append(deviation) + return person_keypoint_accuracy, point_position_similarities - average_position_deviation = None - if len(point_wise_deviations) > 0: - average_position_deviation = np.mean(point_wise_deviations) - - return n_point_deviation / len(kps_a), average_position_deviation - -def _compute_body_keypoint_deviation(kps_a, kps_b, bbox_a, bbox_b, img_w, img_h): - #TODO ES KANN SEIN DASS KEYPOINTS LEER SIND UND SOMIT SHAPE ANDERS +def _compute_body_keypoint_similarity(kps_a, kps_b, bbox_a, bbox_b): + if bbox_b == None or len(bbox_b) == 0: + return 0.0, [] #Is shape the same? if len(kps_a) != len(kps_b): raise ValueError(f"Key-point shapes differ: {kps_a.shape} vs {kps_b.shape}") #Filter keypoints with (x,y) == (0,0) coordinates, based on Bounding box origin //keypoints were shifted by bbox offset in advance, this causes not found keypoints (0,0) to be exactly at bbox origin - _adapt_body_keypoints(kps_a, bbox_a, img_w, img_h) - _adapt_body_keypoints(kps_b, bbox_b, img_w, img_h) - n_point_deviation, avg_position_deviation = _compare_keypoints(kps_a, kps_b) - return n_point_deviation, avg_position_deviation + _adapt_body_keypoints(kps_a, bbox_a) + _adapt_body_keypoints(kps_b, bbox_b) + person_keypoint_accuracy, point_position_similarities = _compare_keypoints(kps_a, kps_b) + return person_keypoint_accuracy, point_position_similarities -def _compute_face_keypoint_deviation(kps_a, kps_b, img_w, img_h): +def _compute_face_keypoint_similarity(kps_a, kps_b, bbox_a, bbox_b): #Is shape the same? if len(kps_a) != len(kps_b): raise ValueError(f"Key-point shapes differ: {kps_a.shape} vs {kps_b.shape}") - - kps_a = _adapt_face_keypoints(kps_a, img_w, img_h) - kps_b = _adapt_face_keypoints(kps_b, img_w, img_h) - n_point_deviation, avg_position_deviation = _compare_keypoints(kps_a, kps_b) - return n_point_deviation, avg_position_deviation + kps_a = _adapt_face_keypoints(kps_a, bbox_a) + kps_b = _adapt_face_keypoints(kps_b, bbox_b) + person_keypoint_accuracy, point_position_similarities = _compare_keypoints(kps_a, kps_b) + return person_keypoint_accuracy, point_position_similarities def _vec_from_dict(d) -> np.ndarray: EMOTIONS = ("angry", "disgust", "fear", "happy", "sad", "surprise", "neutral") @@ -156,6 +172,9 @@ def _match_persons(face_img1, face_img2): distance = result["distance"] #Default model: VGG-Face; Cosine Similarity, with tuned threshold return verified, distance +def write_image_results_to_folder_result_dict(image_result_dict, folder_result_dict): + raise NotImplementedError() + class Comparator: def compare_with_before_and_after_folder(self, before_directory: str, obfuscated_directory: str): #Validate it's the same dataset @@ -168,32 +187,26 @@ class Comparator: # if before_image_count != obfuscated_image_count: #TODO Einkommentiern #raise ValueError("Not same amount of files in both directories", "before_directory", before_directory, "obfuscated_directory", obfuscated_directory) - folder_result_dict = { - "person": { - "person_found_accuracy": 0.0, - "person_bbox_iou_avg": 0.0, - "person_segment_iou_avg": 0.0, - "person_n_keypoint_similarity_avg": 0.0, - "person_keypoint_position_similarity_avg": 0.0 - }, - "face": { - "face_found_accuracy": 0.0, - "face_bbox_iou_avg": 0.0, - "top1_emotion_accuracy": 0.0, - "emotion_vector_similarity_avg": 0.0, - "obfuscation_accuracy": 0.0, - "face_distance_avg": 0.0, - #"face_n_keypoint_deviation_avg": face_n_keypoint_deviation_avg, - "face_keypoint_position_similarity_avg": 0.0 - }, - "object": { - "object_found_accuracy": 0.0, - "object_bbox_iou_avg": 0.0, - "object_segment_iou_avg": 0.0, - "object_class_accuracy": 0.0 - } + folder_insights = { + "found_matching_persons_count": 0, + "before_person_count": 0, + "person_bbox_ious": [], + "person_segment_ious": [], + "person_keypoint_accuracies": [], + "person_keypoint_position_similarities": [], + "found_face_count": 0, + "face_bbox_ious": [], + "same_emotion_count": 0, + "emotion_vector_similarities": [], + "same_person_counter": 0, + "identity_distances": [], + "face_keypoint_position_similarities": [], + "found_matching_objects_count": 0, + "before_object_count": 0, + "object_bbox_ious": [], + "object_segment_ious": [], + "found_matching_classes_count": 0 } - iterations = 0 #Iterate through all images in before directory and find the corresponding image in the obfuscated directory for idx, before_image_name in enumerate(tqdm(os.listdir(before_directory))): #TODO Entfernen enumerate if before_image_name.endswith(".jpg"): @@ -201,28 +214,16 @@ class Comparator: before_meta_path = os.path.join(before_directory, before_image_name.replace(".jpg", ".json")) after_meta_path = os.path.join(obfuscated_directory, before_image_name.replace(".jpg", ".json")) - img_comparison_results = self._compare_metadata(before_meta_path, after_meta_path) - - print(iterations)#TODO Entfernen - print(img_comparison_results) + img_insights = self._compare_metadata(before_meta_path, after_meta_path) + #TODO hier weiter machen und die ergebnisse für den Ordner zusammenfassen #Aggregate meta_data into folder_result_dict - for key, value in img_comparison_results.items(): - for sub_key, sub_value in value.items(): - folder_result_dict[key][sub_key] += sub_value - iterations += 1 - if iterations == 3:#TODO: entfernen - break - #Divide by number of images to get averages - for key, value in folder_result_dict.items(): - for sub_key, sub_value in value.items(): - folder_result_dict[key][sub_key] /= iterations #before_image_count - print("after") - print(iterations) - print(folder_result_dict) + write_image_results_to_folder_result_dict(img_insights, folder_insights) + + print(folder_insights) exit() #TODO: FIX --> raise ValueError(f"Key-point shapes differ: {kps_a.shape} vs {kps_b.shape}") - return folder_result_dict + return folder_insights #Compare two images def _compare_metadata(self, path_to_meta_before: str, path_to_meta_after: str) -> dict: @@ -234,8 +235,8 @@ class Comparator: found_matching_persons_count = 0 person_bbox_ious = [] person_segment_ious = [] - person_n_keypoint_deviations = [] - person_keypoint_position_deviations = [] + person_keypoint_accuracies = [] + person_keypoint_position_similarities = [] found_face_count = 0 face_bbox_ious = [] @@ -244,7 +245,7 @@ class Comparator: same_person_counter = 0 identity_distances = [] #face_n_keypoint_deviations= [] - face_keypoint_position_deviations = [] + face_keypoint_position_similarities = [] #Object scores before_object_count = len(before_meta["objects"]) @@ -261,10 +262,9 @@ class Comparator: found_matching_persons_count += 1 person_bbox_ious.append(bbox_iou) person_segment_ious.append(segment_iou) - n_point_deviation, avg_position_deviation = _compute_body_keypoint_deviation(before_person["body_keypoints"], after_person["body_keypoints"], before_person["bbox"], after_person["bbox"], before_img.shape[1], before_img.shape[0]) - person_n_keypoint_deviations.append(n_point_deviation) - if avg_position_deviation is not None: - person_keypoint_position_deviations.append(avg_position_deviation) + person_keypoint_accuracy, point_position_similarities = _compute_body_keypoint_similarity(before_person["body_keypoints"], after_person["body_keypoints"], before_person["bbox"], after_person["bbox"]) + person_keypoint_accuracies.append(person_keypoint_accuracy) + person_keypoint_position_similarities.extend(point_position_similarities) #Check for validity of before data if before_person["face_bbox"] is None: @@ -284,10 +284,10 @@ class Comparator: if face_verified: same_person_counter += 1 identity_distances.append(identity_distance) - _, face_avg_position_deviation = _compute_face_keypoint_deviation(before_person["face_keypoints"], after_person["face_keypoints"], before_img.shape[1], before_img.shape[0]) - #face_n_keypoint_deviations.append(face_n_point_deviation) - if face_avg_position_deviation is not None: - face_keypoint_position_deviations.append(face_avg_position_deviation) + + _, point_position_similarities = _compute_face_keypoint_similarity(before_person["face_keypoints"], after_person["face_keypoints"], before_person["face_bbox"], after_person["face_bbox"]) + face_keypoint_position_similarities.extend(point_position_similarities) + for before_object in before_meta["objects"]: result = _find_best_matching_object(before_object, after_meta["objects"]) @@ -300,49 +300,46 @@ class Comparator: if before_object["label"] == after_object["label"]: found_matching_classes_count += 1 - person_found_accuracy = (found_matching_persons_count / before_person_count) * 100.0 - person_bbox_iou_avg = np.mean(person_bbox_ious) * 100.0 if len(person_bbox_ious) > 0 else 0.0 - person_segment_iou_avg = np.mean(person_segment_ious) * 100.0 if len(person_segment_ious) > 0 else 0.0 - person_n_keypoint_similarity_avg = (1.0 - np.mean(person_n_keypoint_deviations)) * 100.0 if len(person_n_keypoint_deviations) > 0 else 0.0 - person_keypoint_position_similarity_avg = (1.0 - np.mean(person_keypoint_position_deviations)) * 100.0 if len(person_keypoint_position_deviations) > 0 else 0.0 + # #TODO Scores global berechnen und nicht für ein bild konkret + # person_found_accuracy = (found_matching_persons_count / before_person_count) * 100.0 + # person_bbox_iou_avg = np.mean(person_bbox_ious) * 100.0 if len(person_bbox_ious) > 0 else 0.0 + # person_segment_iou_avg = np.mean(person_segment_ious) * 100.0 if len(person_segment_ious) > 0 else 0.0 + # person_n_keypoint_similarity_avg = (1.0 - np.mean(person_n_keypoint_deviations)) * 100.0 if len(person_n_keypoint_deviations) > 0 else 0.0 #TODO anders? + # person_keypoint_position_similarity_avg = (1.0 - np.mean(person_keypoint_position_deviations)) * 100.0 if len(person_keypoint_position_deviations) > 0 else 0.0 #TODO anders? + # + # face_found_accuracy = (found_face_count / before_person_count) * 100.0 if found_face_count > 0 else 0.0 + # face_bbox_iou_avg = np.mean(face_bbox_ious) * 100.0 if len(face_bbox_ious) > 0 else 0.0 + # top1_emotion_accuracy = ((same_emotion_count / found_face_count) * 100.0) if (found_face_count > 0) else 0.0 + # emotion_vector_similarity_avg = np.mean(emotion_vector_similarities) * 100.0 if len(emotion_vector_similarities) > 0 else 0.0 + # obfuscation_accuracy = ((1.0 - (same_person_counter / found_face_count)) * 100.0) if (found_face_count > 0) else 100.0 + # identity_distance_avg = np.mean(identity_distances) * 100.0 if len(identity_distances) > 0 else 100.0 + # #face_n_keypoint_deviation_avg = np.mean(face_n_keypoint_deviations) + # face_keypoint_position_similarity_avg = (1.0 - np.mean(face_keypoint_position_deviations)) * 100.0 if len(face_keypoint_position_deviations) > 0 else 0.0 + # + # object_found_accuracy = (found_matching_objects_count / before_object_count) * 100.0 + # object_bbox_iou_avg = np.mean(object_bbox_ious) * 100.0 if len(object_bbox_ious) > 0 else 0.0 + # object_segment_iou_avg = np.mean(object_segment_ious) * 100.0 if len(object_segment_ious) > 0 else 0.0 + # object_class_accuracy = (found_matching_classes_count / before_object_count) * 100.0 - face_found_accuracy = (found_face_count / before_person_count) * 100.0 if found_face_count > 0 else 0.0 - face_bbox_iou_avg = np.mean(face_bbox_ious) * 100.0 if len(face_bbox_ious) > 0 else 0.0 - top1_emotion_accuracy = ((same_emotion_count / found_face_count) * 100.0) if (found_face_count > 0) else 0.0 - emotion_vector_similarity_avg = np.mean(emotion_vector_similarities) * 100.0 if len(emotion_vector_similarities) > 0 else 0.0 - obfuscation_accuracy = ((1.0 - (same_person_counter / found_face_count)) * 100.0) if (found_face_count > 0) else 100.0 - identity_distance_avg = np.mean(identity_distances) * 100.0 if len(identity_distances) > 0 else 100.0 - #face_n_keypoint_deviation_avg = np.mean(face_n_keypoint_deviations) - face_keypoint_position_similarity_avg = (1.0 - np.mean(face_keypoint_position_deviations)) * 100.0 if len(face_keypoint_position_deviations) > 0 else 0.0 - object_found_accuracy = (found_matching_objects_count / before_object_count) * 100.0 - object_bbox_iou_avg = np.mean(object_bbox_ious) * 100.0 if len(object_bbox_ious) > 0 else 0.0 - object_segment_iou_avg = np.mean(object_segment_ious) * 100.0 if len(object_segment_ious) > 0 else 0.0 - object_class_accuracy = (found_matching_classes_count / before_object_count) * 100.0 - - result_score_dict = { - "person": { - "person_found_accuracy": person_found_accuracy, - "person_bbox_iou_avg": person_bbox_iou_avg, - "person_segment_iou_avg": person_segment_iou_avg, - "person_n_keypoint_similarity_avg": person_n_keypoint_similarity_avg, - "person_keypoint_position_similarity_avg": person_keypoint_position_similarity_avg - }, - "face": { - "face_found_accuracy": face_found_accuracy, - "face_bbox_iou_avg": face_bbox_iou_avg, - "top1_emotion_accuracy": top1_emotion_accuracy, - "emotion_vector_similarity_avg": emotion_vector_similarity_avg, - "obfuscation_accuracy": obfuscation_accuracy, - "face_distance_avg": identity_distance_avg, - #"face_n_keypoint_deviation_avg": face_n_keypoint_deviation_avg, - "face_keypoint_position_similarity_avg": face_keypoint_position_similarity_avg - }, - "object": { - "object_found_accuracy": object_found_accuracy, - "object_bbox_iou_avg": object_bbox_iou_avg, - "object_segment_iou_avg": object_segment_iou_avg, - "object_class_accuracy": object_class_accuracy, - } + image_insights = { + "found_matching_persons_count": found_matching_persons_count, + "before_person_count": before_person_count, + "person_bbox_ious": person_bbox_ious, + "person_segment_ious": person_segment_ious, + "person_keypoint_accuracies": person_keypoint_accuracies, + "person_keypoint_position_similarities": person_keypoint_position_similarities, + "found_face_count": found_face_count, + "face_bbox_ious": face_bbox_ious, + "same_emotion_count": same_emotion_count, + "emotion_vector_similarities": emotion_vector_similarities, + "same_person_counter": same_person_counter, + "identity_distances": identity_distances, + "face_keypoint_position_similarities": face_keypoint_position_similarities, + "found_matching_objects_count": found_matching_objects_count, + "before_object_count": before_object_count, + "object_bbox_ious": object_bbox_ious, + "object_segment_ious": object_segment_ious, + "found_matching_classes_count": found_matching_classes_count } - return result_score_dict \ No newline at end of file + return image_insights \ No newline at end of file diff --git a/project/meta_data/meta_data_extractor.py b/project/meta_data/meta_data_extractor.py index 02afde0..979b406 100644 --- a/project/meta_data/meta_data_extractor.py +++ b/project/meta_data/meta_data_extractor.py @@ -135,7 +135,6 @@ class MetaExtractor: face_kps = [] mesh = self._mp_mesh.process(face_crop) - if mesh.multi_face_landmarks: for lm in mesh.multi_face_landmarks[0].landmark: face_kps.append([