File size: 683 Bytes
5684b83
 
 
 
d3e13fc
5684b83
7bc13e0
a4ea2cb
f7ad38e
facc99f
5684b83
 
385b3a4
f7ad38e
5684b83
 
7bc13e0
 
f7ad38e
 
 
5684b83
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.text.all import *

repo_id = "paquinon/entregable3"

learner = from_pretrained_fastai(repo_id)

# Etiquetas legibles para el usuario
label_map = {'0': 'Negativo', '1': 'Positivo'}

def predict(text):
    pred_class, _, _ = learner.predict(text)
    return label_map[str(pred_class)]

gr.Interface(
    fn=predict,
    inputs=gr.Textbox(lines=4, placeholder="Escribe el texto aquí..."),
    outputs=gr.Textbox(label="Predicción"),
    title="Clasificador de opiniones sobre películas",
    description="Introduce un texto para predecir si la opinión es positiva o negativa."
).launch(share=False)