Skip to content

Refactor code #4

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
import random
from librosa import resample
from librosa.effects import split
from scipy.stats import special_ortho_group
from scipy.io import wavfile
import scipy
import pandas as pd
import noisereduce as nr
from tqdm import tqdm


Expand Down
26 changes: 17 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
from wav2pos import wav2pos
import torch.optim as optim
from data import LibriSpeechLocations, DelaySimulatorDataset, remove_silence
import scipy
import torch.utils.data as data_utils
import importlib
import argparse
import os
from timm.optim import optim_factory
from timm.optim import param_groups_weight_decay
from tqdm import tqdm
from warmup_scheduler import GradualWarmupScheduler
import datetime
Expand Down Expand Up @@ -115,6 +114,15 @@ def log_print(*kwargs):

mic_locs = np.stack([mic1, mic2, mic3, mic4, mic5, mic6]).transpose(1, 2, 0)

# # For more than 6 microphones (`num_mics` in `cfg.py`), you will need to add
# # more microphone positions. For example, you can add:
# mic7 = np.random.uniform(
# [0, 0, room_len_z/2], [room_len_x, room_len_y, room_len_z/2], coord_size)
# mic8 = np.random.uniform(
# [room_len_x/2, 0, 0], [room_len_x/2, room_len_y, room_len_z], coord_size)

# # And update `mic_locs`:
# mic_locs = np.stack([mic1, mic2, mic3, mic4, mic5, mic6, mic7, mic8]).transpose(1, 2, 0)

log_print("Data prep started...")
data_set = LibriSpeechLocations(source_locs, mic_locs, split="test-clean", random_source_pos=True,
Expand Down Expand Up @@ -223,7 +231,7 @@ def log_print(*kwargs):
# Create optimizer
no_weight_decay_list = {'norm', 'enc_audio_modality', 'enc_loc_modality',
'dec_audio_modality', 'dec_loc_modality', 'pos_embed', 'decoder_pos_embed', 'mask_token'}
param_groups = optim_factory.param_groups_weight_decay(
param_groups = param_groups_weight_decay(
model, cfg.wd, no_weight_decay_list)
optimizer = optim.AdamW(param_groups, lr=cfg.lr)
scheduler = optim.lr_scheduler.CosineAnnealingLR(
Expand Down Expand Up @@ -336,12 +344,12 @@ def log_print(*kwargs):
scheduler.step()

outstr = 'Train epoch, %d, audio loss, %.6f, loc loss, %.6f, tdoa loss, %.6f, loc MAE [cm], %.6f, loc acc, %.6f, lr, %.6f' % (e,
curr_loss_audio,
curr_loss_locs,
curr_loss_tdoas,
curr_mae * 100.0,
curr_acc,
optimizer.param_groups[0]['lr'])
curr_loss_audio,
curr_loss_locs,
curr_loss_tdoas,
curr_mae * 100.0,
curr_acc,
optimizer.param_groups[0]['lr'])

log_string(outstr+'\n')

Expand Down
Loading