kitrofimov commited on
Commit
1f140b1
·
1 Parent(s): 53a58d8

Add examples

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -3,6 +3,12 @@ from transformers import pipeline
3
 
4
  pipe = pipeline("text-classification", model="kitrofimov/news-clf", top_k=3)
5
  label_names = dict(zip([f"LABEL_{i}" for i in range(4)], ["World", "Sports", "Business", "Sci/Tech"]))
 
 
 
 
 
 
6
 
7
  def classify(text):
8
  preds = pipe(text)[0]
@@ -16,6 +22,7 @@ with gr.Blocks() as demo:
16
  with gr.Row():
17
  with gr.Column():
18
  input = gr.Textbox(lines=5, placeholder="Enter your news article...")
 
19
  classify_btn = gr.Button("Classify")
20
  with gr.Column():
21
  output = gr.Label(num_top_classes=3)
 
3
 
4
  pipe = pipeline("text-classification", model="kitrofimov/news-clf", top_k=3)
5
  label_names = dict(zip([f"LABEL_{i}" for i in range(4)], ["World", "Sports", "Business", "Sci/Tech"]))
6
+ examples = [
7
+ ["NASA announces new discovery on Mars water."],
8
+ ["Stock markets rally after positive earnings report."],
9
+ ["Lionel Messi scores a hat-trick in the Champions League."],
10
+ ["UN summit discusses climate change and global policies."]
11
+ ]
12
 
13
  def classify(text):
14
  preds = pipe(text)[0]
 
22
  with gr.Row():
23
  with gr.Column():
24
  input = gr.Textbox(lines=5, placeholder="Enter your news article...")
25
+ gr.Examples(examples=examples, inputs=input)
26
  classify_btn = gr.Button("Classify")
27
  with gr.Column():
28
  output = gr.Label(num_top_classes=3)