elselse commited on
Commit
c364fcb
·
verified ·
1 Parent(s): ad4dbf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import torch
3
  import json
4
- import base64
5
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
6
 
7
  model_path = "CIRCL/cwe-parent-vulnerability-classification-roberta-base"
@@ -36,13 +35,12 @@ def predict_ancestors(input_text):
36
  ancestor = child_to_ancestor.get(cwe_child, "N/A")
37
  results.append(f"{i}. CWE-{cwe_child} (ancestor: CWE-{ancestor}) - {score:.4f}")
38
 
39
- return results
40
 
41
- # Interface Gradio
42
  gr.Interface(
43
  fn=predict_ancestors,
44
  inputs=gr.Textbox(label="Commit message or patch (e.g., 'hg')"),
45
- outputs=gr.outputs.Textbox(label="Top 5 Predicted CWE Ancestors"),
46
  title="CWE Ancestor Predictor",
47
  description="Entrez un message de commit ou un patch. Le modèle prédit les 5 CWE enfants les plus probables et affiche leurs ancêtres."
48
  ).launch()
 
1
  import gradio as gr
2
  import torch
3
  import json
 
4
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
5
 
6
  model_path = "CIRCL/cwe-parent-vulnerability-classification-roberta-base"
 
35
  ancestor = child_to_ancestor.get(cwe_child, "N/A")
36
  results.append(f"{i}. CWE-{cwe_child} (ancestor: CWE-{ancestor}) - {score:.4f}")
37
 
38
+ return "\n".join(results)
39
 
 
40
  gr.Interface(
41
  fn=predict_ancestors,
42
  inputs=gr.Textbox(label="Commit message or patch (e.g., 'hg')"),
43
+ outputs=gr.Textbox(label="Top 5 Predicted CWE Ancestors"),
44
  title="CWE Ancestor Predictor",
45
  description="Entrez un message de commit ou un patch. Le modèle prédit les 5 CWE enfants les plus probables et affiche leurs ancêtres."
46
  ).launch()