File size: 899 Bytes
1c0f547
 
 
cb66b8a
1c0f547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce6fa48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
from transformers import pipeline

classifier = pipeline(task='text-classification', model='cwchang/my-text-classification-finetuned-v1', device=-1)

def classify(text):
    return classifier(text)[0]["label"]

demo = gr.Interface(
    fn=classify,
    inputs=gr.Textbox(placeholder="請輸入一段文字..."),
    outputs="label",
    examples=[["Take me to church"],
        ["What's the weather like today?"],
        ["Set an alarm for 7 AM tomorrow"],
        ["Call Mom"],
        ["Send a text to Alex saying, 'I'll be there in 15 minutes'"],
        ["Play some relaxing music"],
        ["Remind me to buy milk when I'm at the grocery store"],
        ["How do I get to the nearest coffee shop?"],
        ["What's the latest news?"],
        ["Translate 'thank you' into Spanish"],
        ["Add a meeting to my calendar for next Monday at 3 PM"]]
    )

demo.launch()