|
import gradio as gr |
|
from fastai.text.all import * |
|
from fastai.text.all import * |
|
from datasets import load_dataset |
|
from spacy.lemmatizer import Lemmatizer |
|
|
|
learn = load_learner('export.pkl') |
|
labels = ['anger','joy','optimism','sadness'] |
|
|
|
def predict(text): |
|
aux1,aux2,probs = learn.predict(text) |
|
return {labels[i]: float(probs[i]) for i in range(len(labels))} |
|
|
|
|
|
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(lines=3,placeholder="Type a phrase that has some emotion",label="Input Text",), outputs=gr.outputs.Label(num_top_classes=4),examples=[ |
|
'No but thats so cute. Atsu was probably shy about photos before but cherry helped her out uwu ', |
|
]).launch(share=False) |