File size: 1,027 Bytes
7dbe682
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
from setfit import SetFitModel

# Cargar el modelo
model = SetFitModel.from_pretrained("rovargasc/modelopruebaUNAL2")

def predict_text(text):
    """Función para hacer predicciones con el modelo"""
    if not text.strip():
        return "Por favor ingresa un texto"
    
    try:
        prediction = model(text)
        return f"Predicción: {prediction}"
    except Exception as e:
        return f"Error: {str(e)}"

# Crear la interfaz
interface = gr.Interface(
    fn=predict_text,
    inputs=gr.Textbox(
        lines=3, 
        placeholder="Escribe tu texto aquí...",
        label="Texto de entrada"
    ),
    outputs=gr.Textbox(label="Resultado"),
    title="Clasificador de Texto - SetFit Model",
    description="Ingresa un texto para obtener una predicción del modelo SetFit",
    examples=[
        ["This movie is amazing!"],
        ["I don't like this product"],
        ["chokes on its own depiction of upper-crust decorum."]
    ]
)

if __name__ == "__main__":
    interface.launch()