kj03 commited on
Commit
c7bdb86
·
verified ·
1 Parent(s): cc1911f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +149 -139
app.py CHANGED
@@ -5,30 +5,30 @@ from sklearn.model_selection import train_test_split
5
  import gradio as gr
6
  import random
7
 
8
- # Generate synthetic dataset for Indian crops (focusing on South Indian states)
9
  def generate_synthetic_dataset(num_samples=5000):
10
  np.random.seed(42)
11
 
12
- # Common crops in Andhra Pradesh and Telangana
13
  crops = [
14
- 'Rice', 'Maize', 'Cotton', 'Groundnut', 'Red Gram (Toor Dal)',
15
- 'Green Gram (Moong Dal)', 'Black Gram (Urad Dal)', 'Sunflower',
16
- 'Sugarcane', 'Turmeric', 'Chilli', 'Tomato', 'Onion', 'Mango',
17
- 'Banana', 'Coconut', 'Soybean', 'Jowar (Sorghum)', 'Bajra (Pearl Millet)'
18
  ]
19
 
20
- # Soil types common in the region
21
- soil_types = ['Black Cotton', 'Red Sandy', 'Clayey', 'Loamy', 'Sandy Loam']
22
 
23
- # Seasons in Indian agriculture
24
- seasons = ['Kharif (June-Oct)', 'Rabi (Oct-Mar)', 'Zaid (Mar-Jun)', 'Whole Year']
25
 
26
  # Generate synthetic data
