Files
obfuscation_platform/project/main.py
T

139 lines
5.9 KiB
Python

import os
from data_loader import DatasetLoader
from image_preprocessor import DataPreprocessor
##Steps:
#Configure Pipeline (e.g. region, datasets, amount of images per dataset, analysis scopes)
#For each obfuscation method
##For each dataset
###Load raw data (image-wise)
###Preprocess data and save (according to given criteria)
###Analyze data (values before obfuscation)
###Obfuscate data (with current method)
###Analyze data (values after obfuscation)
###Evaluate (analyze e.g. delta/error for before vs after, and aggregate results)
###Visualize Statistics
##Motivation
#Bilder und Videos sind daten, welche viele semantische informationen in sich tragen können
#Entsprechend ist CV so beliebt, weil sich damit mannigfaltig viele aufgaben erledigen lassen wie A, B, C
#Neben den Informationen die für die aufgabe relevant sind, auch andere Informationen abgebildet sind.
#Die ist besonders dann problematisch, wenn beispielsweise person erkennbar abgebildet sind und bilder möglicherweise veröffentlich werden sollen.
#Entsprechend gibt es die möglichkeit, bilder nachträglich zu bearbeiten um die person zu anonymisieren.
#Typischerweise wird dabei eine Verschleierung des Gesichts vorgenommen.
#VERSCHLEIERUNG NICHT GUT - MACHT NATÜRLICHKEIT des Bildes kaputt
#NATÜRLICHKEIT IST SCHWER MESSBAR
#IMPACT AUF TECHNISCHE NUTZBARKEIT NACH VERSCHLEIERUNG
#EINERSEITS STARKE LOKALE ABWEICHUNGEN
#GESICHT KÖNNTE NICHT IDENTIFIZIERBAR SEIN
#HOWEVER DURCH TECHNIK WIE SCHWARZEN BALKEN KÖNNTE ÜBERHAUPT KEIN GESICHT ZU SEHEN SEIN
#ANDERERSEITS ES KÖNNTE GESICHT DA SEIN, ABER XXX INFORMATIONEN WIE EMOTION ODER
#ODER AUCH AUF REESTLICHEN KÖRPER KÖRPER
#IN DIESEM PAPER WOLLEN WIR QUANTIFIZIEREN WIE NATÜRLICH BILD NACH VERSCHLEIERUNG
#DAMIT MEINEN WIR INTEGRITÄT IN BEZUG AUF TECHNISCHE NUTZBARKEIT
#IMPACT AUF gesicht, körper, global
#hier gehts weiter usw.
#TODO ODER EINFACH Alles nehmen einfach: Hat Mensch, Face und andere Objekte
#Detektion Gesichter + Body + Min. 1 anderes Objekt haben
#Alle 3 Modelle müssen gut funktionieren
##Metrics for analysis##
#Impact on facial attributes:
#Detection #TODO: Face detection model
#Bounding box (Any/best overlapping box?) FaceDetectionAccuracy = 0.0 - 1.0
#If face bounding box detected
#Bounding box deviation (IoU) FaceBoundingBoxSimilarity = 0.0-1.0
#Facial keypoints #TODO: Facial keypoint, MediaPipe
#Detected? (Visibility score delta) FacialKeypointVisibilitySimilarity = 0.0-1.0
#Deviation? (Coordinate deviation) FacialKeypointCoordinateSimilarity = 0.0-1.0
#Emotion #TODO: Emotion recognition model
#Detected? (Same top1 emotion?) EmotionRecognitionAccuracy = 0.0-1.0
#Vector? (Euclidean distance) EmotionVectorSimilarity = 0.0-1.0
#Face Matching #TODO: Face recognition model
#Same person? (Binary) AnonymizationSuccess = 0.0-1.0
#Embeddings similarity? (Cosine similarity, or other distance) FaceEmbeddingDeviation = 0.0-1.0
#Impact on naturalness of whole person:
#Detection #TODO: YOLOv12
#Bounding box
#Detected? (Any/best overlapping box?) BodyDetectionAccuracy = 0.0-1.0
#If body bounding box detected
#Bounding box deviation? (IoU) BodyBoundingBoxSimilarity = 0.0-1.0
#Segment #TODO: YOLOv12
#Detected? (Any/best overlapping segment?) BodySegmentDetectionAccuracy = 0.0-1.0
#Deviation? (IoU) BodySegmentSimilarity = 0.0-1.0
#Keypoint #TODO: MediaPipe (body)
#Detected? (Visibility score delta)
#Deviation? (Coordinate deviation)
#Global impact (all other objects)
#Detection #TODO: YOLOv12
#Bounding box
#Detected? (Any overlapping box?)
#If any object bounding box detected
#Deviation? (IoU)
#Segment
#Detected? (Any overlapping segment?)
#Deviation? (IoU)
def main():
print("Starting obfuscation platform")
#First: load the image datasets
raw_dataset_path = "datasets/raw/"
data_loader = DatasetLoader(raw_dataset_path)
raw_datasets_dict = data_loader.load_data() #This variable contains a dict with the filenames for each dataset
#Second: filter the image data and extract meta data
base_output_directory = "datasets/filtered/"
for dataset_name, image_paths in raw_datasets_dict.items():
data_preprocessor = DataPreprocessor(image_paths)
output_directory = os.path.join(base_output_directory, dataset_name)
data_preprocessor.preprocess_images(output_directory)
#TODO: Datenset filtern und Bilder mit Metadaten speichern. Für jedes Bild gilt:
#1. Hat Bild Bobx mit min. 1 anderes Objekt als Mensch?
#1.1 Gibt es zu Bbox Segment?
#2. Hat Bild Bbox mit Mensch?
#2.1 Hat Mensch Segment?
#2.2 Extrahiere Keypoints
#3. Hat Mensch Bbox Gesicht Bbox?
#3.3 Hat
# USW
# Based on that i want to extract meta data:
# -The bounding and segment of the other objects (with yolo11-seg)
# -The segment and boundingbox of the persons (with yolo11-seg)
# -The body keypoints of the persons
# -The Face bounding box of the persons (idk which model, please recommend one)
# -The Face keypoints of the persons (with mediapipe)
# -The emotion of the person
#TODO: filter data by criteria; Like N-Images
#configure pipeline
#load data
#pre-process data //create dataset based on specific criteria
#Run analysis
#Analyze data (values before obfuscation)
#Obfuscate data (with current method)
#Analyze data (values after obfuscation)
#Evaluate (analyze e.g. delta/error for before vs after, and aggregate results)
#Visualize Statistics
if __name__ == '__main__':
main()