shwetashweta05 commited on
Commit
d55d664
Β·
verified Β·
1 Parent(s): 0985c09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -4,7 +4,7 @@ import numpy as np
4
  import os
5
 
6
  # Define Model File Path
7
- MODEL_PATH = "random_forest_pipeline.pkl"
8
 
9
  # Streamlit UI Setup
10
  st.set_page_config(page_title="Wine Quality Prediction πŸ·πŸ”¬", layout="centered")
@@ -28,14 +28,15 @@ st.markdown(
28
  st.markdown('<h1 class="title">Wine Quality Prediction πŸ·πŸ”¬</h1>', unsafe_allow_html=True)
29
  st.write("Predicting Wine Quality based on wine parameters.")
30
 
31
- # Load Model if Available
32
- if os.path.exists(MODEL_PATH):
33
- with open(MODEL_PATH, "rb") as f:
34
  model = pickle.load(f)
 
35
  model_loaded = True
36
  else:
 
37
  model_loaded = False
38
- st.error(f"❌ Model file '{MODEL_PATH}' not found! Please upload the trained model.")
39
 
40
  # User Inputs
41
  fixed_acidity = st.number_input("Fixed Acidity", min_value=4.6, max_value=15.9, value=7.6)
 
4
  import os
5
 
6
  # Define Model File Path
7
+ model_path = "random_forest_pipeline.pkl"
8
 
9
  # Streamlit UI Setup
10
  st.set_page_config(page_title="Wine Quality Prediction πŸ·πŸ”¬", layout="centered")
 
28
  st.markdown('<h1 class="title">Wine Quality Prediction πŸ·πŸ”¬</h1>', unsafe_allow_html=True)
29
  st.write("Predicting Wine Quality based on wine parameters.")
30
 
31
+ # Check if model exists
32
+ if os.path.exists(model_path):
33
+ with open(model_path, "rb") as f:
34
  model = pickle.load(f)
35
+ st.success("βœ… Model loaded successfully!")
36
  model_loaded = True
37
  else:
38
+ st.error(f"❌ Model file '{model_path}' not found! Please upload or train the model first.")
39
  model_loaded = False
 
40
 
41
  # User Inputs
42
  fixed_acidity = st.number_input("Fixed Acidity", min_value=4.6, max_value=15.9, value=7.6)