File size: 796 Bytes
480132b
 
e5ab01f
480132b
 
 
 
 
 
9c2d65a
11a7cfb
 
 
 
480132b
38ee1c2
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from fastai.text.all import *
from huggingface_hub import from_pretrained_fastai

repo_id = "humellad/entregable_3"

learn = from_pretrained_fastai(repo_id)

def predict(text):
    pred, pred_idx, probs = learn.predict(text)
    
    vocab = learn.dls.vocab[1] 
    
    return {vocab[i]: float(probs[i]) for i in range(len(vocab))}

sample_examples = [
    ["i never make her separate from me because i don t ever want her to feel like i m ashamed with her"],
    ["This makes me feel very sad and lonely."],
    ["I am absolutely furious about the delay."],
    ["It's a beautiful day to go for a walk in the park."],
    ["I feel a bit nervous about the upcoming presentation."]
]

gr.Interface(fn=predict, inputs="text", outputs="label", examples=sample_examples).launch()