Update src/streamlit_app.py
Browse files9 unmodified lines101112131415161516171719181920212223242526272829303132333435363738394041424344454647484950519 unmodified lines
# ========== Load Model ========== MODEL_PATH = os.path.join("..", "models", "model.h5") # THIS LINE DEFINES MODEL_PATH
st.write(f"Current working directory: {os.getcwd()}")st.write(f"Looking for model at: {os.path.abspath(MODEL_PATH)}")st.write(f"Does models directory exist: {os.path.exists(os.path.join(os.getcwd(), '..', 'models'))}")st.write(f"Contents of parent directory (..): {os.listdir(os.path.join(os.getcwd(), '..'))}")st.write(f"Contents of models directory: {os.listdir(os.path.join(os.getcwd(), '..', 'models')) if os.path.exists(os.path.join(os.getcwd(), '..', 'models')) else 'models directory not found'}")
MODEL_PATH = os.path.join("..", "models", "model.h5")#"ResNet50_Garbage_Classifier/models/model.h5"#os.path.join("models", "model.h5")# Check if the parent directory (..) exists and list its contentsparent_dir = os.path.join(os.getcwd(), '..')st.write(f"Does parent directory (..) exist: {os.path.exists(parent_dir)}")if os.path.exists(parent_dir): try: st.write(f"Contents of parent directory (..): {os.listdir(parent_dir)}") except Exception as e: st.write(f"Error listing parent directory: {e}")
# Check if the models directory exists and list its contentsmodels_dir = os.path.join(os.getcwd(), '..', 'models')st.write(f"Does models directory exist: {os.path.exists(models_dir)}")if os.path.exists(models_dir): try: st.write(f"Contents of models directory: {os.listdir(models_dir)}") except Exception as e: st.write(f"Error listing models directory: {e}")else: st.write('models directory not found at expected path.')
# --- End of debugging lines ---
if not os.path.exists(MODEL_PATH): st.error(f"Model file not found at: {MODEL_PATH}") st.stop()
model = tf.keras.models.load_model(MODEL_PATH)
if not os.path.exists(MODEL_PATH): st.error(f"❌ Model file not found at: {MODEL_PATH}")src/streamlit_app.py+33-4