From d99d0c29a906f10d663b844d1e4398cfc91e860e Mon Sep 17 00:00:00 2001 From: pnorridge <37704783+pnorridge@users.noreply.github.com> Date: Wed, 26 Jan 2022 17:47:59 +0000 Subject: [PATCH 1/4] Update train_classification.py Loading pre-trained weights did not overwrite the existing weight set. --- train_classification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train_classification.py b/train_classification.py index a41f0a8..b014258 100644 --- a/train_classification.py +++ b/train_classification.py @@ -44,7 +44,7 @@ def main(args): print_info_message('Loading pretrained basenet model weights') model_dict = model.state_dict() - overlap_dict = {k: v for k, v in model_dict.items() if k in pretrained_dict} + overlap_dict = {k: v for k, v in pretrained_dict if k in model_dict.items()} total_size_overlap = 0 for k, v in enumerate(overlap_dict): From 9c2613c00dda5859edda49954814eecf86392158 Mon Sep 17 00:00:00 2001 From: pnorridge <37704783+pnorridge@users.noreply.github.com> Date: Sat, 29 Jan 2022 14:58:00 +0000 Subject: [PATCH 2/4] Fix for different input channel count Updated to ensure that different numbers of input channels can be handled without error. (Shortcut connection configuration assumed this was always equal to config_inp_reinf.) --- model/classification/espnetv2.py | 8 ++++---- nn_layers/eesp.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/classification/espnetv2.py b/model/classification/espnetv2.py index 41b51c9..af76135 100644 --- a/model/classification/espnetv2.py +++ b/model/classification/espnetv2.py @@ -57,19 +57,19 @@ def __init__(self, args): self.level1 = CBR(channels_in, out_channel_map[0], 3, 2) # 112 L1 - self.level2_0 = DownSampler(out_channel_map[0], out_channel_map[1], k=K[0], r_lim=recept_limit[0], reinf=self.input_reinforcement) # out = 56 + self.level2_0 = DownSampler(out_channel_map[0], out_channel_map[1], input2_nin=channels_in, k=K[0], r_lim=recept_limit[0], reinf=self.input_reinforcement) # out = 56 - self.level3_0 = DownSampler(out_channel_map[1], out_channel_map[2], k=K[1], r_lim=recept_limit[1], reinf=self.input_reinforcement) # out = 28 + self.level3_0 = DownSampler(out_channel_map[1], out_channel_map[2], input2_nin=channels_in, k=K[1], r_lim=recept_limit[1], reinf=self.input_reinforcement) # out = 28 self.level3 = nn.ModuleList() for i in range(reps_at_each_level[1]): self.level3.append(EESP(out_channel_map[2], out_channel_map[2], stride=1, k=K[2], r_lim=recept_limit[2])) - self.level4_0 = DownSampler(out_channel_map[2], out_channel_map[3], k=K[2], r_lim=recept_limit[2], reinf=self.input_reinforcement) #out = 14 + self.level4_0 = DownSampler(out_channel_map[2], out_channel_map[3], input2_nin=channels_in, k=K[2], r_lim=recept_limit[2], reinf=self.input_reinforcement) #out = 14 self.level4 = nn.ModuleList() for i in range(reps_at_each_level[2]): self.level4.append(EESP(out_channel_map[3], out_channel_map[3], stride=1, k=K[3], r_lim=recept_limit[3])) - self.level5_0 = DownSampler(out_channel_map[3], out_channel_map[4], k=K[3], r_lim=recept_limit[3]) #7 + self.level5_0 = DownSampler(out_channel_map[3], out_channel_map[4], input2_nin=channels_in, k=K[3], r_lim=recept_limit[3]) #7 self.level5 = nn.ModuleList() for i in range(reps_at_each_level[3]): self.level5.append(EESP(out_channel_map[4], out_channel_map[4], stride=1, k=K[4], r_lim=recept_limit[4])) diff --git a/nn_layers/eesp.py b/nn_layers/eesp.py index 064b5f9..8c268dd 100644 --- a/nn_layers/eesp.py +++ b/nn_layers/eesp.py @@ -101,7 +101,7 @@ class DownSampler(nn.Module): the final output. ''' - def __init__(self, nin, nout, k=4, r_lim=9, reinf=True): + def __init__(self, nin, nout, input2_nin=config_inp_reinf, k=4, r_lim=9, reinf=True): ''' :param nin: number of input channels :param nout: number of output channels @@ -115,7 +115,7 @@ def __init__(self, nin, nout, k=4, r_lim=9, reinf=True): self.avg = nn.AvgPool2d(kernel_size=3, padding=1, stride=2) if reinf: self.inp_reinf = nn.Sequential( - CBR(config_inp_reinf, config_inp_reinf, 3, 1), + CBR(input2_nin, config_inp_reinf, 3, 1), CB(config_inp_reinf, nout, 1, 1) ) self.act = nn.PReLU(nout) From 58c64784184d3863a4bc6f19cbf625d1fb6b0473 Mon Sep 17 00:00:00 2001 From: pnorridge <37704783+pnorridge@users.noreply.github.com> Date: Sat, 29 Jan 2022 16:13:47 +0000 Subject: [PATCH 3/4] Revert "Update train_classification.py" This reverts commit d99d0c29a906f10d663b844d1e4398cfc91e860e. --- train_classification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train_classification.py b/train_classification.py index b014258..a41f0a8 100644 --- a/train_classification.py +++ b/train_classification.py @@ -44,7 +44,7 @@ def main(args): print_info_message('Loading pretrained basenet model weights') model_dict = model.state_dict() - overlap_dict = {k: v for k, v in pretrained_dict if k in model_dict.items()} + overlap_dict = {k: v for k, v in model_dict.items() if k in pretrained_dict} total_size_overlap = 0 for k, v in enumerate(overlap_dict): From f5be3795e66a6b6666850fc854a9fa2c68545da1 Mon Sep 17 00:00:00 2001 From: pnorridge <37704783+pnorridge@users.noreply.github.com> Date: Thu, 24 Mar 2022 21:56:27 +0000 Subject: [PATCH 4/4] Update License --- License | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 License diff --git a/License b/License new file mode 100644 index 0000000..839340a --- /dev/null +++ b/License @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Sachin Mehta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.