File size: 557 Bytes
01f65eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()