import streamlit as st import tensorflow as tf from tensorflow import keras import cv2 st.title(":brain: Brain Tumor Detection (MRI)") vggnet_19= keras.models.load_model("CNN_MODEL_0_9687.h5") vggnet_16 = keras.models.load_model("CNN_MODEL_0_96414.h5") resnet_152 = keras.models.load_model("CNN_MODEL_0_9794.h5") mobilenet_v3= keras.models.load_model("CNN_MODEL_0_9771.h5") def check_accuracy(model,img_input): y_pred = model.predict(img_input).argmax(axis=1) prediction = model.predict(img_input) if y_pred[0] == 0: return "Target: glioma_tumor",prediction.max() elif y_pred[0] == 1: return "Target: meningioma_tumor",prediction.max() elif y_pred[0] == 2: return "Target: no_tumor",prediction.max() else: return "Target: pituitary_tumor",prediction.max() with st.container(): file = st.file_uploader("Upload the MRI Image") if file is not None: print(file) save_image_path = "./upload_images/"+file.name with open(save_image_path,"wb") as f: f.write(file.getbuffer()) img = cv2.imread(save_image_path) col1,col2 = st.columns(2) with st.container(): if file is not None: with col1: st.write("Original Image:") st.image(file) with col2: st.write("Processed Image:") st.image(cv2.resize(img,(224,224))) else: st.error("First upload image") with st.container(): if file is not None: img = cv2.resize(img,(224,224)) img_input = img.reshape((1,224,224,3)) vgg19,v19 = check_accuracy(vggnet_19,img_input) vgg16,v16 = check_accuracy(vggnet_16,img_input) resnet,r152 = check_accuracy(resnet_152,img_input) mobilenet,mv3 = check_accuracy(mobilenet_v3,img_input) st.subheader(vgg19+" for"+ " VGGNET-19") st.write("accuracy of the image",v19) st.subheader(vgg16+" for"+ " VGGNET-16") st.write("accuracy of the image",v16) st.subheader(resnet+" for"+ " RESNET-152") st.write("accuracy of the image",r152) st.subheader(mobilenet+" for"+ " MOBILENET-V3") st.write("accuracy of the image",mv3)