Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| classifier = pipeline(task="text-classification", model="christinacdl/XLM_RoBERTa-Clickbait-Detection-new") | |
| def text_classification(text): | |
| result= classifier(text) | |
| label = result[0]['label'] | |
| score = result[0]['score'] | |
| formatted_output = f"The text's label is {label}. I am {score*100:.2f}% sure!" | |
| return formatted_output | |
| examples=["Your Old Passport Will Be Replaced With Smart E-passport, Here Is Everything You Need To Know", "17 Things That Are Too Real For People Who Always Drop Their Phone", "Israeli Companies Seek a Worldwide Profile", "Venus Williams beats Marion Bartoli to triumph at Wimbledon"] | |
| gradio_app = gr.Interface(fn=text_classification, | |
| inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter text here..."), | |
| outputs=gr.Textbox(lines=2, label="Text Classification Result"), | |
| title="Is It Clickbait?", | |
| description="Enter a text to check if it is clickbait or not!", | |
| examples=examples) | |
| if __name__ == "__main__": | |
| gradio_app.launch() |