Spaces:
Sleeping
Sleeping
init
Browse files- Dockerfile +12 -0
- app.py +25 -0
- iris_decision_tree_model.pkl +3 -0
- requirements.txt +6 -0
Dockerfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt requirements.txt
|
| 6 |
+
RUN pip install --upgrade pip && pip install -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
ENV FLASK_APP=app.py
|
| 11 |
+
|
| 12 |
+
CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]
|
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify
|
| 2 |
+
from flask_cors import CORS
|
| 3 |
+
import joblib
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
app = Flask(__name__)
|
| 7 |
+
CORS(app)
|
| 8 |
+
|
| 9 |
+
# Load model
|
| 10 |
+
model = joblib.load("iris_decision_tree_model.pkl")
|
| 11 |
+
|
| 12 |
+
@app.route('/')
|
| 13 |
+
def home():
|
| 14 |
+
return "Model is ready!"
|
| 15 |
+
|
| 16 |
+
@app.route('/predict', methods=['POST'])
|
| 17 |
+
def predict():
|
| 18 |
+
data = request.get_json()
|
| 19 |
+
input_data = np.array(data['input']).reshape(1, -1)
|
| 20 |
+
prediction = model.predict(input_data)
|
| 21 |
+
classes = ['Setosa', 'Versicolor', 'Virginica']
|
| 22 |
+
return jsonify({'prediction': classes[prediction[0]]})
|
| 23 |
+
|
| 24 |
+
if __name__ == '__main__':
|
| 25 |
+
app.run(debug=True)
|
iris_decision_tree_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39b5e9474ff8e310399feea6d24c547b95f8af258cbcbdfe86a91d659755dabd
|
| 3 |
+
size 3329
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
flask-cors
|
| 3 |
+
numpy
|
| 4 |
+
scikit-learn
|
| 5 |
+
pandas
|
| 6 |
+
joblib
|