Spaces:
Running
on
L40S
Running
on
L40S
resize uploaded image to a 512 ratio making sure dimensions are divisible by 8
Browse files
webgui.py
CHANGED
@@ -160,7 +160,22 @@ def process_video(uploaded_img, uploaded_audio, width, height, length, seed, fac
|
|
160 |
|
161 |
#### face musk prepare
|
162 |
face_img = cv2.imread(uploaded_img)
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
face_mask = np.zeros((face_img.shape[0], face_img.shape[1])).astype('uint8')
|
165 |
det_bboxes, probs = face_detector.detect(face_img)
|
166 |
select_bbox = select_face(det_bboxes, probs)
|
|
|
160 |
|
161 |
#### face musk prepare
|
162 |
face_img = cv2.imread(uploaded_img)
|
163 |
+
|
164 |
+
# Get the original dimensions
|
165 |
+
original_height, original_width = face_img.shape[:2]
|
166 |
+
|
167 |
+
# Set the new width to 512 pixels
|
168 |
+
new_width = 512
|
169 |
+
|
170 |
+
# Calculate the new height with the same aspect ratio
|
171 |
+
new_height = int(original_height * (new_width / original_width))
|
172 |
+
|
173 |
+
# Round the new height to the nearest multiple of 8
|
174 |
+
new_height = round(new_height / 8) * 8
|
175 |
+
|
176 |
+
# Resize the image to the calculated dimensions
|
177 |
+
face_image = cv2.resize(face_img, (new_width, new_height))
|
178 |
+
|
179 |
face_mask = np.zeros((face_img.shape[0], face_img.shape[1])).astype('uint8')
|
180 |
det_bboxes, probs = face_detector.detect(face_img)
|
181 |
select_bbox = select_face(det_bboxes, probs)
|