exact_data2023/application/functions/sentiment.py
2023-05-27 15:10:30 +02:00

11 lines
432 B
Python

from transformers import AutoTokenizer
from transformers import pipeline
model = 'application/models/sentiment_model'
tokenizer = AutoTokenizer.from_pretrained('application/tokenizers/sentiment_tokenizer')
# tokenizer = AutoTokenizer.from_pretrained("sdadas/polish-gpt2-small")
def sentiment_prediction(data):
pipe = pipeline('text-classification', model=model, tokenizer = tokenizer)
result = pipe(data)
return result