diff --git a/ml/Procfile b/ml/Procfile new file mode 100644 index 0000000..2e35818 --- /dev/null +++ b/ml/Procfile @@ -0,0 +1 @@ +web: python app.py diff --git a/ml/app.py b/ml/app.py index 79b7a61..b90d013 100644 --- a/ml/app.py +++ b/ml/app.py @@ -2,8 +2,13 @@ import tensorflow as tf import numpy as np from PIL import Image +from flask_cors import CORS + + app = Flask(__name__) +CORS(app) + # Load the trained model model = tf.keras.models.load_model("./model/image_classifier_model.h5") @@ -37,11 +42,19 @@ # Image preprocessing def preprocess_image(image): - image = image.resize((224, 224)) # <-- Change this to 224x224 - image = np.array(image) / 255.0 - image = np.expand_dims(image, axis=0) + image = image.convert('RGB') # Ensure RGB + image = image.resize((224, 224)) # Resize to model input size + image = np.array(image) / 255.0 # Normalize + image = np.expand_dims(image, axis=0) # Add batch dimension return image +@app.route('/') +def home(): + return 'SkinAI Flask Server is running' + + + + @app.route('/predict', methods=['POST']) def predict(): if 'file' not in request.files: @@ -58,5 +71,5 @@ def predict(): return jsonify({'class': predicted_class, 'confidence': confidence}) -if __name__ == "__main__": - app.run(debug=True) +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/ml/requirements.txt b/ml/requirements.txt index 7fdb927..986797b 100644 Binary files a/ml/requirements.txt and b/ml/requirements.txt differ