I have been recently working on creating a cancerous mole detector. For this I made a CNN model and trained it, getting around 86% accuracy and 43% loss. To provide an interface for users, I decided to implement it into a webpage. I got this working as well using Flask, HTML, and CSS. When I uploaded a test non-cancerous image to the website, it returned either 99% confidence, and thus cancerous, or something very close to that (98 ~ 96). This occurs every time, even if the image is unrelated to moles. To see if something was wrong with my model, I did further tests and visualized 10 random images using Matplotlib. These however averaged around 80% ~ 90%. I assume this means my model is fine and something must be wrong with my implementation. Does anyone know what? Relevant Flask code: model = load_model('new_model.h5') decision = '' @app.route('/predict/<path:filename>') def predict(filename): img = image.load_img(os.path.join(app.config['UPLOAD_FOLDER'], filename), target_size=(224, 224)) img_array = image.img_to_array(img) img_array = np.expand_dims(img_array, axis=0) img_array = img_array / 255.0 result = model.predict(img_array)[0][0] if result > 0.5: decision = "Malignant" confidence = result * 100 else: decision = "Benign" confidence = (1 - result) * 100 return render_template('results.html', prediction=confidence, decision=decision, filename=filename) Continue reading...