From 7623871ac1f334f20396110959c0d71a1e340bfd Mon Sep 17 00:00:00 2001 From: Sameer Shaik Date: Fri, 30 May 2025 23:32:04 +0530 Subject: [PATCH 1/4] feat: add Procfile and update app.py to run on host and port --- ml/Procfile | 1 + ml/app.py | 9 +++++++-- ml/requirements.txt | Bin 2572 -> 2610 bytes 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 ml/Procfile 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..81be781 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") @@ -58,5 +63,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 7fdb9279d2d79de09749f406cfb1298b892d31d7..8d53b49e356c6215fadde146dcf3d7daf28119f0 100644 GIT binary patch delta 36 qcmeAX*(9=I3!`{3LpFmhLo!1?LlHwUgDnu6G3YTEY+lNk&H(_eBM5r{ delta 12 Tcmdla(j&5A3*+Wnj1e3FA%FzB From ba72bd4ac6b8442a1a41423990cffce9a1aa56fc Mon Sep 17 00:00:00 2001 From: Sameer Shaik Date: Fri, 30 May 2025 23:34:09 +0530 Subject: [PATCH 2/4] fix: ensure image is converted to RGB before preprocessing --- ml/app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ml/app.py b/ml/app.py index 81be781..55b78ad 100644 --- a/ml/app.py +++ b/ml/app.py @@ -42,11 +42,13 @@ # 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('/predict', methods=['POST']) def predict(): if 'file' not in request.files: From 5b961b88638bb9153073de0662e8848dab204b32 Mon Sep 17 00:00:00 2001 From: Sameer Shaik Date: Fri, 30 May 2025 23:35:18 +0530 Subject: [PATCH 3/4] feat: add home route to confirm server is running --- ml/app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ml/app.py b/ml/app.py index 55b78ad..b90d013 100644 --- a/ml/app.py +++ b/ml/app.py @@ -48,6 +48,12 @@ def preprocess_image(image): 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(): From 57b9c1c2e033a8f2c0ed70692f351db262b6db39 Mon Sep 17 00:00:00 2001 From: Sameer Shaik Date: Fri, 30 May 2025 23:46:16 +0530 Subject: [PATCH 4/4] chore: update requirements.txt to reflect changes in dependencies --- ml/requirements.txt | Bin 2610 -> 122 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/ml/requirements.txt b/ml/requirements.txt index 8d53b49e356c6215fadde146dcf3d7daf28119f0..986797b9d8b8661e8d8d262762f1bc14f9471cb8 100644 GIT binary patch literal 122 zcmYL>TMB?M32I+Ju)LdkZ6m8GUps~gu>E9M9 literal 2610 zcmZ{m&2AGx5QOK9#G^Qh?fk%j0~Zd6NJtzIC$zC0+p)8Dyz4m0!vpno?d&WPC~~4~ z_taEZSNHn&uPWW9CT-Iw?bA#8pr1)POJjY`)7$hWRf@Lhm} z3Sq6BjiQG>{=P?<#q(AThYqsZKlLJ?I(uuRZ!yXD;Hb zPZ6Ezc97q7nD08ooz8+%1r8bK-RY}7qgIVORe9)DFe}*kh8N*)`};u{cS;eTM`d?H zKp#}f_e>*e5-8LT27EGGDj5f7>-|YlGoE%qLZP+j$na&raY>tBMxkmnP7&CY-Qaopn%_ zb+sl&q+({0eN^?c0mfv&doTQLD1Qnz<8X}G7y&P{L%nr4kD`-QX6dV{UWRsToZ|X% z`3wJ^#S&n`4ZBZRej z;<;gWGEw#dx|glu%~zCYYBl}q1e-^3`EN