smjain commited on
Commit
8443d3b
·
1 Parent(s): 366df9c

Create new file

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipe = pipeline(task="text-classification",
5
+ model="mrm8488/codebert-base-finetuned-detect-insecure-code")
6
+ gr.Interface.from_pipeline(pipe,
7
+ title="Insecure Code Detector",
8
+ description="LABEL_0 for secure code, LABEL_1 for insecure code\n\nThis app identifies whether the input code is vulnerable to cyber attacks that may cause harm to systems such as theft or loss of valuable data. (Other examples of code in examples.txt under Files and versions)",
9
+ inputs = gr.inputs.Textbox(placeholder="Type or paste code here", label="Input"),
10
+ examples = [['def search(arr, low, high, x): if high >= low: mid = (high + low) // 2 if arr[mid] == x: return mid elif arr[mid] > x: return search(arr, low, mid - 1, x) else: return search(arr, mid + 1, high, x) else: return -1'],["def foo(request, user): assert user.is_admin, “user does not have access”"]],
11
+ allow_flagging="never").launch(inbrowser=True)