File size: 792 Bytes
00fae30
c41c5d1
 
00fae30
c41c5d1
 
 
 
 
 
a479071
c41c5d1
b541280
c41c5d1
 
 
8baf8a0
00fae30
4d59a38
00fae30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()