|
import gradio as gr |
|
import string |
|
from fastai.text.all import * |
|
|
|
|
|
model = load_learner('acc.pkl') |
|
|
|
labels = ['sadnesss','joy','love','anger','fear','surprise'] |
|
|
|
def make_prediction(text): |
|
|
|
tr = str.maketrans('','',string.punctuation) |
|
text=text.translate(tr).lower() |
|
|
|
|
|
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() |
|
|
|
|
|
|