saronium commited on
Commit
0c3276d
1 Parent(s): 51d0bd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -14,14 +14,13 @@ 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, 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,17 +28,16 @@ class ANNModel(nn.Module):
29
  x = self.fc2(x)
30
  x = self.relu2(x)
31
  x = self.fc3(x)
32
- x = self.softmax(x)
33
  return x
34
 
35
  # Create an instance of your model
36
  ann_model = ANNModel()
37
 
38
  # Load the trained model
39
- ann_model.load_state_dict(torch.load('ann_model_256_97400.pth'))
40
 
41
  # Load the PCA instance
42
- pca = load('pca_400.pkl')
43
 
44
  vgg16 = models.vgg16(pretrained=True).features
45
  # 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):
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
  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