File size: 943 Bytes
5a66061
 
 
fc8098a
9250638
5a66061
fc8098a
 
 
 
2615b7b
fc8098a
 
5a66061
fc8098a
5a66061
fc8098a
 
dd19955
fc8098a
8edffc3
 
87d0755
b6c6946
87d0755
 
8edffc3
 
7155bee
5a66061
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()