saronium commited on
Commit
0b54da7
·
verified ·
1 Parent(s): 04813c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -14,13 +14,14 @@ import soundfile as sf
14
  language_mapping = {'malayalam': 0, 'english': 1, 'tamil': 2,'hindi':3}
15
 
16
  class ANNModel(nn.Module):
17
- def __init__(self):
18
  super(ANNModel, self).__init__()
19
- self.fc1 = nn.Linear(300, 256)
20
  self.relu1 = nn.ReLU()
21
- self.fc2 = nn.Linear(256, 64)
22
  self.relu2 = nn.ReLU()
23
- self.fc3 = nn.Linear(64, 4)
 
24
 
25
  def forward(self, x):
26
  x = self.fc1(x)
@@ -28,16 +29,16 @@ class ANNModel(nn.Module):
28
  x = self.fc2(x)
29
  x = self.relu2(x)
30
  x = self.fc3(x)
31
- return x
32
 
33
  # Create an instance of your model
34
  ann_model = ANNModel()
35
 
36
  # Load the trained model
37
- ann_model.load_state_dict(torch.load('ann_model_256_01_94.pth'))
38
 
39
  # Load the PCA instance
40
- pca = load('pca_256_01_94.pkl')
41
 
42
  vgg16 = models.vgg16(pretrained=True).features
43
  # Function to load and preprocess a single audio file
 
14
  language_mapping = {'malayalam': 0, 'english': 1, 'tamil': 2,'hindi':3}
15
 
16
  class ANNModel(nn.Module):
17
+ def __init__(self, input_size=300, hidden_size1=256, hidden_size2=64, num_classes=4):
18
  super(ANNModel, self).__init__()
19
+ self.fc1 = nn.Linear(input_size, hidden_size1)
20
  self.relu1 = nn.ReLU()
21
+ self.fc2 = nn.Linear(hidden_size1, hidden_size2)
22
  self.relu2 = nn.ReLU()
23
+ self.fc3 = nn.Linear(hidden_size2, num_classes)
24
+ self.softmax = nn.Softmax(dim=1)
25
 
26
  def forward(self, x):
27
  x = self.fc1(x)
 
29
  x = self.fc2(x)
30
  x = self.relu2(x)
31
  x = self.fc3(x)
32
+ x = self.softmax(x)
33
 
34
  # Create an instance of your model
35
  ann_model = ANNModel()
36
 
37
  # Load the trained model
38
+ ann_model.load_state_dict(torch.load('ann_model_256_97400.pth'))
39
 
40
  # Load the PCA instance
41
+ pca = load('pca_400.pkl')
42
 
43
  vgg16 = models.vgg16(pretrained=True).features
44
  # Function to load and preprocess a single audio file