callcut.io.intervals_to_frame_labels๐
- callcut.io.intervals_to_frame_labels(intervals, times)[source]๐
Convert annotation intervals to per-frame binary labels.
For each frame, the label is
1.0if the frameโs time falls within any annotation interval, and0.0otherwise.- Parameters:
- Returns:
- labels
Tensorof shape(n_frames,) Binary labels (
0.0or1.0) for each frame.
- labels
Examples
>>> import numpy as np >>> import torch >>> intervals = np.array([[1.0, 2.0], [3.5, 4.0]]) >>> times = torch.linspace(0, 5, 100) >>> labels = intervals_to_frame_labels(intervals, times) >>> labels.shape torch.Size([100]) >>> labels.sum() # frames within [1,2] and [3.5,4] tensor(30.)