manue commited on
Commit
e1379c5
·
1 Parent(s): 03c041a

Refactor sentiment model initialization to use AutoModel and AutoTokenizer

Browse files
Files changed (1) hide show
  1. model/sentiment.py +5 -2
model/sentiment.py CHANGED
@@ -1,8 +1,11 @@
1
- from transformers import pipeline
2
  from typing import Any
3
 
4
  class Sentiment:
5
  def __init__(self, line: str) -> (list | list[Any] | Any | None):
6
- self.pipe = pipeline("text-classification", model='./feel-it-italian-sentiment')
 
 
 
7
  self.result = self.pipe(line)
8
 
 
1
+ from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
2
  from typing import Any
3
 
4
  class Sentiment:
5
  def __init__(self, line: str) -> (list | list[Any] | Any | None):
6
+ model = AutoModelForSequenceClassification.from_pretrained("./feel-it-italian-sentiment")
7
+ tokenizer = AutoTokenizer.from_pretrained("./feel-it-italian-sentiment")
8
+
9
+ self.pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
10
  self.result = self.pipe(line)
11