Spaces:
Runtime error
Runtime error
Commit
·
d21a6a7
1
Parent(s):
10210a4
change chkpt path
Browse files- sentiment.py +2 -1
- sentiment_onnx.py +2 -1
- sentiment_onnx_classify.py +6 -4
sentiment.py
CHANGED
@@ -3,7 +3,8 @@ from transformers import AutoModelForSequenceClassification,AutoTokenizer
|
|
3 |
|
4 |
chkpt='distilbert-base-uncased-finetuned-sst-2-english'
|
5 |
model=AutoModelForSequenceClassification.from_pretrained(chkpt)
|
6 |
-
tokenizer=AutoTokenizer.from_pretrained(
|
|
|
7 |
|
8 |
def classify_sentiment(texts,model=model,tokenizer=tokenizer):
|
9 |
"""
|
|
|
3 |
|
4 |
chkpt='distilbert-base-uncased-finetuned-sst-2-english'
|
5 |
model=AutoModelForSequenceClassification.from_pretrained(chkpt)
|
6 |
+
tokenizer=AutoTokenizer.from_pretrained(chkpt)
|
7 |
+
# tokenizer=AutoTokenizer.from_pretrained('sentiment_classifier/')
|
8 |
|
9 |
def classify_sentiment(texts,model=model,tokenizer=tokenizer):
|
10 |
"""
|
sentiment_onnx.py
CHANGED
@@ -12,7 +12,8 @@ python3 -m transformers.onnx --model= distilbert-base-uncased-finetuned-sst-2-en
|
|
12 |
"""
|
13 |
chkpt='distilbert-base-uncased-finetuned-sst-2-english'
|
14 |
model= AutoModelForSequenceClassification.from_pretrained(chkpt)
|
15 |
-
tokenizer= AutoTokenizer.from_pretrained('
|
|
|
16 |
|
17 |
"""
|
18 |
or download the model directly from hub --
|
|
|
12 |
"""
|
13 |
chkpt='distilbert-base-uncased-finetuned-sst-2-english'
|
14 |
model= AutoModelForSequenceClassification.from_pretrained(chkpt)
|
15 |
+
tokenizer= AutoTokenizer.from_pretrained('chkpt')
|
16 |
+
# tokenizer= AutoTokenizer.from_pretrained('sentiment_classifier/')
|
17 |
|
18 |
"""
|
19 |
or download the model directly from hub --
|
sentiment_onnx_classify.py
CHANGED
@@ -3,15 +3,17 @@ import torch
|
|
3 |
from transformers import AutoTokenizer
|
4 |
import numpy as np
|
5 |
|
6 |
-
|
|
|
|
|
7 |
|
8 |
#create onnx & onnx_int_8 sessions
|
9 |
session=ort.InferenceSession("sent_clf_onnx/sentiment_classifier_onnx.onnx")
|
10 |
session_int8=ort.InferenceSession("sent_clf_onnx/sentiment_classifier_onnx_int8.onnx")
|
11 |
|
12 |
-
options=ort.SessionOptions()
|
13 |
-
options.inter_op_num_threads=1
|
14 |
-
options.intra_op_num_threads=1
|
15 |
|
16 |
def classify_sentiment_onnx(texts,_model=session,_tokenizer=tokenizer):
|
17 |
"""
|
|
|
3 |
from transformers import AutoTokenizer
|
4 |
import numpy as np
|
5 |
|
6 |
+
chkpt='distilbert-base-uncased-finetuned-sst-2-english'
|
7 |
+
tokenizer=AutoTokenizer.from_pretrained(chkpt)
|
8 |
+
# tokenizer=AutoTokenizer.from_pretrained("sentiment_classifier/")
|
9 |
|
10 |
#create onnx & onnx_int_8 sessions
|
11 |
session=ort.InferenceSession("sent_clf_onnx/sentiment_classifier_onnx.onnx")
|
12 |
session_int8=ort.InferenceSession("sent_clf_onnx/sentiment_classifier_onnx_int8.onnx")
|
13 |
|
14 |
+
# options=ort.SessionOptions()
|
15 |
+
# options.inter_op_num_threads=1
|
16 |
+
# options.intra_op_num_threads=1
|
17 |
|
18 |
def classify_sentiment_onnx(texts,_model=session,_tokenizer=tokenizer):
|
19 |
"""
|