emot / app.py
umsee
appscript update
7be925b
raw
history blame
831 Bytes
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()