update
Browse files
app.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
2 |
import torch
|
3 |
|
4 |
-
tokenizer
|
5 |
-
|
|
|
|
|
6 |
|
7 |
def classify_text(text):
|
8 |
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
|
|
1 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
2 |
import torch
|
3 |
|
4 |
+
# 加载微调的模型和tokenizer
|
5 |
+
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
8 |
|
9 |
def classify_text(text):
|
10 |
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|