alinikkhah commited on
Commit
c8db798
1 Parent(s): 4805566

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -6,10 +6,13 @@ import torch
6
  from transformers import BertForSequenceClassification, BertTokenizer
7
  import gradio as gr
8
 
9
- # Load the model architecture
 
 
 
10
  model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2)
11
 
12
- # Load the state dict, ensuring tensors are on the CPU
13
  try:
14
  model.load_state_dict(torch.load('bert_model_complete.pth', map_location=torch.device('cpu')), strict=False)
15
  except Exception as e:
 
6
  from transformers import BertForSequenceClassification, BertTokenizer
7
  import gradio as gr
8
 
9
+ import torch
10
+ from transformers import BertForSequenceClassification
11
+
12
+ # Load the model architecture with the number of labels
13
  model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2)
14
 
15
+ # Load the state dict while mapping to CPU
16
  try:
17
  model.load_state_dict(torch.load('bert_model_complete.pth', map_location=torch.device('cpu')), strict=False)
18
  except Exception as e: