Randinu002 commited on
Commit
c553417
·
1 Parent(s): d4eb7cd

Remove notebook_login and use secrets for auth

Browse files
Files changed (1) hide show
  1. model.py +2 -13
model.py CHANGED
@@ -1,8 +1,4 @@
1
- # ===================================================================
2
- # FINAL WORKING SCRIPT (v5): MANUAL STATISTICS POOLING
3
- # ===================================================================
4
 
5
- # --- 1. IMPORTS ---
6
  import torch
7
  import torch.nn as nn
8
  import torch.nn.functional as F
@@ -16,14 +12,9 @@ from speechbrain.lobes.features import Fbank
16
  from speechbrain.lobes.models.ECAPA_TDNN import ECAPA_TDNN
17
  import torch.optim as optim
18
  import itertools
19
- from huggingface_hub import notebook_login
20
 
21
  print("All libraries imported successfully.")
22
 
23
- # --- 2. HUGGING FACE LOGIN ---
24
- notebook_login()
25
-
26
- # --- 3. ALL MODEL AND DATASET CLASSES ---
27
 
28
  class AFM(nn.Module):
29
  def __init__(self, channels):
@@ -71,13 +62,11 @@ class DBE(nn.Module):
71
  cat_feats = torch.cat(main_outs[-3:], dim=1)
72
  mfa_feats = self.mfa(cat_feats)
73
 
74
- # <<< --- FINAL FIX: Manual Statistics Pooling --- >>>
75
- # We replace the problematic SpeechBrain layer with a correct manual implementation.
76
  mean = mfa_feats.mean(dim=2)
77
  std = mfa_feats.std(dim=2)
78
- pooled_feats = torch.cat((mean, std), dim=1) # Shape is now correctly (batch, 1024)
79
 
80
- norm_feats = self.bn(pooled_feats) # This will now work
81
  embedding = self.fc(norm_feats)
82
  return embedding
83
 
 
 
 
 
1
 
 
2
  import torch
3
  import torch.nn as nn
4
  import torch.nn.functional as F
 
12
  from speechbrain.lobes.models.ECAPA_TDNN import ECAPA_TDNN
13
  import torch.optim as optim
14
  import itertools
 
15
 
16
  print("All libraries imported successfully.")
17
 
 
 
 
 
18
 
19
  class AFM(nn.Module):
20
  def __init__(self, channels):
 
62
  cat_feats = torch.cat(main_outs[-3:], dim=1)
63
  mfa_feats = self.mfa(cat_feats)
64
 
 
 
65
  mean = mfa_feats.mean(dim=2)
66
  std = mfa_feats.std(dim=2)
67
+ pooled_feats = torch.cat((mean, std), dim=1)
68
 
69
+ norm_feats = self.bn(pooled_feats)
70
  embedding = self.fc(norm_feats)
71
  return embedding
72