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

mix_clips_batch issue #188

Open
pi19404 opened this issue Jul 17, 2024 · 2 comments
Open

mix_clips_batch issue #188

pi19404 opened this issue Jul 17, 2024 · 2 comments

Comments

@pi19404
Copy link

pi19404 commented Jul 17, 2024

I am using the function openwakeword.data.mix_clips_batch to mix foreground and background clips at desired snr levels .
And getting the below error .

for batch in tqdm(mixing_generator, total=N_total//batch_size):

File "/workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages/tqdm/std.py", line 1181, in iter
for obj in iterable:
File "/workspace/f1/openwakeword_eval/openwakeword/data.py", line 466, in mix_clips_batch
error_index = torch.from_numpy(np.where(mixed_clips_batch.max(dim=1) != 0)[0])
TypeError: _amax() got an unexpected keyword argument 'dim'

To resolve the issue I had to make changes in data.py file replace the line
error_index = torch.from_numpy(np.where(mixed_clips_batch.max(dim=1) != 0)[0])
with
error_index = torch.from_numpy(np.where(mixed_clips_batch.max(dim=1) != 0)[0])

@dscripka
Copy link
Owner

I'm not sure I understand the issue, it looks like your corrected line is the same?

Also, while mix_clips_batch still works, the official training process uses the augment_clips function, which should perform a bit better and be more efficient.

@markdewing
Copy link

I ran into this issue when running the training_models notebook. The issue is that torch max uses 'dim' as the keyword argument and numpy max uses 'axis'.

The variable 'mixed_clips_batch' is converted to a numpy array here:

mixed_clips_batch = (mixed_clips_batch.numpy()*32767).astype(np.int16)

The necessary change in line 466 is

-        error_index = torch.from_numpy(np.where(mixed_clips_batch.max(dim=1) != 0)[0])
+        error_index = torch.from_numpy(np.where(mixed_clips_batch.max(axis=1) != 0)[0])


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants