Spaces:
Runtime error
Runtime error
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
model_path = "d12o6aa/ArabGuard"
|
| 6 |
+
classifier = pipeline("text-classification", model=model_path)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def predict(text, request: gr.Request):
|
| 10 |
+
results = classifier(text)[0]
|
| 11 |
+
return {"label": results['label'], "confidence": round(results['score'], 4)}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
demo = gr.Interface(
|
| 15 |
+
fn=predict,
|
| 16 |
+
inputs=gr.Textbox(label="Input Text (Slang/Franco)"),
|
| 17 |
+
outputs=gr.JSON(label="Security Analysis"),
|
| 18 |
+
title="ArabGuard API Gateway",
|
| 19 |
+
description="Secure API for detecting Prompt Injections in Egyptian Dialect."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
demo.launch()
|