dpanchali commited on
Commit
f08df0b
·
verified ·
1 Parent(s): 09b4cbb

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -57,7 +57,7 @@ if st.button("Predict Engine Condition", type="primary"):
57
  load_index = float(engine_rpm * fuel_pressure / 100)
58
  thermal_stress = float(coolant_temp - lub_oil_temp)
59
 
60
- # Create DataFrame with EXACT column names and order from your error message
61
  input_data = pd.DataFrame([[
62
  engine_rpm,
63
  lub_oil_pressure,
@@ -79,15 +79,23 @@ if st.button("Predict Engine Condition", type="primary"):
79
  st.divider()
80
  st.subheader("Results")
81
 
82
- if prediction == 0: # Assuming 0 is Good based on typical maintenance datasets
 
83
  st.success("**Status: Engine is in Good Condition**")
84
  else:
85
  st.error("**Status: Maintenance Required (Potential Fault)**")
86
 
87
- # Confidence Visual
88
- health_score = prediction_proba[0] # Probability of "Healthy"
 
 
 
 
 
 
89
  st.write(f"**Confidence Score:** {max(prediction_proba)*100:.2f}%")
90
- st.progress(health_score)
 
91
 
92
  else:
93
  st.error("Model could not be loaded. Check your Hugging Face Repo ID.")
 
57
  load_index = float(engine_rpm * fuel_pressure / 100)
58
  thermal_stress = float(coolant_temp - lub_oil_temp)
59
 
60
+ # Create DataFrame with EXACT column names and order
61
  input_data = pd.DataFrame([[
62
  engine_rpm,
63
  lub_oil_pressure,
 
79
  st.divider()
80
  st.subheader("Results")
81
 
82
+ # Visual Feedback based on Prediction
83
+ if prediction == 0: # Assuming 0 is Good
84
  st.success("**Status: Engine is in Good Condition**")
85
  else:
86
  st.error("**Status: Maintenance Required (Potential Fault)**")
87
 
88
+ # --- FIX START: Handling st.progress error ---
89
+ # 1. Extract the probability for the "Healthy" class (Class 0)
90
+ health_score = float(prediction_proba[0])
91
+
92
+ # 2. Clip the value to ensure it is strictly between 0.0 and 1.0
93
+ # This prevents crashes if the model returns 1.0000001 or -0.0000001
94
+ safe_progress_value = max(0.0, min(1.0, health_score))
95
+
96
  st.write(f"**Confidence Score:** {max(prediction_proba)*100:.2f}%")
97
+ st.progress(safe_progress_value)
98
+ # --- FIX END ---
99
 
100
  else:
101
  st.error("Model could not be loaded. Check your Hugging Face Repo ID.")