Abineshkumar77 commited on
Commit
d65dba3
ยท
2 Parent(s): f97bb94 86f4524

Add application file

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -1,13 +1,24 @@
1
  from fastapi import FastAPI
 
2
  import onnxruntime as ort
3
  from transformers import AutoTokenizer
 
 
 
 
4
  import time
5
  import torch
6
 
 
7
  # Load the tokenizer and ONNX model
8
  tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
9
  onnx_model_path = "D:/demodeploy/sentiment_model.onnx"
10
  onnx_session = ort.InferenceSession(onnx_model_path)
 
 
 
 
 
11
 
12
  app = FastAPI()
13
 
@@ -72,4 +83,8 @@ def analyze_sentiment(tweet: str):
72
  "label": highest_label,
73
  "score": highest_score,
74
  "inference_time": round(inference_time, 4) # In seconds
 
 
 
75
  }
 
 
1
  from fastapi import FastAPI
2
+ <<<<<<< HEAD
3
  import onnxruntime as ort
4
  from transformers import AutoTokenizer
5
+ =======
6
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
7
+ import torch
8
+ >>>>>>> 86f452461e3f04611f1ee50ade207b1a64893e79
9
  import time
10
  import torch
11
 
12
+ <<<<<<< HEAD
13
  # Load the tokenizer and ONNX model
14
  tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
15
  onnx_model_path = "D:/demodeploy/sentiment_model.onnx"
16
  onnx_session = ort.InferenceSession(onnx_model_path)
17
+ =======
18
+ # Load the tokenizer and model directly
19
+ tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
20
+ model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
21
+ >>>>>>> 86f452461e3f04611f1ee50ade207b1a64893e79
22
 
23
  app = FastAPI()
24
 
 
83
  "label": highest_label,
84
  "score": highest_score,
85
  "inference_time": round(inference_time, 4) # In seconds
86
+ <<<<<<< HEAD
87
+ }
88
+ =======
89
  }
90
+ >>>>>>> 86f452461e3f04611f1ee50ade207b1a64893e79