Instructions to use Sumedhzz/Sentiment-Analyzer-Quantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sumedhzz/Sentiment-Analyzer-Quantized with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Sumedhzz/Sentiment-Analyzer-Quantized")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Sumedhzz/Sentiment-Analyzer-Quantized") model = AutoModelForSequenceClassification.from_pretrained("Sumedhzz/Sentiment-Analyzer-Quantized") - Notebooks
- Google Colab
- Kaggle
Sumedh satish gajbhiye commited on
Update handler.py
Browse files- handler.py +8 -6
handler.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
| 1 |
from transformers import AutoTokenizer, pipeline
|
| 2 |
from optimum.onnxruntime import ORTModelForSequenceClassification
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def __call__(data):
|
| 12 |
return classifier(data["inputs"])
|
|
|
|
| 1 |
from transformers import AutoTokenizer, pipeline
|
| 2 |
from optimum.onnxruntime import ORTModelForSequenceClassification
|
| 3 |
|
| 4 |
+
def init():
|
| 5 |
+
global classifier
|
| 6 |
+
model_id = "."
|
| 7 |
+
|
| 8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 9 |
+
model = ORTModelForSequenceClassification.from_pretrained(model_id)
|
| 10 |
+
|
| 11 |
+
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
| 12 |
|
| 13 |
def __call__(data):
|
| 14 |
return classifier(data["inputs"])
|