cyberguard-api / app.py
Jishnuuuu's picture
Update app.py
9e2f571 verified
raw
history blame contribute delete
938 Bytes
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()