Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cropping_mode to DelayedAggregation #105

Merged
merged 5 commits into from
Oct 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/diart/blocks/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class DelayedAggregation:
"mean": simple average
"hamming": average weighted by the Hamming window values (aligned to the buffer)
"any": no aggregation, pick the first overlapping window
cropping_mode: ("strict", "loose", "center"), optional
Defines the cropping mode. Defaults to "loose".
juanmc2005 marked this conversation as resolved.
Show resolved Hide resolved

Example
--------
Expand Down Expand Up @@ -130,10 +132,12 @@ def __init__(
step: float,
latency: Optional[float] = None,
strategy: Literal["mean", "hamming", "first"] = "hamming",
cropping_mode: Literal["strict", "loose", "center"] = "loose"
juanmc2005 marked this conversation as resolved.
Show resolved Hide resolved
):
self.step = step
self.latency = latency
self.strategy = strategy
self.cropping_mode = cropping_mode
bhigy marked this conversation as resolved.
Show resolved Hide resolved

if self.latency is None:
self.latency = self.step
Expand All @@ -159,7 +163,7 @@ def _prepend(
num_frames = output_window.data.shape[0]
first_region = Segment(0, output_region.end)
first_output = buffers[0].crop(
first_region, fixed=first_region.duration
first_region, mode=self.cropping_mode, fixed=first_region.duration
)
first_output[-num_frames:] = output_window.data
resolution = output_region.end / first_output.shape[0]
Expand Down