Binta26 commited on
Commit
248136b
·
verified ·
1 Parent(s): 0c5c12e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -82,6 +82,7 @@ confidence_threshold = st.sidebar.slider("Confidence threshold", 0.1, 1.0, 0.4)
82
  min_box_area = st.sidebar.number_input("Min box area (px²)", min_value=0, value=1600, step=100)
83
  min_track_hits = st.sidebar.number_input("Min track hits (YOLO only)", min_value=1, value=5, step=1)
84
  shape_refine = st.sidebar.checkbox("Reclassify tall 'car' as person", value=True)
 
85
  person_car_ratio = st.sidebar.slider("Person/Car ratio (H/W)", 0.8, 2.0, 1.2, 0.05)
86
 
87
  if not selected_classes:
@@ -182,7 +183,11 @@ if uploaded_file is not None:
182
  ret, frame = cap.read()
183
  if not ret:
184
  break
185
-
 
 
 
 
186
  timestamp = round(frame_idx / fps, 3)
187
  results = model.track(
188
  frame, persist=True, tracker="bytetrack.yaml",
@@ -312,6 +317,11 @@ if uploaded_file is not None:
312
  if not ret:
313
  break
314
 
 
 
 
 
 
315
  timestamp = round(frame_idx / fps, 3)
316
  img_rgb = cv.cvtColor(frame, cv.COLOR_BGR2RGB)
317
  tensor = TF.to_tensor(img_rgb).unsqueeze(0).to(device)
 
82
  min_box_area = st.sidebar.number_input("Min box area (px²)", min_value=0, value=1600, step=100)
83
  min_track_hits = st.sidebar.number_input("Min track hits (YOLO only)", min_value=1, value=5, step=1)
84
  shape_refine = st.sidebar.checkbox("Reclassify tall 'car' as person", value=True)
85
+ frame_skip = st.sidebar.slider("Process every N frame", 1, 10, 2)
86
  person_car_ratio = st.sidebar.slider("Person/Car ratio (H/W)", 0.8, 2.0, 1.2, 0.05)
87
 
88
  if not selected_classes:
 
183
  ret, frame = cap.read()
184
  if not ret:
185
  break
186
+
187
+ if frame_idx % frame_skip !=0:
188
+ frame_idx += 1
189
+ continue
190
+
191
  timestamp = round(frame_idx / fps, 3)
192
  results = model.track(
193
  frame, persist=True, tracker="bytetrack.yaml",
 
317
  if not ret:
318
  break
319
 
320
+ if frame_idx % frame_skip != 0:
321
+ frame_idx +=1
322
+ continue
323
+
324
+
325
  timestamp = round(frame_idx / fps, 3)
326
  img_rgb = cv.cvtColor(frame, cv.COLOR_BGR2RGB)
327
  tensor = TF.to_tensor(img_rgb).unsqueeze(0).to(device)