puneeth1 commited on
Commit
939e633
·
verified ·
1 Parent(s): 52225d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -29,10 +29,19 @@ def load_model_and_tokenizer():
29
  with open(config_path, "r") as f:
30
  config = json.load(f)
31
 
 
 
 
 
 
 
32
  # Load model
33
  model = BiLSTM(
34
- embedding_matrix=torch.zeros((config["max_length"], config["embedding_dim"])),
35
- num_classes=config["num_labels"]
 
 
 
36
  )
37
  model.load_state_dict(torch.load(model_weights_path, map_location=DEVICE))
38
  model.eval()
 
29
  with open(config_path, "r") as f:
30
  config = json.load(f)
31
 
32
+ # Get vocabulary size from the tokenizer
33
+ vocab_size = len(tokenizer.word_index) + 1 # +1 for padding token
34
+
35
+ # Initialize embedding matrix (vocab_size x embed_size)
36
+ embedding_matrix = torch.zeros((vocab_size, config["embedding_dim"]))
37
+
38
  # Load model
39
  model = BiLSTM(
40
+ embedding_matrix=embedding_matrix,
41
+ embed_size=config["embedding_dim"],
42
+ num_labels=config["num_labels"],
43
+ hidden_size=config["hidden_size"],
44
+ dropout=config["dropout_rate"]
45
  )
46
  model.load_state_dict(torch.load(model_weights_path, map_location=DEVICE))
47
  model.eval()