Abineshkumar77 commited on
Commit
9bae10e
ยท
1 Parent(s): 4fcd4f9

Add application file

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -1,12 +1,11 @@
1
  from fastapi import FastAPI
2
- from transformers import AutoTokenizer
3
- from optimum.onnxruntime import ORTModelForSequenceClassification
4
  import torch
5
  import time
6
 
7
- # Load the tokenizer and optimized model
8
  tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
9
- model = ORTModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment", from_transformers=True)
10
 
11
  app = FastAPI()
12
 
@@ -65,6 +64,4 @@ def analyze_sentiment(tweet: str):
65
  "label": highest_label,
66
  "score": highest_score,
67
  "inference_time": round(inference_time, 4) # In seconds
68
- }
69
-
70
-
 
1
  from fastapi import FastAPI
2
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
 
3
  import torch
4
  import time
5
 
6
+ # Load the tokenizer and model directly
7
  tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
8
+ model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
9
 
10
  app = FastAPI()
11
 
 
64
  "label": highest_label,
65
  "score": highest_score,
66
  "inference_time": round(inference_time, 4) # In seconds
67
+ }