ElPremOoO commited on
Commit
e10e5ff
·
verified ·
1 Parent(s): 87bf892

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -3
main.py CHANGED
@@ -8,7 +8,7 @@ app = Flask(__name__)
8
  # Load model and tokenizer
9
  def load_model():
10
  # Load saved config and weights
11
- checkpoint = torch.load("codebert_readability_scorer.pth", map_location=torch.device('cpu'))
12
  config = RobertaConfig.from_dict(checkpoint['config'])
13
 
14
  # Initialize model with loaded config
@@ -19,7 +19,7 @@ def load_model():
19
 
20
  # Load components
21
  try:
22
- tokenizer = RobertaTokenizer.from_pretrained("./tokenizer_readability")
23
  model = load_model()
24
  print("Model and tokenizer loaded successfully!")
25
  except Exception as e:
@@ -54,7 +54,7 @@ def predict():
54
  score = torch.sigmoid(outputs.logits).item()
55
 
56
  return jsonify({
57
- "readability_score": round(score, 4),
58
  "processed_code": code[:500] + "..." if len(code) > 500 else code
59
  })
60
 
 
8
  # Load model and tokenizer
9
  def load_model():
10
  # Load saved config and weights
11
+ checkpoint = torch.load("codebert_vulnerability_scorer.pth", map_location=torch.device('cpu'))
12
  config = RobertaConfig.from_dict(checkpoint['config'])
13
 
14
  # Initialize model with loaded config
 
19
 
20
  # Load components
21
  try:
22
+ tokenizer = RobertaTokenizer.from_pretrained("./tokenizer_vulnerability")
23
  model = load_model()
24
  print("Model and tokenizer loaded successfully!")
25
  except Exception as e:
 
54
  score = torch.sigmoid(outputs.logits).item()
55
 
56
  return jsonify({
57
+ "vulnerability_score": round(score, 4),
58
  "processed_code": code[:500] + "..." if len(code) > 500 else code
59
  })
60