carlesabarca commited on
Commit
2839f8d
·
1 Parent(s): e6e702e

Error double render

Browse files
Files changed (1) hide show
  1. app.py +8 -19
app.py CHANGED
@@ -22,7 +22,6 @@ def analyze_text(input_text):
22
  else:
23
  sentiment_label = "Muy positivo"
24
 
25
- # Devolver el resultado con el nivel de confianza
26
  return f"{sentiment_label} ({score}%)", score
27
 
28
  def analyze_pdf(pdf_file):
@@ -34,15 +33,6 @@ def analyze_pdf(pdf_file):
34
  return analyze_text(text)
35
 
36
  # Interfaz de Gradio
37
- text_input = gr.Textbox(label="Ingrese texto para análisis")
38
- pdf_input = gr.File(label="Subir PDF para análisis", file_types=[".pdf"])
39
-
40
- text_output = gr.Label(label="Resultado del análisis")
41
- slider_output = gr.Slider(label="Nivel de sentimiento", minimum=0, maximum=100, interactive=False)
42
-
43
- text_button = gr.Button("Analizar texto")
44
- pdf_button = gr.Button("Analizar PDF")
45
-
46
  def text_analysis(input_text):
47
  sentiment, score = analyze_text(input_text)
48
  return sentiment, score
@@ -53,21 +43,20 @@ def pdf_analysis(pdf_file):
53
 
54
  with gr.Blocks() as app:
55
  gr.Markdown("## Análisis de Sentimientos con DistilBETO")
56
-
57
  with gr.Column():
58
  gr.Markdown("### Análisis de Texto")
59
- text_input.render()
60
- text_button.render()
61
- text_output.render()
62
- slider_output.render()
63
 
64
  text_button.click(text_analysis, inputs=text_input, outputs=[text_output, slider_output])
65
 
 
66
  gr.Markdown("### Análisis de PDF")
67
- pdf_input.render()
68
- pdf_button.render()
69
- text_output.render()
70
- slider_output.render()
71
 
72
  pdf_button.click(pdf_analysis, inputs=pdf_input, outputs=[text_output, slider_output])
73
 
 
22
  else:
23
  sentiment_label = "Muy positivo"
24
 
 
25
  return f"{sentiment_label} ({score}%)", score
26
 
27
  def analyze_pdf(pdf_file):
 
33
  return analyze_text(text)
34
 
35
  # Interfaz de Gradio
 
 
 
 
 
 
 
 
 
36
  def text_analysis(input_text):
37
  sentiment, score = analyze_text(input_text)
38
  return sentiment, score
 
43
 
44
  with gr.Blocks() as app:
45
  gr.Markdown("## Análisis de Sentimientos con DistilBETO")
46
+
47
  with gr.Column():
48
  gr.Markdown("### Análisis de Texto")
49
+ text_input = gr.Textbox(label="Ingrese texto para análisis")
50
+ text_button = gr.Button("Analizar texto")
51
+ text_output = gr.Label(label="Resultado del análisis")
52
+ slider_output = gr.Slider(label="Nivel de sentimiento", minimum=0, maximum=100, interactive=False)
53
 
54
  text_button.click(text_analysis, inputs=text_input, outputs=[text_output, slider_output])
55
 
56
+ with gr.Column():
57
  gr.Markdown("### Análisis de PDF")
58
+ pdf_input = gr.File(label="Subir PDF para análisis", file_types=[".pdf"])
59
+ pdf_button = gr.Button("Analizar PDF")
 
 
60
 
61
  pdf_button.click(pdf_analysis, inputs=pdf_input, outputs=[text_output, slider_output])
62