File size: 771 Bytes
88b6f30
 
 
ccdac2b
 
 
c40ebdf
 
ccdac2b
c40ebdf
ccdac2b
b61d174
ccdac2b
 
 
 
 
 
 
 
b61d174
ccdac2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from transformers import pipeline
import gradio as gr

pipe = pipeline("text-classification", model="muhnatha/distilbert-base-uncased-game")

def actor_game(emotion, text):
    pred_emotion = pipe(text)
    if pred_emotion[0]['label'] == emotion:
        return "YOU WON",emotion,pred_emotion[0]['label']
    else:
        return "YOU LOSE",emotion,pred_emotion[0]['label']

iface = gr.Interface(
    fn=actor_game,
    inputs=[gr.Textbox(label="What emotion do you want to train?",placeholder = "joy, sadness, fear, surprise, love, anger"), 
            gr.Textbox(label="your dialog")],
    outputs=[gr.Textbox(label="Result"),gr.Textbox(label="Expected"),gr.Textbox(label="your emotion")],
    title="Be an Actor",
    description="Type your dialog",
)

iface.launch()