fazrinmuh commited on
Commit
4673d94
1 Parent(s): b989f50

Upload 9 files

Browse files
BACTERIA-1514320-0003.jpeg ADDED
BACTERIA-1639580-0001.jpeg ADDED
NORMAL-831813-0001.jpeg ADDED
NORMAL-930887-0001.jpeg ADDED
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import Library
2
+ import streamlit as st
3
+
4
+ # Import halaman streamlit yang sudah dibuat
5
+ import eda
6
+ import prediction
7
+
8
+
9
+ # Tombol navigasi
10
+ navigasi = st.sidebar.selectbox('Choose page :', ('EDA', 'Model Prediction'))
11
+
12
+ if navigasi == 'Model Prediction':
13
+ prediction.run()
14
+ else:
15
+ eda.run()
eda.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import library
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import numpy as np
5
+ from PIL import Image
6
+
7
+ def run():
8
+ # Set Title
9
+ st.title('BRAIN MRI VISUALIZATION')
10
+
11
+ # memasukkan gambar
12
+ st.image ('https://cdn.systematic.com/media/g0sj1tbg/hospital-building-001-global.jpg?mode=crop&width=1200&height=630&center=')
13
+
14
+ # menampilkan EDA
15
+ st.markdown('## Exploratory Data Analysis (EDA)')
16
+ st.markdown ('---')
17
+
18
+
19
+ # EDA 1
20
+ st.markdown("<h3 style='text-align: center;'>Gambar MRI</h3>", unsafe_allow_html=True)
21
+
22
+ image = Image.open('EDA3.png')
23
+ st.image(image)
24
+
25
+ st.write('---')
26
+
27
+
28
+ # EDA 2
29
+ st.markdown("<h3 style='text-align: center;'>Distribusi Data Train</h3>", unsafe_allow_html=True)
30
+
31
+ image = Image.open('EDA1.png')
32
+ st.image(image)
33
+
34
+ st.write('---')
35
+
36
+ # EDA 3
37
+ st.markdown("<h3 style='text-align: center;'>Distribusi Data Val</h3>", unsafe_allow_html=True)
38
+
39
+ image = Image.open('EDA2.png')
40
+ st.image(image)
41
+
42
+ st.write('---')
43
+
44
+ if __name__ == "__main__":
45
+ run()
46
+
model_tl.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a568b10ffff426b8c27d71f06a5a72dbfd34df5000e9e0b2a9afa4c2c99c953
3
+ size 213086560
prediction.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #import library
2
+ import pandas as pd
3
+ import numpy as np
4
+ import streamlit as st
5
+ from tensorflow.keras.preprocessing.image import load_img, img_to_array
6
+ import matplotlib.pyplot as plt
7
+ from PIL import Image
8
+ import tensorflow as tf
9
+ from tensorflow.keras.models import load_model
10
+ import tensorflow_hub as hub
11
+
12
+ #import pickle
13
+ import pickle
14
+
15
+ #load model
16
+ def run():
17
+ file = st.file_uploader("Upload an image", type=["jpg", "png"])
18
+
19
+ model = load_model('model_transfer.h5', custom_objects={'KerasLayer': hub.KerasLayer})
20
+ target_size=(224, 224)
21
+
22
+ def import_and_predict(image_data, model):
23
+ image = tf.keras.utils.load_img(image_data, target_size=(224, 224))
24
+ x = tf.keras.utils.img_to_array(image)
25
+ x = np.expand_dims(x, axis=0)
26
+
27
+ plt.imshow(image)
28
+ plt.axis('off')
29
+ plt.show()
30
+
31
+ # Make prediction
32
+ classes = model.predict(x)
33
+ result_pred = np.where(classes < 0.7, 0, 1)
34
+ if result_pred == 1:
35
+ result = 'Brain Tumor'
36
+ else:
37
+ result = 'Healthy'
38
+
39
+ return f"Prediction: {result}"
40
+
41
+ if file is None:
42
+ st.text("Please upload an image file")
43
+ else:
44
+ result = import_and_predict(file, model)
45
+ st.image(file)
46
+ st.write(result)
47
+
48
+ if __name__ == "__main__":
49
+ run()
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ matplotlib
4
+ seaborn
5
+ pickleshare
6
+ plotly
7
+ scikit.learn==1.4.0
8
+ tensorflow==2.15.0
9
+ tensorflow-hub==0.16.1
10
+ pillow