AkhilRaja commited on
Commit
be84c47
·
verified ·
1 Parent(s): 69b9cf0

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from flask import Flask, request, jsonify
3
+ import pandas as pd
4
+ import joblib
5
+ from huggingface_hub import hf_hub_download
6
+
7
+ # Download model from Hugging Face Model Hub
8
+ model_path = hf_hub_download(
9
+ repo_id="AkhilRaja/final-report-best-model",
10
+ filename="engine_model.pkl"
11
+ )
12
+
13
+ model = joblib.load(model_path)
14
+
15
+ app = Flask(__name__)
16
+
17
+ @app.route("/predict", methods=["POST"])
18
+ def predict():
19
+ data = request.json
20
+ df = pd.DataFrame([data])
21
+ prediction = model.predict(df)
22
+ return jsonify({"prediction": int(prediction[0])})
23
+
24
+ if __name__ == "__main__":
25
+ app.run(host="0.0.0.0", port=7860)