File size: 630 Bytes
a741c1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

model_path = "d12o6aa/ArabGuard" 
classifier = pipeline("text-classification", model=model_path)


def predict(text, request: gr.Request):
    results = classifier(text)[0]
    return {"label": results['label'], "confidence": round(results['score'], 4)}


demo = gr.Interface(
    fn=predict,
    inputs=gr.Textbox(label="Input Text (Slang/Franco)"),
    outputs=gr.JSON(label="Security Analysis"),
    title="ArabGuard API Gateway",
    description="Secure API for detecting Prompt Injections in Egyptian Dialect."
)


if __name__ == "__main__":
    demo.launch()