File size: 1,053 Bytes
19e52c3
 
09d3f66
19e52c3
 
09d3f66
9e5f1df
09d3f66
 
 
d829c3e
 
19e52c3
 
 
 
d829c3e
2969d4e
d829c3e
 
 
 
19e52c3
d829c3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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" #ModernBert
    model = AutoModelForSequenceClassification.from_pretrained(model_name)
    tokenizer = AutoTokenizer.from_pretrained(model_name)
    classifier = pipeline("text-classification", model = model, tokenizer = tokenizer)
    result = classifier(text)[0]  # Récupère le premier résultat
    return f"Label: {result['label']}, Score: {result['score']:.2f}"  # Formatage du résultat

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():  # Correction de l'indentation
            result = gr.Textbox(label="Résultat")
    
    spam_check_btn.click(check_spam, inputs=sms, outputs=result)  # Correction de `input` -> `inputs`

demo.launch(share=True)