Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -72,9 +72,8 @@ if st.button("Predict Engine Condition", type="primary"):
|
|
| 72 |
'lub oil temp', 'Coolant temp', 'load_index', 'thermal_stress'
|
| 73 |
])
|
| 74 |
|
| 75 |
-
# Perform prediction
|
| 76 |
prediction = model.predict(input_data)[0]
|
| 77 |
-
prediction_proba = model.predict_proba(input_data)[0]
|
| 78 |
|
| 79 |
st.divider()
|
| 80 |
st.subheader("Results")
|
|
@@ -84,18 +83,6 @@ if st.button("Predict Engine Condition", type="primary"):
|
|
| 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.")
|
|
|
|
| 72 |
'lub oil temp', 'Coolant temp', 'load_index', 'thermal_stress'
|
| 73 |
])
|
| 74 |
|
| 75 |
+
# Perform prediction (Binary Result Only)
|
| 76 |
prediction = model.predict(input_data)[0]
|
|
|
|
| 77 |
|
| 78 |
st.divider()
|
| 79 |
st.subheader("Results")
|
|
|
|
| 83 |
st.success("**Status: Engine is in Good Condition**")
|
| 84 |
else:
|
| 85 |
st.error("**Status: Maintenance Required (Potential Fault)**")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
else:
|
| 88 |
st.error("Model could not be loaded. Check your Hugging Face Repo ID.")
|