jayebaku commited on
Commit
4aca4eb
·
verified ·
1 Parent(s): 6dc4db2

Update classifier.py

Browse files
Files changed (1) hide show
  1. classifier.py +3 -2
classifier.py CHANGED
@@ -1,5 +1,5 @@
1
  import spaces
2
- from transformers import pipeline as tpipeline
3
  # from optimum.pipelines import pipeline as opipeline
4
  from optimum.onnxruntime import ORTModelForSequenceClassification
5
 
@@ -8,9 +8,10 @@ def classify(tweet, event_model, hftoken, threshold):
8
  results = {"text": None, "event": None, "score": None}
9
 
10
  model = ORTModelForSequenceClassification.from_pretrained(event_model)
 
11
 
12
  # event type prediction with transformers pipeline
13
- event_predictor = tpipeline(task="text-classification", model=model, #model=event_model
14
  batch_size=512, token=hftoken, device="cpu")
15
  tokenizer_kwargs = {'padding': True, 'truncation': True, 'max_length': 512}
16
  prediction = event_predictor(tweet, **tokenizer_kwargs)[0]
 
1
  import spaces
2
+ from transformers import AutoTokenizer, pipeline
3
  # from optimum.pipelines import pipeline as opipeline
4
  from optimum.onnxruntime import ORTModelForSequenceClassification
5
 
 
8
  results = {"text": None, "event": None, "score": None}
9
 
10
  model = ORTModelForSequenceClassification.from_pretrained(event_model)
11
+ tokenizer = AutoTokenizer.from_pretrained(event_model)
12
 
13
  # event type prediction with transformers pipeline
14
+ event_predictor = pipeline(task="text-classification", model=model, tokenizer=tokenizer, #model=event_model
15
  batch_size=512, token=hftoken, device="cpu")
16
  tokenizer_kwargs = {'padding': True, 'truncation': True, 'max_length': 512}
17
  prediction = event_predictor(tweet, **tokenizer_kwargs)[0]