from fastai.text.all import* import gradio as gr learn = load_learner('nlp_model.pkl') labels = learn.dls.vocab emotion_labels = labels[1] examples = ["I can't believe you lied to me again! This is unacceptable!", "Got a surprise gift today, feeling overjoyed!"] def classify_text(text): pred,pred_idx,probs = learn.predict(text) return {emotion_labels[i]: float(probs[i]) for i in range(len(emotion_labels))} interface = gr.Interface( fn=classify_text, inputs=gr.components.Textbox( placeholder="Enter Text here", label='Input text', lines=5 ), outputs=gr.components.Label( num_top_classes=4, label='Emotion in the Text' ), title="Emotion Classifier", theme='soft' ) interface.launch()