Spaces:
Runtime error
Runtime error
File size: 707 Bytes
cf40ff7 b658a8c cf40ff7 9e7ab7c 05e2a18 9e7ab7c 05e2a18 9e7ab7c 5f5c8b5 b658a8c d30c3fd 9e7ab7c e2eaef7 36f6736 9e7ab7c |
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 |
import gradio as gr
from setfit import SetFitModel
# Cargar el modelo
model = SetFitModel.from_pretrained("desarrolloasesoreslocales/SetFitArgumentos")
# Mapear las etiquetas
id2label = {0: "49", 1: "994", 2: "1002", 3: "2014"}
# Definir la función de predicción
def predict(payload):
results = model.predict_proba([payload])[0]
return "\n".join([f"Label: {id2label[i]}, Score: {result.item()}" for i, result in enumerate(results)])
# Crear una interfaz Gradio
iface = gr.Interface(
fn=predict,
inputs=gr.inputs.Textbox(),
outputs=gr.outputs.Textbox(),
live=False,
layout='vertical',
title="Clasificador de Texto"
)
# Iniciar la interfaz Gradio
iface.launch()
|