Spaces:
Runtime error
Runtime error
Abineshkumar77
commited on
Commit
ยท
9bae10e
1
Parent(s):
4fcd4f9
Add application file
Browse files
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
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
| 9 |
-
model =
|
| 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 |
+
}
|
|
|
|
|
|