Spaces:
Sleeping
Sleeping
File size: 818 Bytes
0a92d69 c5cd223 0a92d69 c5cd223 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import pipeline
nlp = pipeline("text-classification")
def classify_text(input_text):
result = nlp(input_text)[0]
return result["label"], result["score"]
with gr.Blocks() as app:
with gr.Row():
with gr.Column():
text_input = gr.Textbox(label="Enter text to classify")
classify_btn = gr.Button(value="Classify")
with gr.Column():
label_output = gr.Textbox(label="Predicted label")
score_output = gr.Textbox(label="Score")
classify_btn.click(classify_text, inputs=text_input, outputs=[label_output, score_output], api_name="classify-text")
examples = gr.Examples(examples=["This is a positive review.", "This is a negative review."],
inputs=[text_input])
app.launch() |