Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -22,38 +22,40 @@ def home():
|
|
| 22 |
return request.url
|
| 23 |
|
| 24 |
|
| 25 |
-
@app.route("/predict", methods=["POST"])
|
|
|
|
| 26 |
def predict():
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
|
| 55 |
-
except Exception as e:
|
| 56 |
-
|
| 57 |
|
| 58 |
|
| 59 |
# Run the Flask app
|
|
|
|
| 22 |
return request.url
|
| 23 |
|
| 24 |
|
| 25 |
+
# @app.route("/predict", methods=["POST"])
|
| 26 |
+
@app.route("/predict")
|
| 27 |
def predict():
|
| 28 |
+
return "predicted brooo"
|
| 29 |
+
# try:
|
| 30 |
+
# # Debugging: print input code to check if the request is received correctly
|
| 31 |
+
# print("Received code:", request.get_json()["code"])
|
| 32 |
|
| 33 |
+
# data = request.get_json()
|
| 34 |
+
# if "code" not in data:
|
| 35 |
+
# return jsonify({"error": "Missing 'code' parameter"}), 400
|
| 36 |
|
| 37 |
+
# code_input = data["code"]
|
| 38 |
|
| 39 |
+
# # Tokenize the input code using the CodeBERT tokenizer
|
| 40 |
+
# inputs = tokenizer(
|
| 41 |
+
# code_input,
|
| 42 |
+
# return_tensors='pt',
|
| 43 |
+
# truncation=True,
|
| 44 |
+
# padding='max_length',
|
| 45 |
+
# max_length=512
|
| 46 |
+
# )
|
| 47 |
|
| 48 |
+
# # Make prediction using the model
|
| 49 |
+
# with torch.no_grad():
|
| 50 |
+
# outputs = model(**inputs)
|
| 51 |
+
# prediction = outputs.logits.squeeze().item() # Extract the predicted score (single float)
|
| 52 |
|
| 53 |
+
# print(f"Predicted score: {prediction}") # Debugging: Print prediction
|
| 54 |
|
| 55 |
+
# return jsonify({"predicted_score": prediction})
|
| 56 |
|
| 57 |
+
# except Exception as e:
|
| 58 |
+
# return jsonify({"error": str(e)}), 500
|
| 59 |
|
| 60 |
|
| 61 |
# Run the Flask app
|