Laura Cabayol Garcia commited on
Commit
8bac453
·
1 Parent(s): 57f29d4

directory with necessary files to access model over the intrnet with HF

Browse files
Files changed (3) hide show
  1. UI_app/app.py +27 -0
  2. UI_app/model.pkl +0 -0
  3. UI_app/requirements.txt +10 -0
UI_app/app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ import pickle
3
+ import numpy as np
4
+
5
+ app = Flask(__name__)
6
+
7
+ # Load the model from the pickle file
8
+ with open('model.pkl', 'rb') as f:
9
+ model = pickle.load(f)
10
+
11
+ @app.route('/')
12
+ def home():
13
+ return "Welcome to the Penguin Classifier API!"
14
+
15
+ @app.route('/predict', methods=['POST'])
16
+ def predict():
17
+ # Parse input features from the request body (assumed to be JSON)
18
+ data = request.get_json()
19
+ features = np.array(data['features']).reshape(1, -1)
20
+
21
+ # Make prediction
22
+ prediction = model.predict(features).tolist()
23
+
24
+ return jsonify({'prediction': prediction})
25
+
26
+ if __name__ == "__main__":
27
+ app.run(debug=True)
UI_app/model.pkl ADDED
Binary file (642 kB). View file
 
UI_app/requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ mlflow==2.16.2
2
+ cloudpickle==3.0.0
3
+ ipykernel==6.29.5
4
+ loguru==0.7.2
5
+ numpy==2.1.1
6
+ pandas==2.2.3
7
+ python-dotenv==1.0.1
8
+ scikit-learn==1.5.2
9
+ scipy==1.14.1
10
+ gradio==3.1