roychao19477 commited on
Commit
5a10a66
·
1 Parent(s): a89dde6

Update module

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -146,6 +146,7 @@ def extract_faces(video_file):
146
  for box in results.boxes:
147
  # version 1
148
  # x1, y1, x2, y2 = map(int, box.xyxy[0])
 
149
  # version 2
150
  h, w, _ = frame.shape
151
  x1, y1, x2, y2 = box.xyxy[0].cpu().numpy()
@@ -158,7 +159,11 @@ def extract_faces(video_file):
158
  y1 = int(max(0, y1 - dy))
159
  x2 = int(min(w, x2 + dx))
160
  y2 = int(min(h, y2 + dy))
161
- face_crop = frame[y1:y2, x1:x2]
 
 
 
 
162
  if face_crop.size != 0:
163
  resized = cv2.resize(face_crop, (224, 224))
164
  frames.append(resized)
 
146
  for box in results.boxes:
147
  # version 1
148
  # x1, y1, x2, y2 = map(int, box.xyxy[0])
149
+
150
  # version 2
151
  h, w, _ = frame.shape
152
  x1, y1, x2, y2 = box.xyxy[0].cpu().numpy()
 
159
  y1 = int(max(0, y1 - dy))
160
  x2 = int(min(w, x2 + dx))
161
  y2 = int(min(h, y2 + dy))
162
+ # Added for v3
163
+ shift_down = int(0.1 * (y2 - y1))
164
+ y1 = int(min(max(0, y1 + shift_down), h))
165
+ y2 = int(min(max(0, y2 + shift_down), h))
166
+ face_crop = frame[y1:y2, x1:x2]
167
  if face_crop.size != 0:
168
  resized = cv2.resize(face_crop, (224, 224))
169
  frames.append(resized)