danielle2003 commited on
Commit
1c1191c
·
verified ·
1 Parent(s): 5149c40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -27,7 +27,7 @@ from gradcam import GradCAM # Import your GradCAM class
27
 
28
  if "model" not in st.session_state:
29
  st.session_state.model = tf.keras.models.load_model(
30
- "models/best_model.h5"
31
  )
32
  if "framework" not in st.session_state:
33
  st.session_state.framework = "Tensorflow"
@@ -226,7 +226,7 @@ class_labels = ["Cyst", "Normal", "Stone", "Tumor"]
226
 
227
 
228
  def load_tensorflow_model():
229
- tf_model = tf.keras.models.load_model("models/best_model.h5")
230
  return tf_model
231
 
232
  if st.session_state.framework =="TensorFlow":
@@ -239,7 +239,7 @@ if st.session_state.framework =="TensorFlow":
239
  return predictions
240
 
241
  if st.session_state.framework == "PyTorch":
242
- logo_path = "images/pytorch.png"
243
  bg_color = "#FF5733" # For example, a warm red/orange
244
  bg_color_iv = "orange" # For example, a warm red/orange
245
 
@@ -311,7 +311,7 @@ def get_layers_data(model, prefix=""):
311
 
312
  ###########################################
313
  main_bg_ext = "png"
314
- main_bg = "images/bg1.jpg"
315
  # Read and encode the logo image
316
 
317
  with open(logo_path, "rb") as image_file:
@@ -859,7 +859,7 @@ if page == "Home":
859
 
860
  # components.html(html_string) # JavaScript works
861
  # st.markdown(html_string, unsafe_allow_html=True)
862
- image_path = "images/image.jpg"
863
 
864
  st.container()
865
  st.markdown(
@@ -955,7 +955,7 @@ if page == "Home":
955
  placeholder.empty()
956
  st.markdown(content, unsafe_allow_html=True)
957
  else:
958
- default_image_path = "images/image.jpg"
959
  with open(image_path, "rb") as image_file:
960
  encoded_image = base64.b64encode(image_file.read()).decode()
961
 
@@ -974,7 +974,7 @@ if page == "Home":
974
  unsafe_allow_html=True,
975
  )
976
  if page == "pome":
977
- gif_path = "images/bg3.gif"
978
  with open(gif_path, "rb") as image_file:
979
  encode_image = base64.b64encode(image_file.read()).decode()
980
  st.markdown(
@@ -1015,12 +1015,12 @@ if page == "pome":
1015
 
1016
  if toggle and st.session_state.framework != "PyTorch":
1017
  st.session_state.framework = "PyTorch"
1018
- st.session_state.model = torch.load('models/kidney_model .pth', map_location=torch.device('cpu'))
1019
  st.rerun()
1020
  elif not toggle and st.session_state.framework != "TensorFlow":
1021
  st.session_state.framework = "TensorFlow"
1022
  st.session_state.model = tf.keras.models.load_model(
1023
- "models/best_model.h5"
1024
  )
1025
  st.rerun()
1026
  print(st.session_state.framework)
 
27
 
28
  if "model" not in st.session_state:
29
  st.session_state.model = tf.keras.models.load_model(
30
+ "best_model.h5"
31
  )
32
  if "framework" not in st.session_state:
33
  st.session_state.framework = "Tensorflow"
 
226
 
227
 
228
  def load_tensorflow_model():
229
+ tf_model = tf.keras.models.load_model("best_model.h5")
230
  return tf_model
231
 
232
  if st.session_state.framework =="TensorFlow":
 
239
  return predictions
240
 
241
  if st.session_state.framework == "PyTorch":
242
+ logo_path = "pytorch.png"
243
  bg_color = "#FF5733" # For example, a warm red/orange
244
  bg_color_iv = "orange" # For example, a warm red/orange
245
 
 
311
 
312
  ###########################################
313
  main_bg_ext = "png"
314
+ main_bg = "bg1.jpg"
315
  # Read and encode the logo image
316
 
317
  with open(logo_path, "rb") as image_file:
 
859
 
860
  # components.html(html_string) # JavaScript works
861
  # st.markdown(html_string, unsafe_allow_html=True)
862
+ image_path = "image.jpg"
863
 
864
  st.container()
865
  st.markdown(
 
955
  placeholder.empty()
956
  st.markdown(content, unsafe_allow_html=True)
957
  else:
958
+ default_image_path = "image.jpg"
959
  with open(image_path, "rb") as image_file:
960
  encoded_image = base64.b64encode(image_file.read()).decode()
961
 
 
974
  unsafe_allow_html=True,
975
  )
976
  if page == "pome":
977
+ gif_path = "bg3.gif"
978
  with open(gif_path, "rb") as image_file:
979
  encode_image = base64.b64encode(image_file.read()).decode()
980
  st.markdown(
 
1015
 
1016
  if toggle and st.session_state.framework != "PyTorch":
1017
  st.session_state.framework = "PyTorch"
1018
+ st.session_state.model = torch.load('kidney_model .pth', map_location=torch.device('cpu'))
1019
  st.rerun()
1020
  elif not toggle and st.session_state.framework != "TensorFlow":
1021
  st.session_state.framework = "TensorFlow"
1022
  st.session_state.model = tf.keras.models.load_model(
1023
+ "best_model.h5"
1024
  )
1025
  st.rerun()
1026
  print(st.session_state.framework)