Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from scipy.special import softmax
|
|
5 |
import gradio as gr
|
6 |
torch.cuda.is_available()
|
7 |
|
8 |
-
model_path = "
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
11 |
config = AutoConfig.from_pretrained(model_path)
|
@@ -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 = ['
|
20 |
scores = {l: float(s) for (l, s) in zip(labels, scores_)}
|
21 |
return scores
|
22 |
|
@@ -26,12 +26,12 @@ demo = gr.Interface(
|
|
26 |
inputs=gr.Textbox(placeholder="Write your text here..."),
|
27 |
outputs="label",
|
28 |
examples=[
|
29 |
-
["
|
30 |
-
["
|
31 |
-
["
|
32 |
-
["
|
33 |
-
["
|
34 |
-
["
|
35 |
],
|
36 |
title='Sentiment Analysis App',
|
37 |
description='This app classifies a positive, neutral, or negative sentiment.'
|
|
|
5 |
import gradio as gr
|
6 |
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)
|
|
|
16 |
output = model(**encoded_input)
|
17 |
scores_ = output[0][0].detach().numpy()
|
18 |
scores_ = softmax(scores_)
|
19 |
+
labels = ['Negativ', 'Nøytral', 'Positiv']
|
20 |
scores = {l: float(s) for (l, s) in zip(labels, scores_)}
|
21 |
return scores
|
22 |
|
|
|
26 |
inputs=gr.Textbox(placeholder="Write your text here..."),
|
27 |
outputs="label",
|
28 |
examples=[
|
29 |
+
["Woho, jeg fikk meg ny jobb!"],
|
30 |
+
["Jeg skal jobbe med løver i den nye jobben min."],
|
31 |
+
["Oj, en løve spiste den ene armen min.. Snakk om HMS :("],
|
32 |
+
["På vei til sykehus.. Ønsk meg lykke til.."],
|
33 |
+
["Supert! De må pokkern meg amputere hele armen.."],
|
34 |
+
["Våkna opp fra operasjon, fått en robot arm. Im now terminator! Super opplevelse 10 av 10.."]
|
35 |
],
|
36 |
title='Sentiment Analysis App',
|
37 |
description='This app classifies a positive, neutral, or negative sentiment.'
|