import streamlit as st import numpy as np import pickle from tensorflow.keras.models import load_model # Load the model @st.cache_resource() def load_h5_model(model_path): return load_model(model_path) # Load the data @st.cache_resource() def load_npy_data(data_path): return np.load(data_path) # Load the pickle file @st.cache_resource() def load_pkl_file(pkl_path): with open(pkl_path, 'rb') as f: return pickle.load(f) # Streamlit app def main(): st.title("Breast Cancer Detection Model Evaluation") # Load the model model = load_h5_model('CNN_model.h5') # Load the data X_test = load_npy_data('X_test.npy') y_test = load_npy_data('y_test.npy') # Load the accuracy from accuracy_epoch_5000.pkl loaded_correct_predictions, loaded_correct_indices = load_pkl_file('accuracy_epoch_5000.pkl') # Load the history from history.pkl history = load_pkl_file('history.pkl') # Display the shapes of X_test and y_test st.write("X_test shape:", X_test.shape) st.write("y_test shape:", y_test.shape) # Display the model summary (utilize st.text not st.write) st.write("CNN_model.h5 Summary") st.text(model.summary()) # Display the loaded accuracy results st.write("accuracy_epoch_5000 results:") st.write("Loaded Correct Predictions:", loaded_correct_predictions) st.write("Loaded Correct Indices:", loaded_correct_indices) # Display the model accuracy from history # (55005 - 12171) / 55005 = 0.78 % # Adding rest of epochs from 55005 images # Then, drawing inference on how close # in proximity the Accuracy and History pickle file are # The history pickle file is st.write("Breast Cancer Detection Model Accuracy deriving from history:") if 'accuracy' in history: st.line_chart(history['accuracy']) else: st.write("No accuracy data available in history.") if __name__ == "__main__": main()