xiongjie's picture
Update app.py
8baf8a0
raw
history blame contribute delete
792 Bytes
import gradio as gr
import emoji
from simpletransformers.classification import ClassificationModel, ClassificationArgs
CLASS_NAMES = ['angry_face', 'crying_face', 'face_with_crossed-out_eyes', 'face_with_open_mouth', 'flushed_face', 'grinning_face_with_smiling_eyes', 'loudly_crying_face', 'pouting_face', 'slightly_smiling_face', 'smiling_face_with_smiling_eyes', 'sparkles', 'tired_face']
model_args = ClassificationArgs()
model_original = ClassificationModel(
'auto',
'xiongjie/face-expression-ja',
use_cuda=False,
args=model_args,
num_labels=len(CLASS_NAMES)
)
def predict_emoticon(text):
return emoji.emojize(":" + CLASS_NAMES[model_original.predict([text])[0][0]] + ":")
iface = gr.Interface(fn=predict_emoticon, inputs="text", outputs="text")
iface.launch()