32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import os
|
|
|
|
import numpy as np
|
|
import cv2
|
|
|
|
from obfuscation.base_obfuscation_technique import ObfuscationTechnique
|
|
import requests
|
|
|
|
|
|
#NOTE: Run the server with WSL conda obfuscation_platform_p38
|
|
class Style(ObfuscationTechnique):
|
|
"""
|
|
Replace face with generated face
|
|
"""
|
|
def __init__(self):
|
|
print("Style not activated")
|
|
# print("Style activated")
|
|
# self.image_processing_path = "C:/Users/bijan/Desktop/obfuscation_platform/project/models/vtoonify/image_cache/"
|
|
# resp = requests.get("http://127.0.0.1:8002/init", timeout=180)
|
|
# resp.raise_for_status()
|
|
|
|
|
|
def obfuscate(self, face_roi_img_bgr: np.ndarray, face_mask) -> np.ndarray:
|
|
cv2.imwrite(os.path.join(self.image_processing_path, "face.png"), face_roi_img_bgr)
|
|
cv2.imwrite(os.path.join(self.image_processing_path, "mask.png"), face_mask)
|
|
resp = requests.get("http://127.0.0.1:8002/obfuscate", timeout=180)
|
|
resp.raise_for_status()
|
|
obfuscated_face = cv2.imread(os.path.join(self.image_processing_path, "obfuscated_face.png"))
|
|
return obfuscated_face
|
|
|
|
def name(self):
|
|
return "Style" |