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

improve: skip validation chunks with too many speakers #1762

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
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
13 changes: 6 additions & 7 deletions pyannote/audio/tasks/segmentation/speaker_diarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,6 @@ def prepare_chunk(self, file_id: int, start_time: float, duration: float):
labels = list(np.unique(chunk_annotations[label_scope_key]))
num_labels = len(labels)

if num_labels > self.max_speakers_per_chunk:
pass

# initial frame-level targets
num_frames = self.model.num_frames(
round(duration * self.model.hparams.sample_rate)
Expand Down Expand Up @@ -679,9 +676,11 @@ def validation_step(self, batch, batch_idx: int):
waveform = batch["X"]
# (batch_size, num_channels, num_samples)

# TODO: should we handle validation samples with too many speakers
# waveform = waveform[keep]
# target = target[keep]
# drop samples that contain too many speakers
num_speakers: torch.Tensor = torch.sum(torch.any(target, dim=1), dim=1)
keep: torch.Tensor = num_speakers <= self.max_speakers_per_chunk
target = target[keep]
waveform = waveform[keep]

# forward pass
prediction = self.model(waveform)
Expand Down Expand Up @@ -721,7 +720,7 @@ def validation_step(self, batch, batch_idx: int):
)

self.model.log(
"loss/val/segmentation",
f"loss/val/segmentation/{self.max_speakers_per_chunk:d}speakers",
seg_loss,
on_step=False,
on_epoch=True,
Expand Down
Loading