Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,10 +32,13 @@ single_strain_value = 0 # training used LabelEncoder -> 0
|
|
| 32 |
|
| 33 |
# ==================== New Integration ====================
|
| 34 |
# Create a list of row indices for dropdown
|
| 35 |
-
row_options = [str(i) for i in range(len(df))]
|
| 36 |
|
| 37 |
# Function to autofill input fields from selected row
|
| 38 |
def autofill_fields(row_index):
|
|
|
|
|
|
|
|
|
|
| 39 |
row = df.iloc[int(row_index)]
|
| 40 |
return (
|
| 41 |
row['Soil_N_ppm'], row['Soil_P_ppm'], row['Soil_K_ppm'],
|
|
@@ -44,6 +47,7 @@ def autofill_fields(row_index):
|
|
| 44 |
row['Relative_Yield_%'], row['Dose_g_per_pot'] if 'Dose_g_per_pot' in row else None
|
| 45 |
)
|
| 46 |
|
|
|
|
| 47 |
# -----------------------------
|
| 48 |
# 3️⃣ Prediction function
|
| 49 |
# -----------------------------
|
|
@@ -189,6 +193,7 @@ with gr.Blocks(
|
|
| 189 |
chlorophyll, shoot_length, root_length, yield_g,
|
| 190 |
relative_yield, actual_dose]
|
| 191 |
)
|
|
|
|
| 192 |
predict_btn.click(
|
| 193 |
fn=predict_dose,
|
| 194 |
inputs=[crop, strain, soil_n, soil_p, soil_k, soil_ec, soil_moisture,
|
|
|
|
| 32 |
|
| 33 |
# ==================== New Integration ====================
|
| 34 |
# Create a list of row indices for dropdown
|
| 35 |
+
row_options = ["None, Enter manually"] + [str(i) for i in range(len(df))]
|
| 36 |
|
| 37 |
# Function to autofill input fields from selected row
|
| 38 |
def autofill_fields(row_index):
|
| 39 |
+
if row_index == "None":
|
| 40 |
+
# Reset all fields if 'None' selected UPDATE
|
| 41 |
+
return (None, None, None, None, None, None, None, None, None, None, None)
|
| 42 |
row = df.iloc[int(row_index)]
|
| 43 |
return (
|
| 44 |
row['Soil_N_ppm'], row['Soil_P_ppm'], row['Soil_K_ppm'],
|
|
|
|
| 47 |
row['Relative_Yield_%'], row['Dose_g_per_pot'] if 'Dose_g_per_pot' in row else None
|
| 48 |
)
|
| 49 |
|
| 50 |
+
|
| 51 |
# -----------------------------
|
| 52 |
# 3️⃣ Prediction function
|
| 53 |
# -----------------------------
|
|
|
|
| 193 |
chlorophyll, shoot_length, root_length, yield_g,
|
| 194 |
relative_yield, actual_dose]
|
| 195 |
)
|
| 196 |
+
|
| 197 |
predict_btn.click(
|
| 198 |
fn=predict_dose,
|
| 199 |
inputs=[crop, strain, soil_n, soil_p, soil_k, soil_ec, soil_moisture,
|