File size: 851 Bytes
2d780cf
 
 
 
 
 
 
 
 
 
 
f9b0d45
2d780cf
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.vision.all import *

repo_id = "Ignaciobfp/Practica8-modelo"

learner = from_pretrained_fastai(repo_id)
labels = ["negative", "positive"]

def predict(opinion):
    pred,pred_idx,probs = learner.predict(opinion)
    print("coco")
    return {labels[i]: float(probs[i]) for i in range(len(labels))}
    
# Creamos la interfaz y la lanzamos. 
gr.Interface(fn=predict, inputs=gr.Textbox(lines=2, placeholder="the movie was neither good or bad"), outputs=gr.outputs.Label(num_top_classes=2),
             examples=['the movie was utter shit I would rater sting a stick in my eyes than seeing something remotely similar to this again', 'is the best movie i have ever seen, had action, romance, science fiction elements. As fun as movies will ever get']).launch(share=False)