27
  data = {
28
- 'Temperature (°C)': np.random.uniform(10, 60, num_samples),
29
- 'Rainfall (mm)': np.random.uniform(0, 300, num_samples),
30
- 'Humidity (%)': np.random.uniform(20, 100, num_samples),
31
- 'Soil pH': np.random.uniform(4.5, 9.5, num_samples),
32
  'Soil Type': np.random.choice(soil_types, num_samples),
33
  'Nitrogen (N) Level': np.random.uniform(0, 150, num_samples),
34
  'Phosphorus (P) Level': np.random.uniform(0, 100, num_samples),
@@ -45,52 +45,56 @@ def generate_synthetic_dataset(num_samples=5000):
45
  crop = row['Crop']
46
 
47
  # Temperature adjustments
48
- if crop in ['Rice', 'Banana', 'Coconut']:
49
- df.at[idx, 'Temperature (°C)'] = np.random.uniform(25, 40)
50
- df.at[idx, 'Humidity (%)'] = np.random.uniform(60, 100)
51
- elif crop in ['Wheat', 'Barley']:
52
- df.at[idx, 'Temperature (°C)'] = np.random.uniform(10, 25)
53
- elif crop in ['Chilli', 'Tomato']:
54
- df.at[idx, 'Temperature (°C)'] = np.random.uniform(20, 35)
 
55
 
56
  # Soil type adjustments
57
- if crop in ['Cotton', 'Groundnut']:
58
- df.at[idx, 'Soil Type'] = 'Black Cotton'
59
- elif crop in ['Rice']:
60
- df.at[idx, 'Soil Type'] = random.choice(['Clayey', 'Loamy'])
 
 
61
 
62
  # Season adjustments
63
- if crop in ['Rice', 'Maize', 'Cotton', 'Groundnut']:
64
- df.at[idx, 'Season'] = 'Kharif (June-Oct)'
65
- elif crop in ['Wheat', 'Barley', 'Chickpea']:
66
- df.at[idx, 'Season'] = 'Rabi (Oct-Mar)'
67
- elif crop in ['Watermelon', 'Cucumber']:
68
- df.at[idx, 'Season'] = 'Zaid (Mar-Jun)'
69
 
70
- # Add profit estimates (in INR per acre)
71
  profit_ranges = {
72
- 'Rice': (25000, 50000),
73
- 'Maize': (20000, 45000),
74
- 'Cotton': (30000, 70000),
75
- 'Groundnut': (25000, 55000),
76
- 'Red Gram (Toor Dal)': (28000, 60000),
77
- 'Green Gram (Moong Dal)': (22000, 50000),
78
- 'Black Gram (Urad Dal)': (24000, 52000),
79
- 'Sunflower': (18000, 40000),
80
- 'Sugarcane': (35000, 75000),
81
- 'Turmeric': (40000, 90000),
82
- 'Chilli': (50000, 120000),
83
- 'Tomato': (30000, 80000),
84
- 'Onion': (25000, 65000),
85
- 'Mango': (60000, 150000),
86
- 'Banana': (50000, 120000),
87
- 'Coconut': (40000, 100000),
88
- 'Soybean': (22000, 48000),
89
- 'Jowar (Sorghum)': (18000, 40000),
90
- 'Bajra (Pearl Millet)': (15000, 35000)
 
91
  }
92
 
93
- df['Profit (INR/acre)'] = df['Crop'].apply(lambda x: random.randint(*profit_ranges[x]))
94
 
95
  return df
96
 
@@ -98,7 +102,7 @@ def generate_synthetic_dataset(num_samples=5000):
98
  df = generate_synthetic_dataset(10000)
99
 
100
  # Prepare data for ML model
101
- X = df.drop(['Crop', 'Profit (INR/acre)'], axis=1)
102
  X = pd.get_dummies(X) # Convert categorical variables to dummy variables
103
  y = df['Crop']
104
 
@@ -111,47 +115,53 @@ model.fit(X_train, y_train)
111
 
112
  # Crop precautions information
113
  precautions_db = {
114
- 'Rice': [
115
- "Maintain proper water level (5-10 cm) in the field",
116
- "Control weeds through manual weeding or herbicides",
117
- "Use balanced fertilizers (N:P:K = 100:50:50 kg/ha)",
118
- "Watch for pests like stem borers and leaf folders"
119
  ],
120
- 'Maize': [
121
- "Ensure proper spacing (60x20 cm)",
122
- "Apply fertilizers in split doses",
123
- "Control weeds during first 30-40 days",
124
- "Watch for fall armyworm and use pheromone traps"
 
 
 
 
 
 
125
  ],
126
- 'Cotton': [
127
- "Use drip irrigation for water efficiency",
128
- "Monitor for pink bollworm regularly",
129
- "Practice crop rotation to prevent pest buildup",
130
- "Use recommended spacing (90x60 cm)"
131
  ],
132
- 'Groundnut': [
133
- "Ensure well-drained soil to prevent fungal diseases",
134
- "Apply gypsum at flowering stage (500 kg/ha)",
135
- "Control weeds during first 45 days",
136
- "Harvest at proper maturity to avoid pod loss"
137
  ],
138
- 'Red Gram (Toor Dal)': [
139
- "Sow in rows with 45 cm spacing",
140
- "Treat seeds with rhizobium culture",
141
- "Provide protective irrigation during flowering",
142
- "Watch for pod borer and apply neem oil"
143
  ],
144
- 'Tomato': [
145
- "Use staking for better fruit quality",
146
- "Practice crop rotation to avoid soil diseases",
147
- "Monitor for fruit borer and whitefly",
148
- "Harvest at breaker stage for longer shelf life"
149
  ],
150
- 'Chilli': [
151
- "Raise seedlings in nursery for 35-40 days",
152
- "Mulch to conserve soil moisture",
153
- "Monitor for thrips and mites regularly",
154
- "Harvest at regular intervals for higher yield"
155
  ],
156
  # Default precautions for other crops
157
  'Default': [
@@ -170,16 +180,16 @@ def get_precautions(crop, temperature, rainfall, humidity, soil_type):
170
  if temperature > 35:
171
  precautions.append("Provide mulch to reduce soil temperature")
172
  precautions.append("Increase irrigation frequency during hot days")
173
- if rainfall < 50:
174
- precautions.append("Use water conservation techniques like drip irrigation")
175
- if humidity > 80:
176
  precautions.append("Watch for fungal diseases and apply preventive sprays")
177
 
178
  # Add soil-specific precautions
179
- if soil_type == 'Black Cotton':
180
- precautions.append("Practice deep ploughing to break soil hardpans")
181
- elif soil_type == 'Sandy Loam':
182
- precautions.append("Apply organic manure to improve water retention")
183
 
184
  return precautions[:5] # Return top 5 precautions
185
 
@@ -198,11 +208,11 @@ def predict_crop(temperature, rainfall, humidity, soil_ph, soil_type, nitrogen,
198
  }
199
 
200
  # Add soil type columns (one-hot encoding)
201
- for st in ['Black Cotton', 'Red Sandy', 'Clayey', 'Loamy', 'Sandy Loam']:
202
  input_data[f'Soil Type_{st}'] = [1 if soil_type == st else 0]
203
 
204
  # Add season columns (one-hot encoding)
205
- for s in ['Kharif (June-Oct)', 'Rabi (Oct-Mar)', 'Zaid (Mar-Jun)', 'Whole Year']:
206
  input_data[f'Season_{s}'] = [1 if season == s else 0]
207
 
208
  input_df = pd.DataFrame(input_data)
@@ -214,7 +224,7 @@ def predict_crop(temperature, rainfall, humidity, soil_ph, soil_type, nitrogen,
214
  crop = model.predict(input_df)[0]
215
 
216
  # Get profit range
217
- profit = df[df['Crop'] == crop]['Profit (INR/acre)'].mean()
218
 
219
  # Get precautions
220
  precautions = get_precautions(crop, temperature, rainfall, humidity, soil_type)
@@ -227,7 +237,7 @@ def predict_crop(temperature, rainfall, humidity, soil_ph, soil_type, nitrogen,
227
  # Prepare output
228
  output = {
229
  "Recommended Crop": crop,
230
- "Expected Profit (INR per acre)": f"{int(profit):,}",
231
  "Top Precautions": precautions,
232
  "Alternative Crops": similar_crops,
233
  "Best Season": season
@@ -364,7 +374,7 @@ custom_css = """
364
  # Function to format outputs
365
  def format_outputs(output):
366
  crop_md = f"**Recommended Crop:** {output['Recommended Crop']}"
367
- profit_md = f"**Expected Profit (INR per acre):** {output['Expected Profit (INR per acre)']}"
368
  season_md = f"**Best Season:** {output['Best Season']}"
369
  alt_md = f"**Alternative Crops:** {', '.join(output['Alternative Crops'])}"
370
 
@@ -381,98 +391,98 @@ with gr.Blocks(css=custom_css) as demo:
381
  with gr.Column(elem_classes="agrismart-container"):
382
  with gr.Row(elem_classes="agrismart-header"):
383
  gr.Markdown("""
384
- # 🌱 Crop Vision : Smart Crop Advisor for Farmers
385
- ### Get personalized crop recommendations based on your farm conditions
386
  """)
387
 
388
  with gr.Row():
389
  with gr.Column(elem_classes="agrismart-input"):
390
- gr.Markdown("### 🌦️ Enter Your Farm Conditions", elem_classes="agrismart-label")
391
 
392
  with gr.Row():
393
- temperature = gr.Slider(10, 60, label="1. Temperature (How hot is your area?)",
394
- info="Measure the air temperature in shade (°C)",
395
  elem_classes="agrismart-slider")
396
- rainfall = gr.Slider(0, 300, label="2. Rainfall (How much rain your area gets?)",
397
- info="Annual rainfall in your area (mm)",
398
  elem_classes="agrismart-slider")
399
 
400
  with gr.Row():
401
- humidity = gr.Slider(20, 100, label="3. Humidity (How moist is your air?)",
402
- info="Relative humidity percentage (%)",
403
  elem_classes="agrismart-slider")
404
- soil_ph = gr.Slider(4, 10, label="4. Soil pH (Is your soil acidic or alkaline?)",
405
- info="7 is neutral, below 7 is acidic, above 7 is alkaline",
406
  elem_classes="agrismart-slider")
407
 
408
  with gr.Row():
409
  soil_type = gr.Dropdown(
410
- ["Black Cotton", "Red Sandy", "Clayey", "Loamy", "Sandy Loam"],
411
- label="5. Soil Type (What type of soil do you have?)",
412
- info="Black Cotton is common in Andhra/Telangana",
413
  elem_classes="agrismart-dropdown"
414
  )
415
  season = gr.Dropdown(
416
- ["Kharif (June-Oct)", "Rabi (Oct-Mar)", "Zaid (Mar-Jun)", "Whole Year"],
417
- label="6. Season (When will you cultivate?)",
418
  elem_classes="agrismart-dropdown"
419
  )
420
 
421
  with gr.Row():
422
- nitrogen = gr.Slider(0, 150, label="7. Nitrogen Level (N) in soil",
423
- info="Essential for leaf growth (kg/ha)",
424
  elem_classes="agrismart-slider")
425
- phosphorus = gr.Slider(0, 100, label="8. Phosphorus Level (P) in soil",
426
- info="Important for root development (kg/ha)",
427
  elem_classes="agrismart-slider")
428
- potassium = gr.Slider(0, 200, label="9. Potassium Level (K) in soil",
429
- info="Helps in fruit quality (kg/ha)",
430
  elem_classes="agrismart-slider")
431
 
432
- submit_btn = gr.Button("Get Crop Recommendation", elem_classes="agrismart-button")
433
 
434
  with gr.Column(elem_classes="agrismart-output"):
435
- gr.Markdown("### 📊 Recommended Crop Details", elem_classes="agrismart-label")
436
 
437
  with gr.Column(elem_classes="agrismart-result-card"):
438
- crop = gr.Markdown("**Recommended Crop:** ", elem_classes="agrismart-result-value")
439
- profit = gr.Markdown("**Expected Profit (INR per acre):** ", elem_classes="agrismart-result-value")
440
- season_out = gr.Markdown("**Best Season:** ", elem_classes="agrismart-result-value")
441
- alternatives = gr.Markdown("**Alternative Crops:** ", elem_classes="agrismart-result-value")
442
 
443
- gr.Markdown("### 🛡️ Top Precautions", elem_classes="agrismart-result-title")
444
  precautions = gr.HTML("""
445
  <ul class="agrismart-precautions">
446
- <li>Enter your farm details and click the button to get recommendations</li>
447
  </ul>
448
  """)
449
 
450
- # Example images (would need actual images in production)
451
- gr.Markdown("### 🌾 Common Crops in Andhra/Telangana")
452
  gr.HTML("""
453
  <div style="display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;">
454
  <div style="text-align: center;">
455
  <div style="background: #e3f2fd; padding: 10px; border-radius: 10px; width: 100px;">
456
  <div style="font-size: 40px;">🌾</div>
457
- <div>Rice</div>
458
  </div>
459
  </div>
460
  <div style="text-align: center;">
461
  <div style="background: #e8f5e9; padding: 10px; border-radius: 10px; width: 100px;">
462
- <div style="font-size: 40px;">🌽</div>
463
- <div>Maize</div>
464
  </div>
465
  </div>
466
  <div style="text-align: center;">
467
  <div style="background: #fff3e0; padding: 10px; border-radius: 10px; width: 100px;">
468
- <div style="font-size: 40px;">🧶</div>
469
- <div>Cotton</div>
470
  </div>
471
  </div>
472
  <div style="text-align: center;">
473
  <div style="background: #f3e5f5; padding: 10px; border-radius: 10px; width: 100px;">
474
- <div style="font-size: 40px;">🥜</div>
475
- <div>Groundnut</div>
476
  </div>
477
  </div>
478
  </div>
 
5
  import gradio as gr
6
  import random
7
 
8
+ # Generate synthetic dataset for Bangladesh crops
9
  def generate_synthetic_dataset(num_samples=5000):
10
  np.random.seed(42)
11
 
12
+ # Common crops in Bangladesh
13
  crops = [
14
+ 'Rice (Aman)', 'Rice (Boro)', 'Rice (Aus)', 'Jute', 'Wheat',
15
+ 'Maize', 'Potato', 'Sugarcane', 'Pulses (Mungbean)', 'Pulses (Lentil)',
16
+ 'Mustard', 'Sesame', 'Sunflower', 'Tea', 'Mango',
17
+ 'Banana', 'Jackfruit', 'Litchi', 'Pineapple', 'Vegetables'
18
  ]
19
 
20
+ # Soil types common in Bangladesh
21
+ soil_types = ['Alluvial', 'Loamy', 'Clayey', 'Peaty', 'Sandy']
22
 
23
+ # Seasons in Bangladesh agriculture
24
+ seasons = ['Kharif-1 (Mar-Jun)', 'Kharif-2 (Jul-Oct)', 'Rabi (Nov-Feb)', 'Whole Year']
25
 
26
  # Generate synthetic data
27
  data = {
28
+ 'Temperature (°C)': np.random.uniform(10, 40, num_samples), # Bangladesh has more moderate temperatures
29
+ 'Rainfall (mm)': np.random.uniform(100, 400, num_samples), # Higher rainfall range
30
+ 'Humidity (%)': np.random.uniform(60, 100, num_samples), # Generally high humidity
31
+ 'Soil pH': np.random.uniform(5.0, 8.5, num_samples), # Slightly acidic to neutral
32
  'Soil Type': np.random.choice(soil_types, num_samples),
33
  'Nitrogen (N) Level': np.random.uniform(0, 150, num_samples),
34
  'Phosphorus (P) Level': np.random.uniform(0, 100, num_samples),
 
45
  crop = row['Crop']
46
 
47
  # Temperature adjustments
48
+ if 'Rice' in crop:
49
+ df.at[idx, 'Temperature (°C)'] = np.random.uniform(25, 35)
50
+ df.at[idx, 'Humidity (%)'] = np.random.uniform(70, 100)
51
+ elif crop in ['Wheat', 'Mustard', 'Potato']:
52
+ df.at[idx, 'Temperature (°C)'] = np.random.uniform(15, 25)
53
+ elif crop in ['Jute', 'Tea']:
54
+ df.at[idx, 'Temperature (°C)'] = np.random.uniform(20, 30)
55
+ df.at[idx, 'Rainfall (mm)'] = np.random.uniform(200, 400)
56
 
57
  # Soil type adjustments
58
+ if crop in ['Jute']:
59
+ df.at[idx, 'Soil Type'] = 'Alluvial'
60
+ elif crop in ['Tea']:
61
+ df.at[idx, 'Soil Type'] = 'Loamy'
62
+ elif crop in ['Rice (Boro)']:
63
+ df.at[idx, 'Soil Type'] = random.choice(['Alluvial', 'Clayey'])
64
 
65
  # Season adjustments
66
+ if crop in ['Rice (Aman)', 'Jute']:
67
+ df.at[idx, 'Season'] = 'Kharif-2 (Jul-Oct)'
68
+ elif crop in ['Rice (Boro)', 'Wheat', 'Mustard', 'Potato']:
69
+ df.at[idx, 'Season'] = 'Rabi (Nov-Feb)'
70
+ elif crop in ['Rice (Aus)']:
71
+ df.at[idx, 'Season'] = 'Kharif-1 (Mar-Jun)'
72
 
73
+ # Add profit estimates (in BDT per acre)
74
  profit_ranges = {
75
+ 'Rice (Aman)': (30000, 60000),
76
+ 'Rice (Boro)': (35000, 70000),
77
+ 'Rice (Aus)': (25000, 50000),
78
+ 'Jute': (40000, 80000),
79
+ 'Wheat': (25000, 50000),
80
+ 'Maize': (30000, 60000),
81
+ 'Potato': (50000, 100000),
82
+ 'Sugarcane': (60000, 120000),
83
+ 'Pulses (Mungbean)': (20000, 45000),
84
+ 'Pulses (Lentil)': (22000, 48000),
85
+ 'Mustard': (25000, 55000),
86
+ 'Sesame': (18000, 40000),
87
+ 'Sunflower': (20000, 45000),
88
+ 'Tea': (80000, 150000),
89
+ 'Mango': (100000, 250000),
90
+ 'Banana': (80000, 180000),
91
+ 'Jackfruit': (70000, 150000),
92
+ 'Litchi': (90000, 200000),
93
+ 'Pineapple': (60000, 120000),
94
+ 'Vegetables': (50000, 150000)
95
  }
96
 
97
+ df['Profit (BDT/acre)'] = df['Crop'].apply(lambda x: random.randint(*profit_ranges[x]))
98
 
99
  return df
100
 
 
102
  df = generate_synthetic_dataset(10000)
103
 
104
  # Prepare data for ML model
105
+ X = df.drop(['Crop', 'Profit (BDT/acre)'], axis=1)
106
  X = pd.get_dummies(X) # Convert categorical variables to dummy variables
107
  y = df['Crop']
108
 
 
115
 
116
  # Crop precautions information
117
  precautions_db = {
118
+ 'Rice (Aman)': [
119
+ "Transplant 25-30 day old seedlings",
120
+ "Maintain 2-3 cm standing water during initial stage",
121
+ "Apply 60-80 kg N, 15-20 kg P, and 30-40 kg K per hectare",
122
+ "Control stem borer with proper insecticides"
123
  ],
124
+ 'Rice (Boro)': [
125
+ "Ensure irrigation availability as it's dry season rice",
126
+ "Use cold-tolerant varieties in northern regions",
127
+ "Apply split doses of nitrogen fertilizer",
128
+ "Control rats and birds during ripening stage"
129
+ ],
130
+ 'Jute': [
131
+ "Sow in well-prepared land with proper moisture",
132
+ "Retting should be done in clean water for quality fiber",
133
+ "Apply 40-60 kg N, 20-30 kg P, and 20-30 kg K per hectare",
134
+ "Control jute hairy caterpillar with proper measures"
135
  ],
136
+ 'Wheat': [
137
+ "Sow in rows with 20 cm spacing",
138
+ "Apply irrigation at crown root initiation and flowering stages",
139
+ "Use disease-resistant varieties to combat rust",
140
+ "Harvest when moisture content is 20-25%"
141
  ],
142
+ 'Maize': [
143
+ "Sow in rows with 60 cm row to row distance",
144
+ "Apply 150-180 kg N, 35-40 kg P, and 60-70 kg K per hectare",
145
+ "Control fall armyworm with integrated pest management",
146
+ "Harvest when kernels have 20-25% moisture"
147
  ],
148
+ 'Potato': [
149
+ "Use disease-free seed tubers",
150
+ "Apply irrigation at critical growth stages",
151
+ "Control late blight with fungicides",
152
+ "Harvest when vines dry up"
153
  ],
154
+ 'Tea': [
155
+ "Prune bushes regularly for new flush",
156
+ "Apply balanced fertilizer with zinc and magnesium",
157
+ "Control red spider mite with acaricides",
158
+ "Pluck two leaves and a bud for quality"
159
  ],
160
+ 'Mango': [
161
+ "Prune for proper canopy management",
162
+ "Control mango hopper during flowering",
163
+ "Apply irrigation during fruit development",
164
+ "Harvest when shoulders develop"
165
  ],
166
  # Default precautions for other crops
167
  'Default': [
 
180
  if temperature > 35:
181
  precautions.append("Provide mulch to reduce soil temperature")
182
  precautions.append("Increase irrigation frequency during hot days")
183
+ if rainfall > 300:
184
+ precautions.append("Ensure proper drainage to prevent waterlogging")
185
+ if humidity > 85:
186
  precautions.append("Watch for fungal diseases and apply preventive sprays")
187
 
188
  # Add soil-specific precautions
189
+ if soil_type == 'Alluvial':
190
+ precautions.append("Apply organic matter to maintain soil fertility")
191
+ elif soil_type == 'Peaty':
192
+ precautions.append("Apply lime to reduce acidity if needed")
193
 
194
  return precautions[:5] # Return top 5 precautions
195
 
 
208
  }
209
 
210
  # Add soil type columns (one-hot encoding)
211
+ for st in ['Alluvial', 'Loamy', 'Clayey', 'Peaty', 'Sandy']:
212
  input_data[f'Soil Type_{st}'] = [1 if soil_type == st else 0]
213
 
214
  # Add season columns (one-hot encoding)
215
+ for s in ['Kharif-1 (Mar-Jun)', 'Kharif-2 (Jul-Oct)', 'Rabi (Nov-Feb)', 'Whole Year']:
216
  input_data[f'Season_{s}'] = [1 if season == s else 0]
217
 
218
  input_df = pd.DataFrame(input_data)
 
224
  crop = model.predict(input_df)[0]
225
 
226
  # Get profit range
227
+ profit = df[df['Crop'] == crop]['Profit (BDT/acre)'].mean()
228
 
229
  # Get precautions
230
  precautions = get_precautions(crop, temperature, rainfall, humidity, soil_type)
 
237
  # Prepare output
238
  output = {
239
  "Recommended Crop": crop,
240
+ "Expected Profit (BDT per acre)": f"{int(profit):,}",
241
  "Top Precautions": precautions,
242
  "Alternative Crops": similar_crops,
243
  "Best Season": season
 
374
  # Function to format outputs
375
  def format_outputs(output):
376
  crop_md = f"**Recommended Crop:** {output['Recommended Crop']}"
377
+ profit_md = f"**Expected Profit (BDT per acre):** {output['Expected Profit (BDT per acre)']}"
378
  season_md = f"**Best Season:** {output['Best Season']}"
379
  alt_md = f"**Alternative Crops:** {', '.join(output['Alternative Crops'])}"
380
 
 
391
  with gr.Column(elem_classes="agrismart-container"):
392
  with gr.Row(elem_classes="agrismart-header"):
393
  gr.Markdown("""
394
+ # 🌱 বাংলাদেশের জন্য ফসল সুপারিশকারী
395
+ ### আপনার জমির অবস্থা অনুযায়ী উপযুক্ত ফসলের পরামর্শ পান
396
  """)
397
 
398
  with gr.Row():
399
  with gr.Column(elem_classes="agrismart-input"):
400
+ gr.Markdown("### 🌦️ আপনার জমির তথ্য দিন", elem_classes="agrismart-label")
401
 
402
  with gr.Row():
403
+ temperature = gr.Slider(10, 40, label="1. তাপমাত্রা (°C)",
404
+ info="ছায়াযুক্ত স্থানে বায়ুর তাপমাত্রা মাপুন",
405
  elem_classes="agrismart-slider")
406
+ rainfall = gr.Slider(100, 400, label="2. বৃষ্টিপাত (mm)",
407
+ info="আপনার এলাকার বার্ষিক বৃষ্টিপাতের পরিমাণ",
408
  elem_classes="agrismart-slider")
409
 
410
  with gr.Row():
411
+ humidity = gr.Slider(60, 100, label="3. আর্দ্রতা (%)",
412
+ info="বাতাসে আর্দ্রতার পরিমাণ",
413
  elem_classes="agrismart-slider")
414
+ soil_ph = gr.Slider(5, 8.5, label="4. মাটির pH মান",
415
+ info=" হলো নিরপেক্ষ, এর নিচে অম্লীয়, এর উপরে ক্ষারীয়",
416
  elem_classes="agrismart-slider")
417
 
418
  with gr.Row():
419
  soil_type = gr.Dropdown(
420
+ ["Alluvial", "Loamy", "Clayey", "Peaty", "Sandy"],
421
+ label="5. মাটির ধরন",
422
+ info="বাংলাদেশের সাধারণ মাটির ধরন",
423
  elem_classes="agrismart-dropdown"
424
  )
425
  season = gr.Dropdown(
426
+ ["Kharif-1 (Mar-Jun)", "Kharif-2 (Jul-Oct)", "Rabi (Nov-Feb)", "Whole Year"],
427
+ label="6. মৌসুম",
428
  elem_classes="agrismart-dropdown"
429
  )
430
 
431
  with gr.Row():
432
+ nitrogen = gr.Slider(0, 150, label="7. মাটিতে নাইট্রোজেনের পরিমাণ (N)",
433
+ info="গাছের পাতার বৃদ্ধির জন্য প্রয়োজনীয় (kg/ha)",
434
  elem_classes="agrismart-slider")
435
+ phosphorus = gr.Slider(0, 100, label="8. মাটিতে ফসফরাসের পরিমাণ (P)",
436
+ info="শিকড়ের উন্নতির জন্য গুরুত্বপূর্ণ (kg/ha)",
437
  elem_classes="agrismart-slider")
438
+ potassium = gr.Slider(0, 200, label="9. মাটিতে পটাশিয়ামের পরিমাণ (K)",
439
+ info="ফলের গুণগত মানের জন্য সহায়ক (kg/ha)",
440
  elem_classes="agrismart-slider")
441
 
442
+ submit_btn = gr.Button("ফসলের সুপারিশ পান", elem_classes="agrismart-button")
443
 
444
  with gr.Column(elem_classes="agrismart-output"):
445
+ gr.Markdown("### 📊 সুপারিশকৃত ফসলের বিবরণ", elem_classes="agrismart-label")
446
 
447
  with gr.Column(elem_classes="agrismart-result-card"):
448
+ crop = gr.Markdown("**সুপারিশকৃত ফসল:** ", elem_classes="agrismart-result-value")
449
+ profit = gr.Markdown("**আনুমানিক লাভ (প্রতি একরে):** ", elem_classes="agrismart-result-value")
450
+ season_out = gr.Markdown("**উপযুক্ত মৌসুম:** ", elem_classes="agrismart-result-value")
451
+ alternatives = gr.Markdown("**বিকল্প ফসল:** ", elem_classes="agrismart-result-value")
452
 
453
+ gr.Markdown("### 🛡️ প্রয়োজনীয় সতর্কতা", elem_classes="agrismart-result-title")
454
  precautions = gr.HTML("""
455
  <ul class="agrismart-precautions">
456
+ <li>আপনার জমির তথ্য প্রদান করে বাটনে ক্লিক করুন</li>
457
  </ul>
458
  """)
459
 
460
+ # Example images of common Bangladeshi crops
461
+ gr.Markdown("### 🌾 বাংলাদেশের প্রধান ফসল")
462
  gr.HTML("""
463
  <div style="display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;">
464
  <div style="text-align: center;">
465
  <div style="background: #e3f2fd; padding: 10px; border-radius: 10px; width: 100px;">
466
  <div style="font-size: 40px;">🌾</div>
467
+ <div>ধান</div>
468
  </div>
469
  </div>
470
  <div style="text-align: center;">
471
  <div style="background: #e8f5e9; padding: 10px; border-radius: 10px; width: 100px;">
472
+ <div style="font-size: 40px;">🧶</div>
473
+ <div>পাট</div>
474
  </div>
475
  </div>
476
  <div style="text-align: center;">
477
  <div style="background: #fff3e0; padding: 10px; border-radius: 10px; width: 100px;">
478
+ <div style="font-size: 40px;">🥔</div>
479
+ <div>আলু</div>
480
  </div>
481
  </div>
482
  <div style="text-align: center;">
483
  <div style="background: #f3e5f5; padding: 10px; border-radius: 10px; width: 100px;">
484
+ <div style="font-size: 40px;">🍌</div>
485
+ <div>কলা</div>
486
  </div>
487
  </div>
488
  </div>