Skip to content

Commit

Permalink
Optimize frame storage in process_video function
Browse files Browse the repository at this point in the history
- Modify the handling of  to keep only the most recent frames required for processing by limiting the length of the list to .
- This prevents unnecessary memory usage when processing long videos by discarding older frames that are no longer needed.
  • Loading branch information
healthonrails committed Nov 13, 2024
1 parent 185b177 commit 689c7f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion annolid/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ def _select_sam_model_name(self):

def stop_prediction(self):
# Emit the stop signal to signal the prediction thread to stop
self.pred_worker.stop()
self.pred_worker.stop_signal.emit()
self.seg_pred_thread.quit()
self.seg_pred_thread.wait()
self.stepSizeWidget.predict_button.setText(
Expand Down
2 changes: 2 additions & 0 deletions annolid/tracker/cotracker/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def process_video(self,
f"Tracking frame {i}, {pred_tracks.shape}, {pred_visibility.shape}")
is_first_step = False
window_frames.append(frame)
if len(window_frames) > self.model.step * 2:
window_frames = window_frames[-self.model.step * 2:]

pred_tracks, pred_visibility = self.process_step(
window_frames[-(i % self.model.step) - self.model.step - 1:],
Expand Down

0 comments on commit 689c7f3

Please sign in to comment.