Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -78,6 +78,13 @@ def predict_linear(strain, dose, soil_n, soil_p, soil_k, ph,
|
|
| 78 |
result_df = pd.DataFrame(data)
|
| 79 |
|
| 80 |
return result_df, "Prediction complete!", "\n".join(logs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# -----------------------------
|
| 83 |
# 4️⃣ Gradio Interface (Green Theme)
|
|
@@ -124,7 +131,9 @@ with gr.Blocks(
|
|
| 124 |
root_wt = gr.Number(label="Root Wt (g)")
|
| 125 |
yield_gp = gr.Number(label="Yield (g/pot)")
|
| 126 |
|
| 127 |
-
|
|
|
|
|
|
|
| 128 |
|
| 129 |
with gr.Column(scale=1):
|
| 130 |
gr.Markdown("### Prediction Results Table")
|
|
@@ -179,6 +188,16 @@ with gr.Blocks(
|
|
| 179 |
outputs=[result_table, status_box, log_box]
|
| 180 |
)
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
# -----------------------------
|
| 183 |
# 5️⃣ Launch
|
| 184 |
# -----------------------------
|
|
|
|
| 78 |
result_df = pd.DataFrame(data)
|
| 79 |
|
| 80 |
return result_df, "Prediction complete!", "\n".join(logs)
|
| 81 |
+
|
| 82 |
+
# -----------------------------
|
| 83 |
+
# Clear Inputs Function
|
| 84 |
+
# -----------------------------
|
| 85 |
+
def clear_inputs():
|
| 86 |
+
# Reset all input fields to None
|
| 87 |
+
return [None] * 11 # same number of numeric input fields
|
| 88 |
|
| 89 |
# -----------------------------
|
| 90 |
# 4️⃣ Gradio Interface (Green Theme)
|
|
|
|
| 131 |
root_wt = gr.Number(label="Root Wt (g)")
|
| 132 |
yield_gp = gr.Number(label="Yield (g/pot)")
|
| 133 |
|
| 134 |
+
with gr.Row():
|
| 135 |
+
predict_btn = gr.Button(" Predict", variant="primary")
|
| 136 |
+
clear_btn = gr.Button("🧹 Clear Inputs", variant="secondary")
|
| 137 |
|
| 138 |
with gr.Column(scale=1):
|
| 139 |
gr.Markdown("### Prediction Results Table")
|
|
|
|
| 188 |
outputs=[result_table, status_box, log_box]
|
| 189 |
)
|
| 190 |
|
| 191 |
+
# Clear button callback
|
| 192 |
+
clear_btn.click(
|
| 193 |
+
fn=clear_inputs,
|
| 194 |
+
inputs=[],
|
| 195 |
+
outputs=[dose, soil_n, soil_p, soil_k, ph,
|
| 196 |
+
chlorophyll, shoot_len, root_len,
|
| 197 |
+
shoot_wt, root_wt, yield_gp]
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
|
| 201 |
# -----------------------------
|
| 202 |
# 5️⃣ Launch
|
| 203 |
# -----------------------------
|