Skip to content

Commit 31b8e67

Browse files
authored
Merge pull request #17 from DerikVo/readme
added caching to streamlit app and reference
2 parents 25b35c5 + b36c949 commit 31b8e67

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Streamlit/app.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
https://discuss.streamlit.io/t/any-way-to-prevent-commented-out-code-via-triple-quotes-to-be-displayed-in-streamlit/8821/6
2121
2222
This code takes heavy influece from a previous project.
23-
https://github.com/DerikVo/NN_hackathon
23+
https://github.com/DerikVo/NN_hackathon/blob/main/Code/Helpers/streamlit/app.py
2424
2525
There were many changes to the code to get it to work with this data set as well as provide additional features,
2626
but the general structure remains the same
@@ -44,6 +44,7 @@ def load_model_stream():
4444
def get_prediction(model, image):
4545
open_image = Image.open(image)
4646
resized_image = open_image.resize((256, 256))
47+
# got help from chat gpt 3 by copy and pasting code and asking how get predictions from a single image
4748
grayscale_image = resized_image.convert('L')
4849
img = np.expand_dims(grayscale_image, axis=0)
4950
predicted_prob = model.predict(img)[0]
@@ -81,6 +82,8 @@ def upload_mode():
8182
this code also brows ideas from previous projects and intergrates it into a function.
8283
Espically the model evaluation notebook.
8384
'''
85+
86+
@st.cache_resource #cache so I can show this during presentation more easily
8487
def model_Evaluation(path):
8588
'''
8689
Calculate accuracy, precision, recall, and F1 score.
@@ -118,6 +121,7 @@ def model_Evaluation(path):
118121
https://docs.streamlit.io/library/api-reference/media/st.image
119122
'''
120123

124+
121125
if page == 'Model Evaluation':
122126
path = ('../Models/CNN_base.h5')
123127
data = model_Evaluation(path)

0 commit comments

Comments
 (0)