huph22 commited on
Commit
fbaf352
·
verified ·
1 Parent(s): dc3faa0
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,8 +1,10 @@
1
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
  import torch
3
 
4
- tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
5
- model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased")
 
 
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)