Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,22 @@
|
|
1 |
import torch
|
|
|
2 |
from transformers import XLNetTokenizer, XLNetForSequenceClassification
|
3 |
import gradio as gr
|
4 |
|
5 |
# Link to the saved model on Hugging Face Spaces
|
6 |
-
model_link = 'https://huggingface.co/spaces/AliArshad/SeverityPrediction/
|
7 |
|
8 |
-
#
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Other model setup
|
12 |
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased')
|
13 |
-
model.eval()
|
14 |
|
15 |
# Function for prediction
|
16 |
def xl_net_predict(text):
|
|
|
1 |
import torch
|
2 |
+
import requests
|
3 |
from transformers import XLNetTokenizer, XLNetForSequenceClassification
|
4 |
import gradio as gr
|
5 |
|
6 |
# Link to the saved model on Hugging Face Spaces
|
7 |
+
model_link = 'https://huggingface.co/spaces/AliArshad/SeverityPrediction/blob/main/severitypredictor.pt'
|
8 |
|
9 |
+
# Download the model file
|
10 |
+
response = requests.get(model_link)
|
11 |
+
model_path = 'severitypredictor.pt'
|
12 |
+
with open(model_path, 'wb') as f:
|
13 |
+
f.write(response.content)
|
14 |
+
|
15 |
+
# Load the downloaded model using PyTorch
|
16 |
+
model = torch.load(model_path)
|
17 |
|
18 |
# Other model setup
|
19 |
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased')
|
|
|
20 |
|
21 |
# Function for prediction
|
22 |
def xl_net_predict(text):
|