Spaces:
No application file
No application file
import gradio as gr | |
def EmotionPrediction(emotion): | |
input_text_tokenized = bert_tokenizer.encode(emotion, | |
truncation=True, | |
padding='max_length', | |
return_tensors='tf') | |
bert_predict = bert_load_model(input_text_tokenized) | |
bert_output = tf.nn.softmax(bert_predict[0], axis=-1) | |
Emotions = ['joy','anger','surprise', 'neutral', 'disgust', 'sadness', 'fear', 'shame'] | |
label = tf.argmax(bert_output, axis=1) | |
label = label.numpy() | |
return Emotions[label[0]] | |
iface = gr.Interface(fn=EmotionPrediction, inputs='text', outputs='text') | |
iface.launch() |