Spaces:
Paused
Paused
Commit ·
5332aaa
1
Parent(s): 35b86ef
tune: increase face crop padding to 0.6 to include full hair area
Browse files
app/services/prediction_service.py
CHANGED
|
@@ -79,10 +79,7 @@ class MultiModelPredictor:
|
|
| 79 |
|
| 80 |
self.executor = ThreadPoolExecutor(max_workers=os.cpu_count() or 4)
|
| 81 |
|
| 82 |
-
self._lock = threading.Lock()
|
| 83 |
-
|
| 84 |
-
# Initialize OpenCV Face and Eye detectors
|
| 85 |
-
# Removed from __init__ for thread-safety. Will instantiate per-request.
|
| 86 |
|
| 87 |
def _align_and_crop_face(self, image_np):
|
| 88 |
"""
|
|
@@ -125,6 +122,7 @@ class MultiModelPredictor:
|
|
| 125 |
float((eye_right[0] + eye_left[0]) / 2),
|
| 126 |
float((eye_right[1] + eye_left[1]) / 2),
|
| 127 |
)
|
|
|
|
| 128 |
M = cv2.getRotationMatrix2D(eye_center, float(angle), 1.0)
|
| 129 |
image_np = cv2.warpAffine(
|
| 130 |
image_np,
|
|
@@ -140,8 +138,8 @@ class MultiModelPredictor:
|
|
| 140 |
0
|
| 141 |
]
|
| 142 |
|
| 143 |
-
pad_w = int(w * 0.
|
| 144 |
-
pad_h = int(h * 0.
|
| 145 |
|
| 146 |
y1 = max(0, y - pad_h)
|
| 147 |
y2 = min(image_np.shape[0], y + h + pad_h)
|
|
|
|
| 79 |
|
| 80 |
self.executor = ThreadPoolExecutor(max_workers=os.cpu_count() or 4)
|
| 81 |
|
| 82 |
+
self._lock = threading.Lock().
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
def _align_and_crop_face(self, image_np):
|
| 85 |
"""
|
|
|
|
| 122 |
float((eye_right[0] + eye_left[0]) / 2),
|
| 123 |
float((eye_right[1] + eye_left[1]) / 2),
|
| 124 |
)
|
| 125 |
+
|
| 126 |
M = cv2.getRotationMatrix2D(eye_center, float(angle), 1.0)
|
| 127 |
image_np = cv2.warpAffine(
|
| 128 |
image_np,
|
|
|
|
| 138 |
0
|
| 139 |
]
|
| 140 |
|
| 141 |
+
pad_w = int(w * 0.6)
|
| 142 |
+
pad_h = int(h * 0.6)
|
| 143 |
|
| 144 |
y1 = max(0, y - pad_h)
|
| 145 |
y2 = min(image_np.shape[0], y + h + pad_h)
|