feynmanl commited on
Commit
eae71ca
1 Parent(s): c4ca714
Files changed (2) hide show
  1. app.py +15 -0
  2. 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