nlp-goemotions-senti-pred / gradio_app.py
cspocketindia
first commit
01f65eb
raw
history blame
557 Bytes
import gradio
from src.models.bert import BERTClassifier
from src.utils.utilities import Utility
model = BERTClassifier(model_name='Bert_GoEmotions_4Epochs.model')
classes = Utility().read_emotion_list()
def predict(sentence):
print(sentence)
predictions = model.evaluate([sentence])
print(f"Predictions: {predictions}")
return classes[predictions[0]]
gradio.Interface(
fn=predict,
inputs="text",
outputs="text",
allow_flagging='auto',
flagging_dir='logs',
flagging_callback=gradio.SimpleCSVLogger(),
).launch()