ankush-003 commited on
Commit
e646e66
1 Parent(s): 915d3e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -28,8 +28,11 @@ def predict(username, pwd, label, payload_text = None):
28
  # predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])
29
  # print(model.config.id2label[predicted_class_id])
30
  prediction = classifier(payload_text)
31
-
32
- return payload_text, prediction[0]['label'], prediction[0]['score'] * 100
 
 
 
33
 
34
  input_elements = [gr.Textbox(label="Enter Username"), gr.Textbox(label="Enter Password"), gr.Dropdown(["Malicious", "Benign"], label="Expected", info="Enter expected value"),
35
  gr.Textbox(label="Enter Payload", info="Optional if username and password entered already")]
@@ -39,7 +42,7 @@ demo = gr.Interface(
39
  description="DistilBERT-based NoSQL Injection Payload Detection Model",
40
  fn=predict,
41
  inputs=input_elements,
42
- outputs=[gr.Textbox(label="Generated Payload"), gr.Textbox(label="Model Prediction"), gr.Slider(0, 100, label="Score")]
43
  )
44
  demo.launch(debug=True)
45
  # gr.Interface.load("models/ankush-003/nosqli_identifier").launch()
 
28
  # predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])
29
  # print(model.config.id2label[predicted_class_id])
30
  prediction = classifier(payload_text)
31
+ scores = {
32
+ prediction[0]['label']: prediction[0]['score'] * 100
33
+
34
+ }
35
+ return payload_text, scores
36
 
37
  input_elements = [gr.Textbox(label="Enter Username"), gr.Textbox(label="Enter Password"), gr.Dropdown(["Malicious", "Benign"], label="Expected", info="Enter expected value"),
38
  gr.Textbox(label="Enter Payload", info="Optional if username and password entered already")]
 
42
  description="DistilBERT-based NoSQL Injection Payload Detection Model",
43
  fn=predict,
44
  inputs=input_elements,
45
+ outputs=[gr.Textbox(label="Generated Payload"), gr.Label(label="Scores")]
46
  )
47
  demo.launch(debug=True)
48
  # gr.Interface.load("models/ankush-003/nosqli_identifier").launch()