Spaces:
Sleeping
Sleeping
from huggingface_hub import from_pretrained_fastai | |
import gradio as gr | |
from fastai.vision.all import * | |
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME" | |
repo_id = "joelmateo14/peliculas" | |
learner = from_pretrained_fastai(repo_id) | |
labels = learner.dls.vocab | |
# Definimos una función que se encarga de llevar a cabo las predicciones | |
def predict(text): | |
pred,pred_idx,probs = learner.predict(text) | |
if (pred=="0"): | |
return "neg" | |
elif (pred=="1"): | |
return "pos" | |
else: | |
return "error" | |
# Creamos la interfaz y la lanzamos. | |
gr.Interface(fn=predict, inputs="text", outputs="label",examples=["i would not watch it again", "it is amazing one of my favorites"]).launch() |