import os import gradio as gr from transformers import pipeline MODEL_ID = "JyothikaShanmugam/scamshield-muril" HF_TOKEN = os.getenv("HF_TOKEN") classifier = pipeline( task="text-classification", model=MODEL_ID, tokenizer=MODEL_ID, token=HF_TOKEN, truncation=True ) def analyze_text(text): text = (text or "").strip() if not text: return "Please enter a message, URL, or suspicious text.", {} result = classifier(text)[0] label = result["label"] confidence = round(float(result["score"]) * 100, 2) return ( f"Prediction: {label} | Confidence: {confidence}%", {label: float(result["score"])} ) demo = gr.Interface( fn=analyze_text, inputs=gr.Textbox( label="Paste suspicious message, URL, or text", lines=6, placeholder="Example: Your KYC will be blocked today. Click this link immediately..." ), outputs=[ gr.Textbox(label="ScamShield Result"), gr.Label(label="Model Confidence") ], title="ScamShield — Text Scam Detector", description="Privacy-first analysis of user-submitted content." ) demo.launch()