isitraghav commited on
Commit
d8779fb
·
1 Parent(s): ce9afcd
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -61,10 +61,22 @@ def get_fertilizer_recommendation(row, land_size_m2, fallow_years, thresholds, a
61
  for nutrient, threshold in thresholds.items():
62
  if row[nutrient] < threshold:
63
  nutrient_name = nutrient.split('_')[-1]
64
- deficiencies.append(nutrient_name)
 
 
 
 
 
 
 
 
 
 
 
 
65
  base_amount_per_m2 = application_rates[nutrient_name] / 10000
66
  total_amount = base_amount_per_m2 * land_size_m2 * (1 + 0.1 * fallow_years)
67
- fertilizer_amounts[nutrient_name] = round(total_amount, 2)
68
  if deficiencies:
69
  return {'recommendation': f'fertilizer needed for {", ".join(deficiencies)}', 'fertilizer_amounts': fertilizer_amounts}
70
  else:
@@ -104,4 +116,4 @@ def gradio_application():
104
  demo.launch()
105
 
106
  if __name__ == "__main__":
107
- gradio_application()
 
61
  for nutrient, threshold in thresholds.items():
62
  if row[nutrient] < threshold:
63
  nutrient_name = nutrient.split('_')[-1]
64
+ full_nutrient_name = {
65
+ 'P': 'Phosphorus',
66
+ 'K': 'Potassium',
67
+ 'Ca': 'Calcium',
68
+ 'Mg': 'Magnesium',
69
+ 'S': 'Sulphur',
70
+ 'Zn': 'Zinc',
71
+ 'B': 'Boron',
72
+ 'Fe': 'Iron',
73
+ 'Cu': 'Copper',
74
+ 'N': 'Nitrogen'
75
+ }[nutrient_name]
76
+ deficiencies.append(full_nutrient_name)
77
  base_amount_per_m2 = application_rates[nutrient_name] / 10000
78
  total_amount = base_amount_per_m2 * land_size_m2 * (1 + 0.1 * fallow_years)
79
+ fertilizer_amounts[full_nutrient_name] = round(total_amount, 2)
80
  if deficiencies:
81
  return {'recommendation': f'fertilizer needed for {", ".join(deficiencies)}', 'fertilizer_amounts': fertilizer_amounts}
82
  else:
 
116
  demo.launch()
117
 
118
  if __name__ == "__main__":
119
+ gradio_application()