From 38122a4cbf41cf3c7fbbe14ca1e5c9bfabf8ef7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=9Acigacz?= Date: Tue, 30 May 2023 15:30:13 +0200 Subject: [PATCH] get model and tokenizer from HuggingFace --- application/functions/sentiment.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application/functions/sentiment.py b/application/functions/sentiment.py index b264b50..1463057 100644 --- a/application/functions/sentiment.py +++ b/application/functions/sentiment.py @@ -1,10 +1,13 @@ from transformers import AutoTokenizer -from transformers import pipeline +from transformers import pipeline, GPT2ForSequenceClassification import re from facebook_scraper import get_posts -model = 'application/models/sentiment_model' -tokenizer = AutoTokenizer.from_pretrained('application/tokenizers/sentiment_tokenizer') +# model = 'application/models/sentiment_model' +# 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): pipe = pipeline('text-classification', model=model, tokenizer = tokenizer)