Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from fastai.text.all import * | |
| from huggingface_hub import from_pretrained_fastai | |
| repo_id = "aiarenm/yelp-text-classification" | |
| learner = from_pretrained_fastai(repo_id) | |
| labels = ["Negativo", "Positivo"] | |
| def predict(text): | |
| pred, pred_idx, probs = learner.predict(text) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| iface = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Textbox(lines=2, placeholder="Ingresa el texto de la opinión aquí..."), | |
| outputs=gr.Label(num_top_classes=2), | |
| title="Análisis de Sentimiento de Opiniones de Yelp", | |
| description="Un modelo FastAI para clasificar opiniones de Yelp como positivas o negativas." | |
| ) | |
| iface.launch() |