Spaces:
Runtime error
Runtime error
Commit
·
10210a4
1
Parent(s):
ec4681c
updated chkpt for model
Browse files- sentiment.py +2 -1
- sentiment_onnx.py +2 -5
sentiment.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import torch
|
2 |
from transformers import AutoModelForSequenceClassification,AutoTokenizer
|
3 |
|
4 |
-
|
|
|
5 |
tokenizer=AutoTokenizer.from_pretrained('sentiment_classifier/')
|
6 |
|
7 |
def classify_sentiment(texts,model=model,tokenizer=tokenizer):
|
|
|
1 |
import torch
|
2 |
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('sentiment_classifier/')
|
7 |
|
8 |
def classify_sentiment(texts,model=model,tokenizer=tokenizer):
|
sentiment_onnx.py
CHANGED
@@ -1,20 +1,17 @@
|
|
1 |
-
import numpy as np
|
2 |
from transformers import AutoTokenizer,AutoModelForSequenceClassification
|
3 |
import transformers.convert_graph_to_onnx as onnx_convert
|
4 |
from pathlib import Path
|
5 |
import transformers
|
6 |
from onnxruntime.quantization import quantize_dynamic,QuantType
|
7 |
import onnx
|
8 |
-
import torch
|
9 |
import onnxruntime as ort
|
10 |
-
import streamlit as st
|
11 |
|
12 |
"""
|
13 |
type in cmd to create onnx model of hugging face chkpt
|
14 |
python3 -m transformers.onnx --model= distilbert-base-uncased-finetuned-sst-2-english sentiment_onnx/
|
15 |
"""
|
16 |
-
|
17 |
-
model= AutoModelForSequenceClassification.from_pretrained(
|
18 |
tokenizer= AutoTokenizer.from_pretrained('sentiment_classifier/')
|
19 |
|
20 |
"""
|
|
|
|
|
1 |
from transformers import AutoTokenizer,AutoModelForSequenceClassification
|
2 |
import transformers.convert_graph_to_onnx as onnx_convert
|
3 |
from pathlib import Path
|
4 |
import transformers
|
5 |
from onnxruntime.quantization import quantize_dynamic,QuantType
|
6 |
import onnx
|
|
|
7 |
import onnxruntime as ort
|
|
|
8 |
|
9 |
"""
|
10 |
type in cmd to create onnx model of hugging face chkpt
|
11 |
python3 -m transformers.onnx --model= distilbert-base-uncased-finetuned-sst-2-english sentiment_onnx/
|
12 |
"""
|
13 |
+
chkpt='distilbert-base-uncased-finetuned-sst-2-english'
|
14 |
+
model= AutoModelForSequenceClassification.from_pretrained(chkpt)
|
15 |
tokenizer= AutoTokenizer.from_pretrained('sentiment_classifier/')
|
16 |
|
17 |
"""
|