ankush-003 commited on
Commit
bb27896
1 Parent(s): 93b0079

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -1,17 +1,21 @@
1
  import gradio as gr
2
- def predict(payload, payload_label):
3
- inputs = tokenizer(test_payload, return_tensors="tf")
 
 
 
 
4
  model = TFAutoModelForSequenceClassification.from_pretrained("models/ankush-003/nosqli_identifier")
5
  logits = model(**inputs).logits
6
  predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])
7
  # print(model.config.id2label[predicted_class_id])
8
- return model.config.id2label[predicted_class_id]
9
- # return "Fuck You"
10
 
11
  demo = gr.Interface(
12
  fn=predict,
13
  inputs=["text","checkbox"],
14
- outputs="text",
15
  )
16
  demo.launch(debug=True)
17
  # gr.Interface.load("models/ankush-003/nosqli_identifier").launch()
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer
3
+
4
+ tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
5
+
6
+ def predict(payload, malitious):
7
+ inputs = tokenizer(payload, return_tensors="tf")
8
  model = TFAutoModelForSequenceClassification.from_pretrained("models/ankush-003/nosqli_identifier")
9
  logits = model(**inputs).logits
10
  predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])
11
  # print(model.config.id2label[predicted_class_id])
12
+ expected = "Malitious" if malitious else "Benign"
13
+ return model.config.id2label[predicted_class_id], expected
14
 
15
  demo = gr.Interface(
16
  fn=predict,
17
  inputs=["text","checkbox"],
18
+ outputs=["text","text"]
19
  )
20
  demo.launch(debug=True)
21
  # gr.Interface.load("models/ankush-003/nosqli_identifier").launch()