Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Replace this with your actual Hugging Face model repo (trained using classify.py)
|
5 |
MODEL_NAME = "CIRCL/cwe-vulnerability-classification-codebert-base"
|
6 |
|
7 |
-
# Load the text classification pipeline
|
8 |
classifier = pipeline("text-classification", model=MODEL_NAME, return_all_scores=True)
|
9 |
|
10 |
def classify_cwe(text):
|
@@ -13,7 +11,6 @@ def classify_cwe(text):
|
|
13 |
sorted_results = sorted(results, key=lambda x: x["score"], reverse=True)
|
14 |
return {res["label"]: round(res["score"], 4) for res in sorted_results[:5]}
|
15 |
|
16 |
-
# Create the Gradio interface
|
17 |
interface = gr.Interface(
|
18 |
fn=classify_cwe,
|
19 |
inputs=gr.Textbox(lines=5, placeholder="Enter vulnerability description..."),
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
MODEL_NAME = "CIRCL/cwe-vulnerability-classification-codebert-base"
|
5 |
|
|
|
6 |
classifier = pipeline("text-classification", model=MODEL_NAME, return_all_scores=True)
|
7 |
|
8 |
def classify_cwe(text):
|
|
|
11 |
sorted_results = sorted(results, key=lambda x: x["score"], reverse=True)
|
12 |
return {res["label"]: round(res["score"], 4) for res in sorted_results[:5]}
|
13 |
|
|
|
14 |
interface = gr.Interface(
|
15 |
fn=classify_cwe,
|
16 |
inputs=gr.Textbox(lines=5, placeholder="Enter vulnerability description..."),
|