nightfury commited on
Commit
4452fc0
1 Parent(s): 6557836

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +23 -0
App.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ nlp = pipeline("text-classification")
5
+
6
+ def classify_text(input_text):
7
+ result = nlp(input_text)[0]
8
+ return result["label"], result["score"]
9
+
10
+ with gr.Blocks() as demo:
11
+ with gr.Row():
12
+ with gr.Column():
13
+ text_input = gr.Textbox(label="Enter text to classify")
14
+ classify_btn = gr.Button(value="Classify")
15
+ with gr.Column():
16
+ label_output = gr.Textbox(label="Predicted label")
17
+ score_output = gr.Textbox(label="Score")
18
+
19
+ classify_btn.click(classify_text, inputs=text_input, outputs=[label_output, score_output], api_name="classify-text")
20
+ examples = gr.Examples(examples=["This is a positive review.", "This is a negative review."],
21
+ inputs=[text_input])
22
+
23
+ demo.launch()