File size: 1,165 Bytes
6d26cc9
 
 
 
 
 
 
 
 
a4fd093
6d26cc9
 
56bad1a
6d26cc9
 
 
 
6988a7c
6d26cc9
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()