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()