Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
classifier = pipeline(task='text-classification', model='cwchang/my-text-classification-finetuned-v1', device=0)
|
| 5 |
+
|
| 6 |
+
def classify(text):
|
| 7 |
+
return classifier(text)[0]["label"]
|
| 8 |
+
|
| 9 |
+
demo = gr.Interface(
|
| 10 |
+
fn=classify,
|
| 11 |
+
inputs=gr.Textbox(placeholder="請輸入一段文字..."),
|
| 12 |
+
outputs="label",
|
| 13 |
+
examples=[["Take me to church"],
|
| 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 |
+
demo.launch(debug=True)
|