Spaces:
Sleeping
Sleeping
| import joblib | |
| import pandas as pd | |
| import streamlit as st | |
| import cv2 | |
| import numpy as np | |
| def reimage(x): | |
| width = 250 | |
| height = 250 | |
| dim = (width, height) | |
| resim = cv2.resize(x, dim, interpolation = cv2.INTER_AREA) | |
| resim2 = resim.flatten() | |
| return resim2 | |
| model = joblib.load('modelKNN.joblib') | |
| def main(): | |
| st.title("Brain Tumor Analysis") | |
| uploaded_file = st.file_uploader("Upload your Brain MRI image here... (.jpg)", type=['jpg']) | |
| if uploaded_file is not None: | |
| file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8) #Create Bytes array | |
| img = cv2.imdecode(file_bytes,cv2.IMREAD_GRAYSCALE) #Transform Bytes array to numpy array | |
| st.image(uploaded_file) | |
| inputim = reimage(img) | |
| result = model.predict([inputim]) | |
| st.write("Have a brain tumor? : ",result[0]) | |
| else : | |
| st.write("Pls upload .jpg file") | |
| if __name__=='__main__': | |
| main() | |