|
|
import gradio as gr |
|
|
from transformers import pipeline |
|
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification |
|
|
|
|
|
def check_spam(text): |
|
|
classifier = pipeline("text-classification") |
|
|
model_name = "ericjedha/spammy_overfit" |
|
|
model = AutoModelForSequenceClassification.from_pretrained(model_name) |
|
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
|
classifier = pipeline("text-classification", model = model, tokenizer = tokenizer) |
|
|
result = classifier(text)[0] |
|
|
return f"Label: {result['label']}, Score: {result['score']:.2f}" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
sms = gr.Textbox(label="SMS à checker") |
|
|
spam_check_btn = gr.Button("Check") |
|
|
with gr.Column(): |
|
|
result = gr.Textbox(label="Résultat") |
|
|
|
|
|
spam_check_btn.click(check_spam, inputs=sms, outputs=result) |
|
|
|
|
|
demo.launch(share=True) |
|
|
|