dilpreet77 commited on
Commit
0545814
·
verified ·
1 Parent(s): 63f491c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -4,10 +4,10 @@ import numpy as np
4
 
5
  app = Flask(__name__)
6
 
7
- # Load trained model
8
  model = pickle.load(open("crop.pkl", "rb"))
9
 
10
- # Load trained LabelEncoder
11
  le = pickle.load(open("label_encoder.pkl", "rb"))
12
 
13
  @app.route("/")
@@ -27,8 +27,7 @@ def predict():
27
  features = np.array([[N, P, K, temperature, humidity, ph, rainfall]])
28
  pred = model.predict(features)
29
 
30
- # Convert numeric → crop name
31
  crop = le.inverse_transform(pred)[0]
32
 
33
- return render_template("result.html", prediction_text=f"Recommended Crop: {crop}")
34
 
 
4
 
5
  app = Flask(__name__)
6
 
7
+ # Load the trained model
8
  model = pickle.load(open("crop.pkl", "rb"))
9
 
10
+ # Load the SAME LabelEncoder used during training
11
  le = pickle.load(open("label_encoder.pkl", "rb"))
12
 
13
  @app.route("/")
 
27
  features = np.array([[N, P, K, temperature, humidity, ph, rainfall]])
28
  pred = model.predict(features)
29
 
 
30
  crop = le.inverse_transform(pred)[0]
31
 
32
+ return render_template('result.html', prediction_text=f"Recommended Crop: {crop}")
33