AliArshad commited on
Commit
687d513
1 Parent(s): 269ce01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
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/resolve/main/severitypredictor.pt'
7
 
8
- # Load the model directly from the link
9
- model = XLNetForSequenceClassification.from_pretrained(model_link, from_tf=False)
 
 
 
 
 
 
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):