Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ml/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: python app.py
23 changes: 18 additions & 5 deletions ml/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Binary file modified ml/requirements.txt
Binary file not shown.
Loading