tclopess commited on
Commit
cde25ed
·
verified ·
1 Parent(s): 0cac39e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -37
app.py CHANGED
@@ -1,48 +1,12 @@
1
- """
2
  from transformers import pipeline
3
  import gradio as gr
4
  import torch
5
 
6
- model = "neuralmind/bert-base-portuguese-cased"
7
- pipe = pipeline('sentiment-analysis', model=model)
8
 
9
  def get_sentiment(input_text):
10
  return pipe(input_text)
11
 
12
- iface = gr.Interface(fn=get_sentiment,
13
- inputs='text',
14
- outputs=['text'],
15
- title='Sentiment Analysis',
16
- description='Obtenha o sentimento do texto de entrada:'
17
- )
18
-
19
- iface.launch(inline=False)"""
20
-
21
- from transformers import pipeline
22
- import gradio as gr
23
- import torch
24
-
25
- model = "neuralmind/bert-base-portuguese-cased"
26
- pipe = pipeline('sentiment-analysis', model=model)
27
-
28
- def get_sentiment(input_text):
29
- return pipe(input_text)
30
-
31
- results = pipe(input_text)
32
-
33
- # Extract the label and score
34
- label = results[0]['label']
35
- score = results[0]['score']
36
-
37
- threshold = 0.5
38
-
39
- if label == 'LABEL_1' and score > sentiment_threshold: # Positive sentiment
40
- return 'POSITIVO'
41
- else: label == 'LABEL_0' and score <= sentiment_threshold: # Negative sentiment
42
- return 'NEGATIVO'
43
-
44
-
45
-
46
  iface = gr.Interface(fn=get_sentiment,
47
  inputs='text',
48
  outputs='text',
 
 
1
  from transformers import pipeline
2
  import gradio as gr
3
  import torch
4
 
5
+ pipe = pipeline('sentiment-analysis')
 
6
 
7
  def get_sentiment(input_text):
8
  return pipe(input_text)
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  iface = gr.Interface(fn=get_sentiment,
11
  inputs='text',
12
  outputs='text',