Spaces:
Runtime error
Runtime error
Adds demo
Browse files- app.py +15 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
pipe = pipeline(model="fmops/distilbert-prompt-injection")
|
6 |
+
id2label = {
|
7 |
+
'LABEL_0': 'benign',
|
8 |
+
'LABEL_1': 'prompt injection'
|
9 |
+
}
|
10 |
+
|
11 |
+
def greet(prompt):
|
12 |
+
return {id2label[x['label']]: x['score'] for x in pipe(prompt)}
|
13 |
+
|
14 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="label")
|
15 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|