Update app.py
Browse files
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
|
18 |
super(ANNModel, self).__init__()
|
19 |
-
self.fc1 = nn.Linear(
|
20 |
self.relu1 = nn.ReLU()
|
21 |
-
self.fc2 = nn.Linear(
|
22 |
self.relu2 = nn.ReLU()
|
23 |
-
self.fc3 = nn.Linear(
|
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('
|
40 |
|
41 |
# Load the PCA instance
|
42 |
-
pca = load('
|
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
|