diff --git a/project/__pycache__/config.cpython-310.pyc b/project/__pycache__/config.cpython-310.pyc index 8b4d3e1..47c5910 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 d5766e7..01547de 100644 --- a/project/config.py +++ b/project/config.py @@ -6,6 +6,7 @@ from obfuscation.swap import Swap #from obfuscation.fams import FAMS from obfuscation.pixelation import Pixelation from obfuscation.style import Style +from obfuscation.synthetic import Synthetic class Config: @@ -39,6 +40,7 @@ class Config: debug_show_preprocessing=False obfuscation_techniques=[ + Synthetic(), Style(), Swap(), Blackening(), diff --git a/project/models/ganonymization/face_obfuscator.py b/project/models/ganonymization/face_obfuscator.py index dc35560..f0d8e9b 100644 --- a/project/models/ganonymization/face_obfuscator.py +++ b/project/models/ganonymization/face_obfuscator.py @@ -43,14 +43,6 @@ class GANONYMIZATION(): self.padding_resize = ZeroPaddingResize(self.img_size) self.pix2pix_transformer = Pix2PixTransformer(model_file, self.img_size, self.device) - #def obfuscate(self, face_img): - # face_img = self.padding_resize(face_img) - # face_img = self.landmark_model(face_img) - # face_img = self.pix2pix_transformer(face_img) - # face_img = torch.squeeze(face_img) - # face_img = (face_img + 1) / 2 #TODO what is this? - # return face_img - def obfuscate(self, face_img): orig_h, orig_w = face_img.shape[:2] @@ -70,28 +62,26 @@ class GANONYMIZATION(): face = cv2.cvtColor(face, cv2.COLOR_BGR2RGB) #mask = np.any(face > 0, axis=2) - # build mask: everything that wasn’t black padding gray = cv2.cvtColor(face, cv2.COLOR_BGR2GRAY) _, mask = cv2.threshold(gray, 1, 255, cv2.THRESH_BINARY) - #result = face_img.copy() + result = face_img.copy() #result[mask] = face[mask] center = (orig_w // 2, orig_h // 2) result = cv2.seamlessClone(face, face_img, mask, center, flags=cv2.NORMAL_CLONE) result = cv2.cvtColor(result, cv2.COLOR_RGB2BGR) - return result app = FastAPI() ganonymization = None -image_processing_path = "C:/Users/bijan/Desktop/obfuscation_platform/project/models/ganonymization/image_cache/" +image_processing_path = "/mnt/c/Users/bijan/Desktop/obfuscation_platform/project/models/ganonymization/image_cache/" @app.get("/init") def init(): try: - print("initiating face_anon_simple") + print("initiating ganonymization") global ganonymization ganonymization = GANONYMIZATION() diff --git a/project/models/ganonymization/image_cache/obfuscated_face.jpg b/project/models/ganonymization/image_cache/obfuscated_face.jpg new file mode 100644 index 0000000..3155c1e Binary files /dev/null and b/project/models/ganonymization/image_cache/obfuscated_face.jpg differ diff --git a/project/obfuscation/synthetic.py b/project/obfuscation/synthetic.py index f33a02f..5c00c78 100644 --- a/project/obfuscation/synthetic.py +++ b/project/obfuscation/synthetic.py @@ -6,22 +6,17 @@ import cv2 from obfuscation.base_obfuscation_technique import ObfuscationTechnique import requests -#NOTE: Run the server with WSL and conda obfuscation_platform_face_anon_simple +#NOTE: Run the server with WSL and conda obfuscation_platform_ganonymization class Synthetic(ObfuscationTechnique): """ Replace face with generated face """ - - #TODO DEEP PRIVACY2 einbinden - #TODO Problem ist, dass wir hier - - def __init__(self): - print("synthetic not active") - # self.image_processing_path = "C:/Users/bijan/Desktop/obfuscation_platform/project/models/deep_privacy2/image_cache/" - # resp = requests.get(f"http://127.0.0.1:8000/init", timeout=120) - # resp.raise_for_status() + #print("synthetic not active") + self.image_processing_path = "C:/Users/bijan/Desktop/obfuscation_platform/project/models/ganonymization/image_cache/" + resp = requests.get(f"http://127.0.0.1:8000/init", timeout=120) + resp.raise_for_status() def obfuscate(self, face_roi_img_bgr: np.ndarray) -> np.ndarray: