AliArshad commited on
Commit
545a4be
1 Parent(s): 4aff384

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -1,17 +1,13 @@
1
  import torch
2
- from transformers import XLNetTokenizer, XLNetForSequenceClassification
3
  import gradio as gr
4
 
 
 
5
 
6
-
7
- # Path to the saved model
8
- model_path = 'https://huggingface.co/spaces/AliArshad/SeverityPrediction/blob/main/XLNet_model_project_Core.pt' # Update with your model path
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):