spammy / app.py
ericjedha's picture
Update app.py
9e5f1df verified
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)