Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -17,6 +17,8 @@ model = load_model()
|
|
| 17 |
|
| 18 |
st.title("Engine Condition Prediction")
|
| 19 |
|
|
|
|
|
|
|
| 20 |
#engine_rpm = st.number_input("Engine rpm", min_value=0, step=100)
|
| 21 |
#lub_oil_pressure = st.number_input("Lub oil pressure", format="%.3f")
|
| 22 |
#fuel_pressure = st.number_input("Fuel pressure", format="%.3f")
|
|
@@ -104,3 +106,27 @@ if st.button("Predict"):
|
|
| 104 |
|
| 105 |
st.success(f"Engine Condition: {label}")
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
st.title("Engine Condition Prediction")
|
| 19 |
|
| 20 |
+
# Single row prediction
|
| 21 |
+
|
| 22 |
#engine_rpm = st.number_input("Engine rpm", min_value=0, step=100)
|
| 23 |
#lub_oil_pressure = st.number_input("Lub oil pressure", format="%.3f")
|
| 24 |
#fuel_pressure = st.number_input("Fuel pressure", format="%.3f")
|
|
|
|
| 106 |
|
| 107 |
st.success(f"Engine Condition: {label}")
|
| 108 |
|
| 109 |
+
|
| 110 |
+
# Batch prediction
|
| 111 |
+
st.header("Batch Prediction from CSV")
|
| 112 |
+
uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type="csv")
|
| 113 |
+
|
| 114 |
+
if uploaded_file is not None:
|
| 115 |
+
input_data = pd.read_csv(uploaded_file)
|
| 116 |
+
required_cols = ["Engine rpm","Lub oil pressure","Fuel pressure","Coolant pressure","lub oil temp","Coolant temp"]
|
| 117 |
+
|
| 118 |
+
if not all(col in input_data.columns for col in required_cols):
|
| 119 |
+
st.error(f"CSV must contain columns: {', '.join(required_cols)}")
|
| 120 |
+
else:
|
| 121 |
+
predictions = model.predict(input_data)
|
| 122 |
+
input_data["Engine Condition"] = ["FAULTY" if p == 1 else "NORMAL" for p in predictions]
|
| 123 |
+
st.success("Predictions completed!")
|
| 124 |
+
st.dataframe(input_data)
|
| 125 |
+
|
| 126 |
+
csv = input_data.to_csv(index=False).encode("utf-8")
|
| 127 |
+
st.download_button(
|
| 128 |
+
label="Download Predictions as CSV",
|
| 129 |
+
data=csv,
|
| 130 |
+
file_name="engine_predictions.csv",
|
| 131 |
+
mime="text/csv",
|
| 132 |
+
)
|