import streamlit as st import tensorflow as tf from tensorflow.keras.preprocessing import image import numpy as np from sklearn.metrics import classification_report # Load the models model1 = tf.keras.models.load_model("densenet_model.h5") model2 = tf.keras.models.load_model("inception_model.h5") model3 = tf.keras.models.load_model("resnet_model.h5") # Streamlit app st.title("Cancer Prediction App") # Upload image through Streamlit uploaded_file = st.file_uploader("Choose an image...", type="jpg") if uploaded_file is not None: # Read and preprocess the uploaded image img = image.load_img(uploaded_file, target_size=(224, 224)) img_array = image.img_to_array(img) img_array = np.expand_dims(img_array, axis=0) img_array /= 255.0 # Normalize the image # Make a prediction with Model 1 prediction = model1.predict(img_array) predicted_class = np.argmax(prediction[0]) prediction_accuracy = prediction[0][predicted_class] # Display the prediction result st.image(img, caption="Uploaded Image", use_column_width=True) if prediction_accuracy < 0.5: st.write("Prediction (using DenseNet): Not Cancerous") else: st.write("Prediction (using DenseNet): Cancerous") st.write(f"Chance of Cancer (using DenseNet): {prediction_accuracy*100}%") # Make a prediction with Model 2 prediction = model2.predict(img_array) predicted_class = np.argmax(prediction[0]) prediction_accuracy = prediction[0][predicted_class] # Display the prediction result st.image(img, caption="Uploaded Image", use_column_width=True) if prediction_accuracy < 0.5: st.write("Prediction (using Inception V3): Not Cancerous") else: st.write("Prediction (using Inception V3): Cancerous") st.write(f"Chance of Cancer (using Inception V3): {prediction_accuracy*100}%") # Make a prediction with Model 3 prediction = model3.predict(img_array) predicted_class = np.argmax(prediction[0]) prediction_accuracy = prediction[0][predicted_class] # Display the prediction result st.image(img, caption="Uploaded Image", use_column_width=True) if prediction_accuracy <0.5: st.write("Prediction (using Resnet50): Not Cancerous") else: st.write("Prediction (using Resnet50): Cancerous") st.write(f"Chance of Cancer (using Resnet50): {prediction_accuracy*100}%")