Added initial code to load data

This commit is contained in:
2025-05-07 16:25:07 +02:00
parent fbe4a4580e
commit 8da0a3c4cf
5 changed files with 53 additions and 3 deletions
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
from typing import Dict, List, Sequence, Union
import os
class DatasetLoader:
def __init__(self, path: str):
self.path=path
#This function loads the data from the given path and returns a dict with entries for each subfolder in the given path the folder name and strings
def load_data(self) -> Dict[str, List[str]]:
subdirs = [sub for sub in os.listdir(self.path) if os.path.isdir(os.path.join(self.path, sub))]
data_dict = {}
for subdir in subdirs:
data_dict[subdir] = []
for file in os.listdir(os.path.join(self.path, subdir)):
if file.endswith((".jpg", ".jpeg", ".png")):
data_dict[subdir].append(os.path.join(self.path, subdir, file))
return data_dict
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

+36 -3
View File
@@ -1,3 +1,4 @@
from data_loader import DatasetLoader
##Steps:
#Configure Pipeline (e.g. region, datasets, amount of images per dataset, analysis scopes)
@@ -10,7 +11,7 @@
###Obfuscate data (with current method)
###Analyze data (values after obfuscation)
###Evaluate (analyze e.g. delta/error for before vs after, and aggregate results)
###Visualize
###Visualize Statistics
##Motivation
@@ -35,7 +36,22 @@
#hier gehts weiter usw.
##Metrics##
#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
#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
@@ -77,6 +93,23 @@
def main():
print("Starting obfuscation platform")
data_path = "datasets/"
data_loader = DatasetLoader(data_path)
data_paths = data_loader.load_data() #This variable contains a dict with the filenames for each dataset
print(data_paths)
#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()
main()