som11 commited on
Commit
12b2fa2
1 Parent(s): 0bafa48

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from keras.preprocessing import image
4
+ from keras.models import load_model
5
+
6
+
7
+
8
+ model = load_model('braintumordetectmodel.h5')
9
+
10
+
11
+
12
+ st.title('Classification of Brain Tumor using CNN')
13
+
14
+ st.text("")
15
+
16
+ upload_brain_photo = st.file_uploader('Please upload the photo of Brain MRI Image', type=['jpg', 'png'])
17
+
18
+
19
+ if upload_brain_photo is not None:
20
+
21
+ brain_photo_uploaded = image.load_img(upload_brain_photo, target_size=(180, 180, 3))
22
+
23
+ st.text("")
24
+
25
+ col1, col2, col3 = st.columns (3)
26
+
27
+ with col1:
28
+ st.write (' ')
29
+ with col2:
30
+ st.image (brain_photo_uploaded, caption='Preview of the uploaded Brain MRI Image', width=250)
31
+ with col3:
32
+ st.write (' ')
33
+
34
+ brain_photo_uploaded_to_arr = image.img_to_array(brain_photo_uploaded)
35
+
36
+ brain_photo_uploaded_to_arr = brain_photo_uploaded_to_arr / 255
37
+
38
+ brain_photo_uploaded_to_arr_expand = np.expand_dims(brain_photo_uploaded_to_arr, axis=0)
39
+
40
+ prediction = (model.predict(brain_photo_uploaded_to_arr_expand) > 0.5).astype('int32')
41
+
42
+ st.text("")
43
+
44
+ if prediction[0][0] == 0:
45
+ st.markdown("<div style='background-color: green; padding: 8px; border-radius: 10px; text-align: center; color: white; font-size: large'>The Brain MRI imaging that you uploaded shows no signs of any tumor.</div>", unsafe_allow_html=True)
46
+ else:
47
+ st.markdown("<div style='background-color: red; padding: 8px; border-radius: 10px; text-align: center; color: white; font-size: large'> The brain imaging that you uploaded indeed has signs of a tumor.</div>", unsafe_allow_html=True)