Spaces:
Build error
Build error
| 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 demo: | |
| 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]) | |
| demo.launch() |