File size: 831 Bytes
513cffc
6595106
513cffc
 
26b2e49
7be925b
513cffc
 
 
 
6595106
 
 
 
 
e8bd206
 
513cffc
 
 
 
 
 
ea56466
 
26b2e49
513cffc
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import string
from fastai.text.all import *

#loading the model from pretrained weights
model = load_learner('acc.pkl')

labels = ['sadnesss','joy','love','anger','fear','surprise']

def make_prediction(text):
    #text preprocessing
    tr = str.maketrans('','',string.punctuation)
    text=text.translate(tr).lower()
    
    #making prediction by passing to model 
    choice,pos,preds= model.predict(text)
    return {labels[i]:float(preds[i]) for i in range(len(labels))}

title = 'Emotional assist'
description = 'A haphazard tool for the critically inept, god forbid you actually need one of these in the future'
examples =['Hello Everyone!','How are you today','fine, thank you!','Oh my God!']
enable_queue=True

demo = gr.Interface(fn=make_prediction,inputs='text',outputs=gr.Label())

demo.launch()