AndresR2909 commited on
Commit
1d1e9f1
1 Parent(s): 94da137

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -36,12 +36,23 @@ pipeline = TextClassificationPipeline(tokenizer, distilbert_model, xgb_model)
36
  def predict_api(texts: List[str]) -> List[int]:
37
  # Hacer predicciones (usando el pipeline precargado)
38
  predictions = [pipeline(text)[0] for text in texts]
39
-
40
  return predictions
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  # Crear la interfaz (opcional)
43
  iface = gr.Interface(
44
- fn=predict_api,
45
  inputs=gr.Textbox(lines=2, placeholder="Introduce un texto aquí..."),
46
  outputs="text",
47
  title="Clasificación de Texto (API)",
 
36
  def predict_api(texts: List[str]) -> List[int]:
37
  # Hacer predicciones (usando el pipeline precargado)
38
  predictions = [pipeline(text)[0] for text in texts]
39
+
40
  return predictions
41
 
42
+ # Crear la interfaz de Gradio
43
+ def main(text):
44
+ # Conversión de texto a lista (fuera de la función predict)
45
+ string_list = [text]
46
+ pred = predict_api(string_list)
47
+ if pred[0] == 0:
48
+ return "Normal"
49
+ else:
50
+ return "Relacionado con suicidio"
51
+
52
+
53
  # Crear la interfaz (opcional)
54
  iface = gr.Interface(
55
+ fn=main,
56
  inputs=gr.Textbox(lines=2, placeholder="Introduce un texto aquí..."),
57
  outputs="text",
58
  title="Clasificación de Texto (API)",