Spaces:
Build error
Build error
| import streamlit as st | |
| import tensorflow as tf | |
| from PIL import Image | |
| import os | |
| model = tf.keras.models.load_model('Brain_tumor/') | |
| st.write('Model is loaded successfully') | |
| TEMP_DIR = 'temp' | |
| if not os.path.exists(TEMP_DIR): | |
| os.makedirs(TEMP_DIR) | |
| class_names = ['glioma', 'meningioma', 'notumor', 'pituitary'] | |
| def load_and_prep_imgg(filename ,img_shape=229, scale=True): | |
| img = tf.io.read_file(filename) | |
| img = tf.io.decode_image(img) | |
| img = tf.image.resize(img,size=[img_shape,img_shape]) | |
| if scale : | |
| return img/255 | |
| else : | |
| return img | |
| st.title('Brain Tumor Classidfication Predition using Xception ImageNet ') | |
| uploaded_file = st.sidebar.file_uploader('Upload your Image', type=['jpg']) | |
| if uploaded_file: | |
| #file_path = os.path.join(uploaded_file.name) | |
| img = load_and_prep_imgg(uploaded_file.name,scale=True) | |
| imgg = Image.open(uploaded_file.name) | |
| st.image(img,caption ="Predicted brain tumor is : {pred_class} with probs : {pred_img:max():.2f}" ) | |
| pred_img = model.predict(tf.expand_dims(img,axis=0)) | |
| pred_class = class_names[pred_img.argmax()] | |
| st.write(f"Predicted brain tumor is : {pred_class} with probs : {pred_img:max():.2f}") | |