Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,13 @@
|
|
1 |
import torch
|
2 |
-
from transformers import
|
3 |
import gradio as gr
|
4 |
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
# Load the saved model
|
11 |
-
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased')
|
12 |
-
model = XLNetForSequenceClassification.from_pretrained('xlnet-base-cased', num_labels=2)
|
13 |
-
model.load_state_dict(torch.load(model_path))
|
14 |
-
model.eval()
|
15 |
|
16 |
# Function for prediction
|
17 |
def xl_net_predict(text):
|
|
|
1 |
import torch
|
2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Path to the saved model in Hugging Face Spaces
|
6 |
+
model_path = 'https://huggingface.co/spaces/AliArshad/SeverityPrediction/blob/main/XLNet_model_project_Core.pt'
|
7 |
|
8 |
+
# Load the model and tokenizer
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained('xlnet-base-cased')
|
10 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Function for prediction
|
13 |
def xl_net_predict(text):
|