16
16
17
17
_ = """
18
18
All comments will be assigned to the underscore variable so they dont get rendered in streamlit
19
- as mention in this discussion form :
19
+ as mention in this discussion fourm :
20
20
https://discuss.streamlit.io/t/any-way-to-prevent-commented-out-code-via-triple-quotes-to-be-displayed-in-streamlit/8821/6
21
21
22
22
This code takes heavy influece from a previous project.
23
23
https://github.com/DerikVo/NN_hackathon
24
24
25
- There were many changes to the code to get it to work with this data set,
25
+ There were many changes to the code to get it to work with this data set as well as provide additional features ,
26
26
but the general structure remains the same
27
27
"""
28
28
@@ -33,8 +33,14 @@ def load_model_stream():
33
33
path = "../Models/CNN_base.h5"
34
34
model = load_model (path )
35
35
return model
36
-
37
- # function to preprocess an image and get a prediction from the model
36
+ _ = """
37
+ function to preprocess an image and get a prediction from the model
38
+ code was copied into chatGPT3 with the prompt "how do I modify this code to covert a single image to make predictions on what class it belongs to.
39
+ The image and classes are in greyscale" was provided with this code.
40
+ According to stackoverflow this method is used for greyscaling an image.
41
+ My interptation is by greyscaling our image we ensure it matchs the training data which gets read in as a greyscale image:
42
+ https://stackoverflow.com/questions/52307290/what-is-the-difference-between-images-in-p-and-l-mode-in-pil
43
+ """
38
44
def get_prediction (model , image ):
39
45
open_image = Image .open (image )
40
46
resized_image = open_image .resize ((256 , 256 ))
@@ -43,6 +49,7 @@ def get_prediction(model, image):
43
49
predicted_prob = model .predict (img )[0 ]
44
50
classes = ['glioma' , 'meningioma' , 'notumor' , 'pituitary' ]
45
51
probabilities = dict (zip (classes , predicted_prob ))
52
+ #referenced https://www.freecodecamp.org/news/sort-dictionary-by-value-in-python/
46
53
sorted_probabilities = sorted (probabilities .items (), key = lambda x : x [1 ], reverse = True )
47
54
return sorted_probabilities
48
55
def upload_mode ():
@@ -100,8 +107,11 @@ def model_Evaluation(path):
100
107
return data
101
108
_ = '''
102
109
This code utilized the streamlit documentation to implement columns
103
- and displaying images. In the future I want users to be able to upload their model and have it
104
- automatically be evaluated by the app.
110
+ and displaying images.
111
+
112
+ In the future I want users to be able to upload their model and have it
113
+ automatically be evaluated by the app. However, currently when I create a function to upload the model, I am unable to pass it into the model evaluation function.
114
+ The model being passed isnt being interpreted as a h5 file.
105
115
106
116
The links are as folows:
107
117
https://docs.streamlit.io/library/api-reference/layout/st.columns
@@ -115,7 +125,7 @@ def model_Evaluation(path):
115
125
reg_path = ('../Models/CNN_regularization.h5' )
116
126
reg_data = model_Evaluation (path )
117
127
st .write ("CNN base Metrics:\n " )
118
-
128
+ #create a column for metric scores and display the confusion matrix for the neural network without regularization
119
129
col1 , col2 = st .columns (2 )
120
130
with col1 :
121
131
for metric_name , metric_value in data .items ():
@@ -126,6 +136,7 @@ def model_Evaluation(path):
126
136
st .write ("" )
127
137
st .write ("" )
128
138
st .write ("\n CNN regularization Metrics:" )
139
+ #create a column for metric scores and display the confusion matrix for the neural network with regularization
129
140
col3 , col4 = st .columns (2 )
130
141
with col3 :
131
142
for metric_name , metric_value in reg_data .items ():
0 commit comments