buzzcraft commited on
Commit
f74faa1
1 Parent(s): 0703a02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
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 = "cardiffnlp/twitter-roberta-base-sentiment-latest"
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 = ['Negative', 'Neutral', 'Positive']
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
- ["I'm thrilled about the job offer!"],
30
- ["The weather today is absolutely beautiful."],
31
- ["I had a fantastic time at the concert last night."],
32
- ["I'm so frustrated with this software glitch."],
33
- ["The customer service was terrible at the store."],
34
- ["I'm really disappointed with the quality of this product."]
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
+ [" vei til sykehus.. Ønsk meg lykke til.."],
33
+ ["Supert! De 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.'