Martlgap commited on
Commit
678e0d3
·
1 Parent(s): cb74f9c

no upscaling

Browse files
Files changed (2) hide show
  1. app.py +9 -1
  2. tools/face_recognition.py +4 -10
app.py CHANGED
@@ -54,6 +54,14 @@ with st.sidebar:
54
  track_color=rgb(50, 50, 50),
55
  )
56
 
 
 
 
 
 
 
 
 
57
  st.markdown("## Webcam & Stream")
58
  resolution = st.selectbox(
59
  "Webcam Resolution",
@@ -165,7 +173,7 @@ def video_frame_callback(frame: av.VideoFrame) -> av.VideoFrame:
165
 
166
  # Draw detections
167
  start = time.time()
168
- frame = draw_detections(frame, detections)
169
  stats = stats._replace(drawing=(time.time() - start) * 1000)
170
 
171
  # Convert frame back to av.VideoFrame
 
54
  track_color=rgb(50, 50, 50),
55
  )
56
 
57
+ upscale = st_toggle_switch(
58
+ "Upscale",
59
+ key="upscale",
60
+ default_value=True,
61
+ active_color=rgb(255, 75, 75),
62
+ track_color=rgb(50, 50, 50),
63
+ )
64
+
65
  st.markdown("## Webcam & Stream")
66
  resolution = st.selectbox(
67
  "Webcam Resolution",
 
173
 
174
  # Draw detections
175
  start = time.time()
176
+ frame = draw_detections(frame, detections, upscale=upscale)
177
  stats = stats._replace(drawing=(time.time() - start) * 1000)
178
 
179
  # Convert frame back to av.VideoFrame
tools/face_recognition.py CHANGED
@@ -149,13 +149,7 @@ def process_gallery(files, face_detection_model, face_recognition_model):
149
 
150
 
151
  def draw_detections(
152
- frame, detections, bbox=True, landmarks=True, name=True, upscale=True
153
- ):
154
- if upscale:
155
- frame = cv2.resize(
156
- frame, (1920, 1080)
157
- ) # Upscale frame for better visualization
158
-
159
  shape = np.asarray(frame.shape[:2][::-1])
160
 
161
  for detection in detections:
@@ -165,7 +159,7 @@ def draw_detections(
165
  cv2.circle(
166
  frame,
167
  (np.asarray(landmark) * shape).astype(int),
168
- 5,
169
  (0, 0, 255),
170
  -1,
171
  )
@@ -200,8 +194,8 @@ def draw_detections(
200
  int(detection.bbox[0] * shape[0] + shape[0] // 400),
201
  int(detection.bbox[1] * shape[1] - shape[1] // 100),
202
  ),
203
- cv2.FONT_HERSHEY_SIMPLEX,
204
- 1,
205
  (0, 0, 0),
206
  2,
207
  )
 
149
 
150
 
151
  def draw_detections(
152
+ frame, detections, bbox=True, landmarks=True, name=True):
 
 
 
 
 
 
153
  shape = np.asarray(frame.shape[:2][::-1])
154
 
155
  for detection in detections:
 
159
  cv2.circle(
160
  frame,
161
  (np.asarray(landmark) * shape).astype(int),
162
+ 2,
163
  (0, 0, 255),
164
  -1,
165
  )
 
194
  int(detection.bbox[0] * shape[0] + shape[0] // 400),
195
  int(detection.bbox[1] * shape[1] - shape[1] // 100),
196
  ),
197
+ cv2.LINE_AA,
198
+ 0.5,
199
  (0, 0, 0),
200
  2,
201
  )