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 label is {label} with the probability {score*100:.2f}%" 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"] 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()