diff --git a/project/__pycache__/config.cpython-310.pyc b/project/__pycache__/config.cpython-310.pyc index 058391b..aa8b537 100644 Binary files a/project/__pycache__/config.cpython-310.pyc and b/project/__pycache__/config.cpython-310.pyc differ diff --git a/project/config.py b/project/config.py index 78da3d7..6ab2dbf 100644 --- a/project/config.py +++ b/project/config.py @@ -7,7 +7,7 @@ class Config: raw_dataset_path="datasets/raw/" filtered_output_directory="datasets/filtered/" obfuscated_output_directory="datasets/obfuscated/" - max_images_per_dataset=500 + max_images_per_dataset=1000 seg_model_type="yolo11m-seg.pt" pose_model_type="yolo11m-pose.pt" diff --git a/project/main.py b/project/main.py index b32a63a..d31ac29 100644 --- a/project/main.py +++ b/project/main.py @@ -87,11 +87,10 @@ from obfuscation.obfuscation_engine import ObfuscationEngine #Detected? (Any overlapping segment?) #Deviation? (IoU) - +#TODO: Zusätzliche analysen für Journal: Konfidenz, Mehrere Modelle für Gesichtserkennung, Andere Datensets (in the wild) def main(): #TODO: die analysen vorher/nachher #TODO: gute techniken hinzufügen - #TODO: Techniken alle mit GPU print("Starting obfuscation platform") #1: Preprocess images and extract metadata @@ -109,8 +108,12 @@ def main(): obfuscation_engine.obfuscate_datasets(Config.filtered_output_directory, Config.obfuscated_output_directory, verbose=Config.verbose) #3: Extract metadata from obfuscated datasets + #TODO: Hier durch die obfuskierten Bilder iterieren # if Config.tasks["analysis"]: - + # image_meta = extractor.extract(img_file_path) + # meta_data_file_path = os.path.join(output_directory, os.path.basename(img_file_path).split(".")[0] + ".json") + # with open(meta_data_file_path, "w") as f: + # json.dump(image_meta.to_dict(), f, indent=2) if __name__ == '__main__': main() 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 80a25b1..48f43c4 100644 Binary files a/project/meta_data/__pycache__/meta_data_extractor.cpython-310.pyc and b/project/meta_data/__pycache__/meta_data_extractor.cpython-310.pyc differ diff --git a/project/meta_data/meta_data_extractor.py b/project/meta_data/meta_data_extractor.py index 0af4db1..ec7a2d6 100644 --- a/project/meta_data/meta_data_extractor.py +++ b/project/meta_data/meta_data_extractor.py @@ -75,8 +75,8 @@ class MetaExtractor: self.segmentor = YOLO(Config.seg_model_type) self.pose_estimator = YOLO(Config.pose_model_type) - self.face_detector = DeepFace.build_model(model_name=Config.face_model_type, task="face_detector") - # self._face_backend = Config.face_model_type + # self.face_detector = DeepFace.build_model(model_name=Config.face_model_type, task="face_detector") + self._face_backend = Config.face_model_type # MediaPipe self._mp_mesh = mp.solutions.face_mesh.FaceMesh(static_image_mode=True, refine_landmarks=True, max_num_faces=1) @@ -112,23 +112,19 @@ class MetaExtractor: # -- 1) Face detection (DeepFace) -------------------------------- try: - faces = self.face_detector.detect_faces(cv2.cvtColor(person_crop, cv2.COLOR_RGB2BGR)) - # print(faces) - # faces1 = DeepFace.extract_faces( - # cv2.cvtColor(person_crop, cv2.COLOR_RGB2BGR), - # detector_backend=Config.face_model_type, - # enforce_detection=True - # ) - - except ValueError: + # faces = self.face_detector.detect_faces(cv2.cvtColor(person_crop, cv2.COLOR_RGB2BGR)) + faces = DeepFace.extract_faces( + cv2.cvtColor(person_crop, cv2.COLOR_RGB2BGR), + detector_backend=Config.face_model_type, + enforce_detection=True + ) + except: faces = [] if faces: - fx0, fy0, fx1, fy1 = _facial_region_to_xyxy(faces[0]) - # print(fx0, fy0, fx1, fy1) - # fx0, fy0, fx1, fy1 = _deepface_bbox_to_xyxy(faces1[0]) - # print(fx0, fy0, fx1, fy1) - # exit() + # fx0, fy0, fx1, fy1 = _facial_region_to_xyxy(faces[0]) + fx0, fy0, fx1, fy1 = _deepface_bbox_to_xyxy(faces[0]) + face_bbox = [fx0 + px0, fy0 + py0, fx1 + px0, fy1 + py0] # crop the exact face for emotion / mesh diff --git a/project/obfuscation/__pycache__/obfuscation_engine.cpython-310.pyc b/project/obfuscation/__pycache__/obfuscation_engine.cpython-310.pyc index 3584e0a..1e0567c 100644 Binary files a/project/obfuscation/__pycache__/obfuscation_engine.cpython-310.pyc and b/project/obfuscation/__pycache__/obfuscation_engine.cpython-310.pyc differ diff --git a/project/obfuscation/obfuscation_engine.py b/project/obfuscation/obfuscation_engine.py index 9e7b489..b40d090 100644 --- a/project/obfuscation/obfuscation_engine.py +++ b/project/obfuscation/obfuscation_engine.py @@ -55,16 +55,17 @@ class ObfuscationEngine: return img - def obfuscate_datasets(self, path_to_filtered_dataset, output_path, verbose=False): - sub_dataset_folders = [os.path.join(path_to_filtered_dataset, sub_dataset_folder) for sub_dataset_folder in os.listdir(path_to_filtered_dataset)] + def obfuscate_datasets(self, path_to_filtered_datasets, output_path, verbose=False): + sub_dataset_folders = [os.path.join(path_to_filtered_datasets, sub_dataset_folder) for sub_dataset_folder in os.listdir(path_to_filtered_datasets)] + iterable = sub_dataset_folders if verbose: iterable = tqdm(sub_dataset_folders, desc="Obfuscating folders") - for sub_dataset_folder in iterable: - print(f"Obfuscating {sub_dataset_folder}") - image_meta_pairs = get_image_and_meta_file_paths(sub_dataset_folder) + for sub_dataset_folder_path in iterable: + print(f"Obfuscating {sub_dataset_folder_path}") + image_meta_pairs = get_image_and_meta_file_paths(sub_dataset_folder_path) for technique in self.obfuscation_techniques: - technique_path = os.path.join(output_path, technique.name()) + technique_path = os.path.join(output_path, os.path.basename(sub_dataset_folder_path), technique.name()) if not os.path.exists(technique_path): os.makedirs(technique_path) for image_path, meta_path in image_meta_pairs: