get model and tokenizer from HuggingFace

This commit is contained in:
Maciej Ścigacz 2023-05-30 15:30:13 +02:00
parent 14ebbba342
commit 38122a4cbf

View File

@ -1,10 +1,13 @@
from transformers import AutoTokenizer from transformers import AutoTokenizer
from transformers import pipeline from transformers import pipeline, GPT2ForSequenceClassification
import re import re
from facebook_scraper import get_posts from facebook_scraper import get_posts
model = 'application/models/sentiment_model' # model = 'application/models/sentiment_model'
tokenizer = AutoTokenizer.from_pretrained('application/tokenizers/sentiment_tokenizer') # tokenizer = AutoTokenizer.from_pretrained('application/tokenizers/sentiment_tokenizer')
model = GPT2ForSequenceClassification.from_pretrained("Scigi/sentiment-analysis-model", num_labels=3)
tokenizer = AutoTokenizer.from_pretrained("Scigi/sentiment-analysis-model")
def sentiment_prediction(data): def sentiment_prediction(data):
pipe = pipeline('text-classification', model=model, tokenizer = tokenizer) pipe = pipeline('text-classification', model=model, tokenizer = tokenizer)