Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,19 +19,19 @@ row_options = ["None, Enter Manually"] + [str(i) for i in range(len(df))]
|
|
| 19 |
|
| 20 |
#-------------- To be commented --------------------
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
#
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
|
| 36 |
# -----------------------------
|
| 37 |
# 3️⃣ Prediction function
|
|
@@ -58,9 +58,6 @@ def predict_linear(strain, dose, soil_n, soil_p, soil_k, ph,
|
|
| 58 |
if any(v is None for v in required):
|
| 59 |
logs.append("[DEBUG] Missing numeric inputs!")
|
| 60 |
return pd.DataFrame(), "\n⚠️ Fill all required inputs", "\n".join(logs)
|
| 61 |
-
# if any(v is 0 for v in required):
|
| 62 |
-
# logs.append("[DEBUG] Missing numeric inputs!")
|
| 63 |
-
# return pd.DataFrame(), "\n⚠️ Fill all required inputs", "\n".join(logs)
|
| 64 |
logs.append("[DEBUG] Inputs received.")
|
| 65 |
|
| 66 |
# Prepare DataFrame for model
|
|
@@ -133,7 +130,7 @@ with gr.Blocks(
|
|
| 133 |
label="Select Strain",
|
| 134 |
value=strain_names[0] # default: Tetradesmus nigardi
|
| 135 |
)
|
| 136 |
-
|
| 137 |
|
| 138 |
gr.Markdown("### Input Parameters")
|
| 139 |
dose = gr.Number(label="Dose (g/pot)",placeholder="Enter value")
|
|
@@ -142,13 +139,13 @@ with gr.Blocks(
|
|
| 142 |
soil_k = gr.Number(label="Soil K (ppm)",placeholder="Enter value")
|
| 143 |
ph = gr.Number(label="pH",placeholder="Enter value")
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
|
| 153 |
# Hidden placeholders for metrics
|
| 154 |
chlorophyll = gr.State(None)
|
|
@@ -196,14 +193,14 @@ with gr.Blocks(
|
|
| 196 |
"""
|
| 197 |
)
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
|
| 208 |
# Prediction callback
|
| 209 |
predict_btn.click(
|
|
|
|
| 19 |
|
| 20 |
#-------------- To be commented --------------------
|
| 21 |
|
| 22 |
+
# -----------------------------
|
| 23 |
+
# 2️⃣ Autofill function
|
| 24 |
+
# -----------------------------
|
| 25 |
+
def autofill_fields(row_index):
|
| 26 |
+
if row_index == "None, Enter Manually":
|
| 27 |
+
return [None]*11
|
| 28 |
+
row = df.iloc[int(row_index)]
|
| 29 |
+
return (
|
| 30 |
+
row['Dose (g/pot)'], row['Soil N (ppm)'], row['Soil P (ppm)'],
|
| 31 |
+
row['Soil K (ppm)'], row['pH'], row['Chlorophyll (SPAD)'],
|
| 32 |
+
row['Shoot Length (cm)'], row['Root Length (cm)'], row['Shoot Wt (g)'],
|
| 33 |
+
row['Root Wt (g)'], row['Yield (g/pot)']
|
| 34 |
+
)
|
| 35 |
|
| 36 |
# -----------------------------
|
| 37 |
# 3️⃣ Prediction function
|
|
|
|
| 58 |
if any(v is None for v in required):
|
| 59 |
logs.append("[DEBUG] Missing numeric inputs!")
|
| 60 |
return pd.DataFrame(), "\n⚠️ Fill all required inputs", "\n".join(logs)
|
|
|
|
|
|
|
|
|
|
| 61 |
logs.append("[DEBUG] Inputs received.")
|
| 62 |
|
| 63 |
# Prepare DataFrame for model
|
|
|
|
| 130 |
label="Select Strain",
|
| 131 |
value=strain_names[0] # default: Tetradesmus nigardi
|
| 132 |
)
|
| 133 |
+
row_selector = gr.Dropdown(row_options, label="Select Row", value="None, Enter Manually")
|
| 134 |
|
| 135 |
gr.Markdown("### Input Parameters")
|
| 136 |
dose = gr.Number(label="Dose (g/pot)",placeholder="Enter value")
|
|
|
|
| 139 |
soil_k = gr.Number(label="Soil K (ppm)",placeholder="Enter value")
|
| 140 |
ph = gr.Number(label="pH",placeholder="Enter value")
|
| 141 |
|
| 142 |
+
gr.Markdown("### Autofilled Actual Metrics (from Excel)")
|
| 143 |
+
chlorophyll = gr.Number(label="Chlorophyll (SPAD)")
|
| 144 |
+
shoot_len = gr.Number(label="Shoot Length (cm)")
|
| 145 |
+
root_len = gr.Number(label="Root Length (cm)")
|
| 146 |
+
shoot_wt = gr.Number(label="Shoot Wt (g)")
|
| 147 |
+
root_wt = gr.Number(label="Root Wt (g)")
|
| 148 |
+
yield_gp = gr.Number(label="Yield (g/pot)")
|
| 149 |
|
| 150 |
# Hidden placeholders for metrics
|
| 151 |
chlorophyll = gr.State(None)
|
|
|
|
| 193 |
"""
|
| 194 |
)
|
| 195 |
|
| 196 |
+
Autofill callback
|
| 197 |
+
row_selector.change(
|
| 198 |
+
fn=autofill_fields,
|
| 199 |
+
inputs=[row_selector],
|
| 200 |
+
outputs=[dose, soil_n, soil_p, soil_k, ph,
|
| 201 |
+
chlorophyll, shoot_len, root_len,
|
| 202 |
+
shoot_wt, root_wt, yield_gp]
|
| 203 |
+
)
|
| 204 |
|
| 205 |
# Prediction callback
|
| 206 |
predict_btn.click(
|