Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,8 +38,8 @@ X_train, X_test, y_train, y_test = train_test_split(X, y_encoded, test_size=0.3,
|
|
| 38 |
model = lgb.LGBMClassifier()
|
| 39 |
model.fit(X_train, y_train)
|
| 40 |
|
| 41 |
-
def predict_crop(
|
| 42 |
-
input_data = np.array([[
|
| 43 |
pred = model.predict(input_data)[0]
|
| 44 |
crop_name = le.inverse_transform([pred])[0]
|
| 45 |
return f"🌾ਤੁਹਾਡੇ ਖੇਤ ਲਈ ਸੁਝਾਈ ਗਈ ਫਸਲ: *{crop_name}*"
|
|
@@ -187,18 +187,18 @@ with gr.Blocks() as demo:
|
|
| 187 |
with gr.Tabs():
|
| 188 |
with gr.TabItem("🌾ਕਿਹੜੀ ਫਸਲ ਲਾਈਏ? "):
|
| 189 |
with gr.Row():
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
with gr.Row():
|
| 194 |
-
|
| 195 |
-
|
| 196 |
with gr.Row():
|
| 197 |
-
|
| 198 |
-
|
| 199 |
predict_btn = gr.Button("ਫਸਲ ਦੀ ਭਵਿੱਖਬਾਣੀ ਕਰੋ")
|
| 200 |
crop_output = gr.Markdown()
|
| 201 |
-
predict_btn.click(predict_crop, inputs=[
|
| 202 |
|
| 203 |
with gr.TabItem("🔁 ਫਸਲ ਤੋਂ ਪੈਰਾਮੀਟਰ"):
|
| 204 |
crop_input = gr.Dropdown(choices=crops, label="🌿 ਫਸਲ ਦਾ ਨਾਂ ਲਿਖੋ")
|
|
|
|
| 38 |
model = lgb.LGBMClassifier()
|
| 39 |
model.fit(X_train, y_train)
|
| 40 |
|
| 41 |
+
def predict_crop(ਨਾਈਟ੍ਰੋਜਨ (kg/ha),ਫਾਸਫੋਰਸ (kg/ha),ਪੋਟਾਸ਼ੀਅਮ (kg/ha),ਤਾਪਮਾਨ (°C),ਨਮੀ (%),ਮਿੱਟੀ ਦਾ pH,ਵਰਖਾ (mm)):
|
| 42 |
+
input_data = np.array([[ਨਾਈਟ੍ਰੋਜਨ (kg/ha),ਫਾਸਫੋਰਸ (kg/ha),ਪੋਟਾਸ਼ੀਅਮ (kg/ha),ਤਾਪਮਾਨ (°C),ਨਮੀ (%),ਮਿੱਟੀ ਦਾ pH,ਵਰਖਾ (mm)]])
|
| 43 |
pred = model.predict(input_data)[0]
|
| 44 |
crop_name = le.inverse_transform([pred])[0]
|
| 45 |
return f"🌾ਤੁਹਾਡੇ ਖੇਤ ਲਈ ਸੁਝਾਈ ਗਈ ਫਸਲ: *{crop_name}*"
|
|
|
|
| 187 |
with gr.Tabs():
|
| 188 |
with gr.TabItem("🌾ਕਿਹੜੀ ਫਸਲ ਲਾਈਏ? "):
|
| 189 |
with gr.Row():
|
| 190 |
+
ਨਾਈਟ੍ਰੋਜਨ (kg/ha) = gr.Slider(0, 140, step=1, label="ਨਾਈਟ੍ਰੋਜਨ (kg/ha)")
|
| 191 |
+
ਫਾਸਫੋਰਸ (kg/ha)= gr.Slider(5, 95, step=1, label="ਫਾਸਫੋਰਸ (kg/ha)")
|
| 192 |
+
ਪੋਟਾਸ਼ੀਅਮ (kg/ha)= gr.Slider(5, 82, step=1, label="ਪੋਟਾਸ਼ੀਅਮ (kg/ha)")
|
| 193 |
with gr.Row():
|
| 194 |
+
ਤਾਪਮਾਨ (°C)= gr.Slider(15.63, 36.32, step=0.1, label="ਤਾਪਮਾਨ (°C)")
|
| 195 |
+
ਨਮੀ (%)= gr.Slider(14.2,99.98 , step=1, label="ਨਮੀ (%)")
|
| 196 |
with gr.Row():
|
| 197 |
+
ਮਿੱਟੀ ਦਾ pH = gr.Slider(0, 14, step=0.1, label="ਮਿੱਟੀ ਦਾ pH")
|
| 198 |
+
ਵਰਖਾ (mm)= gr.Slider(20.21, 253.72, step=1, label="ਵਰਖਾ (mm)")
|
| 199 |
predict_btn = gr.Button("ਫਸਲ ਦੀ ਭਵਿੱਖਬਾਣੀ ਕਰੋ")
|
| 200 |
crop_output = gr.Markdown()
|
| 201 |
+
predict_btn.click(predict_crop, inputs=[ਨਾਈਟ੍ਰੋਜਨ (kg/ha),ਫਾਸਫੋਰਸ (kg/ha),ਪੋਟਾਸ਼ੀਅਮ (kg/ha),ਤਾਪਮਾਨ (°C),ਨਮੀ (%),ਮਿੱਟੀ ਦਾ pH,ਵਰਖਾ (mm), outputs=crop_output)
|
| 202 |
|
| 203 |
with gr.TabItem("🔁 ਫਸਲ ਤੋਂ ਪੈਰਾਮੀਟਰ"):
|
| 204 |
crop_input = gr.Dropdown(choices=crops, label="🌿 ਫਸਲ ਦਾ ਨਾਂ ਲਿਖੋ")
|