Spaces:
Sleeping
Sleeping
chienweichang
commited on
Commit
•
1c631a1
1
Parent(s):
ebed740
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
classifier = pipeline(task='text-classification', model='cwchang/my-awesome-tx-v2', device=-1)
|
5 |
+
|
6 |
+
def classify(text):
|
7 |
+
return classifier(text)[0]["label"]
|
8 |
+
|
9 |
+
demo = 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 |
+
demo.launch()
|
27 |
+
|
28 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6572d7f2755a113a326c5f3c/-CVYPibponj8mYw_PyEOl.png)
|