Create app/model.py
Browse files- app/model.py +8 -0
app/model.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
|
| 3 |
+
# Load the model once on import
|
| 4 |
+
sentiment_pipeline = pipeline("sentiment-analysis")
|
| 5 |
+
|
| 6 |
+
def get_sentiment(text):
|
| 7 |
+
result = sentiment_pipeline(text)
|
| 8 |
+
return result[0]
|