jarif commited on
Commit
8a31a00
·
verified ·
1 Parent(s): 05f2933

Upload streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +8 -7
src/streamlit_app.py CHANGED
@@ -4,6 +4,7 @@ import pandas as pd
4
  import plotly.express as px
5
  import pickle
6
  from tensorflow.keras.models import load_model
 
7
 
8
  # Streamlit page configuration
9
  st.set_page_config(
@@ -68,15 +69,15 @@ st.markdown("""
68
  </style>
69
  """, unsafe_allow_html=True)
70
 
71
- # Load model and scalers
72
  try:
73
- model = load_model('my_model.keras')
74
- scaler_X = pickle.load(open('scaler_X.pkl', 'rb'))
75
- scaler_y = pickle.load(open('scaler_y.pkl', 'rb'))
76
  except Exception as e:
77
- st.error(f"Failed to load model or scalers: {str(e)}. Ensure 'my_model.keras', 'scaler_X.pkl', and 'scaler_y.pkl' are in E:\\grid\\. "
78
- "This error may occur if the TensorFlow version used to save the model differs from your installed version. "
79
- "Try installing TensorFlow 2.17.0 or the version used to save the model (e.g., `pip install tensorflow==2.17.0`).")
80
  st.stop()
81
 
82
  # Main app layout
 
4
  import plotly.express as px
5
  import pickle
6
  from tensorflow.keras.models import load_model
7
+ import os
8
 
9
  # Streamlit page configuration
10
  st.set_page_config(
 
69
  </style>
70
  """, unsafe_allow_html=True)
71
 
72
+ # Load model and scalers from root directory
73
  try:
74
+ model = load_model('../my_model.keras')
75
+ scaler_X = pickle.load(open('../scaler_X.pkl', 'rb'))
76
+ scaler_y = pickle.load(open('../scaler_y.pkl', 'rb'))
77
  except Exception as e:
78
+ st.error(f"Failed to load model or scalers: {str(e)}. Ensure 'my_model.keras', 'scaler_X.pkl', and 'scaler_y.pkl' are in the Space's root directory. "
79
+ "This error may occur if the TensorFlow version (2.17.0) differs from the version used to save the model. "
80
+ "Try resaving the model with TensorFlow 2.17.0 or installing the correct version.")
81
  st.stop()
82
 
83
  # Main app layout