Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ torch.cuda.is_available()
|
|
7 |
|
8 |
model_path = "ltg/norbert3-base_sentence-sentiment"
|
9 |
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
11 |
-
config = AutoConfig.from_pretrained(model_path)
|
12 |
model = AutoModelForSequenceClassification.from_pretrained(model_path, trust_remote_code=True)
|
13 |
|
14 |
def sentiment_analysis(text):
|
@@ -16,7 +16,7 @@ def sentiment_analysis(text):
|
|
16 |
output = model(**encoded_input)
|
17 |
scores_ = output[0][0].detach().numpy()
|
18 |
scores_ = softmax(scores_)
|
19 |
-
labels = ['Negativ', '
|
20 |
scores = {l: float(s) for (l, s) in zip(labels, scores_)}
|
21 |
return scores
|
22 |
|
|
|
7 |
|
8 |
model_path = "ltg/norbert3-base_sentence-sentiment"
|
9 |
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
11 |
+
config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
|
12 |
model = AutoModelForSequenceClassification.from_pretrained(model_path, trust_remote_code=True)
|
13 |
|
14 |
def sentiment_analysis(text):
|
|
|
16 |
output = model(**encoded_input)
|
17 |
scores_ = output[0][0].detach().numpy()
|
18 |
scores_ = softmax(scores_)
|
19 |
+
labels = ['Negativ', 'Positiv', 'Nøytral']
|
20 |
scores = {l: float(s) for (l, s) in zip(labels, scores_)}
|
21 |
return scores
|
22 |
|