Spaces:
Sleeping
Sleeping
Commit
·
10ac76e
1
Parent(s):
d64aa71
Refactor mask loading method in ImageProcessor
Browse files
soundimage/utils/image_processor.py
CHANGED
@@ -28,7 +28,12 @@ https://stackoverflow.com/questions/23853632/which-kind-of-interpolation-best-fo
|
|
28 |
"""
|
29 |
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
|
34 |
class ImageProcessor:
|
@@ -61,12 +66,8 @@ class ImageProcessor:
|
|
61 |
# self.face_mesh = mp.solutions.face_mesh.FaceMesh(static_image_mode=True) # Process single image
|
62 |
self.face_mesh = None
|
63 |
self.fa = None
|
64 |
-
|
65 |
-
|
66 |
-
mask_image = cv2.cvtColor(mask_image, cv2.COLOR_BGR2RGB)
|
67 |
-
mask_image = cv2.resize(mask_image, (resolution, resolution), interpolation=cv2.INTER_AREA) / 255.0
|
68 |
-
mask_image = rearrange(torch.from_numpy(mask_image), "h w c -> c h w")
|
69 |
-
return mask_image
|
70 |
|
71 |
def detect_facial_landmarks(self, image: np.ndarray):
|
72 |
height, width, _ = image.shape
|
|
|
28 |
"""
|
29 |
|
30 |
|
31 |
+
def load_fixed_mask(resolution: int, mask_path: str) -> torch.Tensor:
|
32 |
+
mask_image = cv2.imread(mask_path)
|
33 |
+
mask_image = cv2.cvtColor(mask_image, cv2.COLOR_BGR2RGB)
|
34 |
+
mask_image = cv2.resize(mask_image, (resolution, resolution), interpolation=cv2.INTER_AREA) / 255.0
|
35 |
+
mask_image = rearrange(torch.from_numpy(mask_image), "h w c -> c h w")
|
36 |
+
return mask_image
|
37 |
|
38 |
|
39 |
class ImageProcessor:
|
|
|
66 |
# self.face_mesh = mp.solutions.face_mesh.FaceMesh(static_image_mode=True) # Process single image
|
67 |
self.face_mesh = None
|
68 |
self.fa = None
|
69 |
+
|
70 |
+
|
|
|
|
|
|
|
|
|
71 |
|
72 |
def detect_facial_landmarks(self, image: np.ndarray):
|
73 |
height, width, _ = image.shape
|