cwchang/multilingual-text-classification-example
0
1import gradio as gr2from transformers import pipeline3 4classifier = pipeline(task='text-classification', model='cwchang/text-classification-model-multilingual', device=-1)5 6def classify(text):7 return classifier(text)[0]["label"]8 9demo = gr.Interface(10 fn=classify,11 inputs=gr.Textbox(placeholder="Please enter the text..."),12 outputs="label",13 examples=[14 ["What's the weather like today?"],15 ["Set an alarm for 7 AM tomorrow"],16 ["Call Mom"],17 ["Send a text to Alex saying, 'I'll be there in 15 minutes'"],18 ["Play some relaxing music"],19 ["Remind me to buy milk when I'm at the grocery store"],20 ["How do I get to the nearest coffee shop?"],21 ["What's the latest news?"],22 ["Translate 'thank you' into Spanish"],23 ["Add a meeting to my calendar for next Monday at 3 PM"],24 ["查詢今天的空氣品質指數"],25 ["明早八點鐘設一個鬧鐘"],26 ["給老闆發一封電子郵件,確認下週會議的時間"],27 ["給李明打個電話,問他晚餐時間是否方便"],28 ["播放一首運動時的動感音樂"],29 ["我到圖書館時,提醒我還書"],30 ["告訴我到最近的郵局怎麼走"],31 ["播報一下今天的頭條新聞"],32 ["將“生日快樂”翻譯成法語"],33 ["在下週三上午10點的日程中加入牙醫預約"],]34 )35 36demo.launch()