Spaces:
Running
Running
| import gradio as gr | |
| from transformers import pipeline | |
| print("π Loading CyberGuard Model...") | |
| classifier = pipeline("text-classification", model="Jishnuuuu/cyberguard-v1") | |
| print("β Model loaded successfully!") | |
| def analyze_message(text): | |
| """Analyze message for cyberbullying threats""" | |
| if not text or len(text.strip()) == 0: | |
| return {"Label": "ERROR", "Confidence": 0.0} | |
| try: | |
| result = classifier(text)[0] | |
| return { | |
| "Label": result['label'], | |
| "Confidence": round(result['score'], 3) | |
| } | |
| except Exception as e: | |
| return {"Label": "ERROR", "Confidence": 0.0, "error": str(e)} | |
| demo = gr.Interface( | |
| fn=analyze_message, | |
| inputs=gr.Textbox(label="Message", placeholder="Type a message..."), | |
| outputs=gr.JSON(label="Result"), | |
| title="π‘οΈ CyberGuard AI", | |
| description="Cyberbullying Detection - Model: Jishnuuuu/cyberguard-v1" | |
| ) | |
| demo.launch() |