Setfit_test / app.py
MiguelHdz's picture
Create app.py
5fdf12f verified
import gradio as gr
from setfit import SetFitModel
# Cargar el modelo
model = SetFitModel.from_pretrained("MiguelHdz/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()