File size: 694 Bytes
b5c4b5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0c6b74a
b5c4b5f
0c6b74a
b5c4b5f
0c6b74a
b5c4b5f
 
4517c1b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()