Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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=
|
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)",
|