manuelcozar55 commited on
Commit
6a25acd
verified
1 Parent(s): d969e40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -80,7 +80,7 @@ def classify_text(text):
80
  logits = outputs.logits
81
  predicted_class_id = logits.argmax(dim=-1).item()
82
  predicted_label = id2label[predicted_class_id]
83
- return predicted_label, text
84
 
85
  def translate(file, target_language):
86
  # Leer el contenido del archivo subido
@@ -119,8 +119,7 @@ def process_file(file, action, target_language=None, summary_length=None):
119
  else:
120
  with open(file_path, 'r', encoding='utf-8') as f:
121
  text = f.read()
122
- label, document_text = classify_text(text)
123
- return f"Clasificaci贸n: {label}\n\nDocumento:\n{document_text}"
124
  elif action == "Traducir":
125
  return translate(file, target_language)
126
  else:
@@ -166,13 +165,13 @@ with gr.Blocks() as demo:
166
 
167
  def update_visible_elements(action):
168
  if action == "Traducir":
169
- return gr.update(visible=True), gr.update(visible=False), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
170
  elif action == "Resumen":
171
- return gr.update(visible(False)), gr.update(visible(True)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
172
  elif action == "Clasificar":
173
- return gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(True)), gr.update(visible(True)), gr.update(visible(True))
174
  else:
175
- return gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
176
 
177
  action.change(update_visible_elements, inputs=action, outputs=[target_language, summary_length, question, output_text, answer])
178
 
@@ -195,10 +194,5 @@ with gr.Blocks() as demo:
195
  question_button = gr.Button("Hacer Pregunta")
196
  question_button.click(answer_question, inputs=[output_text, question], outputs=answer)
197
 
198
- with gr.Row():
199
- question.render()
200
- question_button.render()
201
- answer.render()
202
-
203
  # Ejecutar la aplicaci贸n Gradio
204
  demo.launch(share=True)
 
80
  logits = outputs.logits
81
  predicted_class_id = logits.argmax(dim=-1).item()
82
  predicted_label = id2label[predicted_class_id]
83
+ return predicted_label
84
 
85
  def translate(file, target_language):
86
  # Leer el contenido del archivo subido
 
119
  else:
120
  with open(file_path, 'r', encoding='utf-8') as f:
121
  text = f.read()
122
+ return classify_text(text)
 
123
  elif action == "Traducir":
124
  return translate(file, target_language)
125
  else:
 
165
 
166
  def update_visible_elements(action):
167
  if action == "Traducir":
168
+ return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
169
  elif action == "Resumen":
170
+ return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
171
  elif action == "Clasificar":
172
+ return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True), gr.update(visible=False)
173
  else:
174
+ return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible(False)), gr.update(visible=False)
175
 
176
  action.change(update_visible_elements, inputs=action, outputs=[target_language, summary_length, question, output_text, answer])
177
 
 
194
  question_button = gr.Button("Hacer Pregunta")
195
  question_button.click(answer_question, inputs=[output_text, question], outputs=answer)
196
 
 
 
 
 
 
197
  # Ejecutar la aplicaci贸n Gradio
198
  demo.launch(share=True)