Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,15 +6,16 @@ import torch
|
|
| 6 |
from transformers import BertForSequenceClassification, BertTokenizer
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
-
# Load your BERT model
|
| 10 |
# Load the model architecture
|
| 11 |
model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2)
|
| 12 |
|
| 13 |
-
# Load the state dict
|
| 14 |
try:
|
| 15 |
model.load_state_dict(torch.load('bert_model_complete.pth', map_location=torch.device('cpu')), strict=False)
|
| 16 |
except Exception as e:
|
| 17 |
print(f"Error loading state dict: {e}")
|
|
|
|
|
|
|
| 18 |
model.eval() # Set the model to evaluation mode
|
| 19 |
|
| 20 |
|
|
|
|
| 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:
|
| 16 |
print(f"Error loading state dict: {e}")
|
| 17 |
+
|
| 18 |
+
|
| 19 |
model.eval() # Set the model to evaluation mode
|
| 20 |
|
| 21 |
|