nishantguvvada commited on
Commit
03e0ab0
·
verified ·
1 Parent(s): 4b58119

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -15
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import numpy as np
2
  import pandas as pd
3
  import streamlit as st
 
4
  from PIL import Image
5
 
6
  st.set_page_config(
@@ -13,6 +14,45 @@ st.set_page_config(
13
  }
14
  )
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  image = Image.open('./title.jpg')
18
  st.image(image)
@@ -23,25 +63,30 @@ with st.sidebar:
23
  st.markdown("<h2 style='text-align: center; color: red;'>Settings Tab</h2>", unsafe_allow_html=True)
24
 
25
 
26
- st.write("Model Settings:")
 
 
 
 
 
 
 
 
 
27
 
28
- #define the temeperature for the model
29
- temperature_value = st.slider('Temperature :', 0.0, 1.0, 0.2)
30
- st.session_state['temperature'] = temperature_value
31
 
32
- #define the temeperature for the model
33
- token_limit_value = st.slider('Token limit :', 1, 1024, 256)
34
- st.session_state['token_limit'] = token_limit_value
35
 
36
- #define the temeperature for the model
37
- top_k_value = st.slider('Top-K :', 1,40,40)
38
- st.session_state['top_k'] = top_k_value
39
 
40
- #define the temeperature for the model
41
- top_p_value = st.slider('Top-P :', 0.0, 1.0, 0.8)
42
- st.session_state['top_p'] = top_p_value
43
 
44
- if st.button("Reset Session"):
45
- reset_session()
46
 
47
 
 
1
  import numpy as np
2
  import pandas as pd
3
  import streamlit as st
4
+ import pickle
5
  from PIL import Image
6
 
7
  st.set_page_config(
 
14
  }
15
  )
16
 
17
+ model = pickle.load(open('crop_model.pkl','rb'))
18
+
19
+ check_crops = {1: 'rice',
20
+ 2: 'maize',
21
+ 3: 'jute',
22
+ 4: 'cotton',
23
+ 5: 'coconut',
24
+ 6: 'papaya',
25
+ 7: 'orange',
26
+ 8: 'apple',
27
+ 9: 'muskmelon',
28
+ 10: 'watermelon',
29
+ 11: 'grapes',
30
+ 12: 'mango',
31
+ 13: 'banana',
32
+ 14: 'pomegranate',
33
+ 15: 'lentil',
34
+ 16: 'blackgram',
35
+ 17: 'mungbean',
36
+ 18: 'mothbeans',
37
+ 19: 'pigeonpeas',
38
+ 20: 'kidneybeans',
39
+ 21: 'chickpea',
40
+ 22: 'coffee'}
41
+
42
+ def recommend(N, P, K, temperature, humidity, ph, rainfall):
43
+ features = np.array([[N, P, K, temperature, humidity, ph, rainfall]]).reshape(1,-1)
44
+ features = ms.transform(features)
45
+ features = ss.transform(features)
46
+ prediction = rfc.predict(features)
47
+ return prediction[0]
48
+
49
+ def output(N, P, K, temperature, humidity, ph, rainfall):
50
+ predict = recommend(N, P, K, temperature, humidity, ph, rainfall)
51
+ if predict in check_crops:
52
+ crop = check_crops[predict]
53
+ print("Our crop recommendation is {}".format(crop))
54
+ else:
55
+ print("No recommendation")
56
 
57
  image = Image.open('./title.jpg')
58
  st.image(image)
 
63
  st.markdown("<h2 style='text-align: center; color: red;'>Settings Tab</h2>", unsafe_allow_html=True)
64
 
65
 
66
+ st.write("Input Settings:")
67
+
68
+ #define the N for the model
69
+ n_value = st.slider('N :', 0.0, 150.0, 20)
70
+
71
+ #define the P for the model
72
+ p_value = st.slider('P :', 0.0, 150.0, 20)
73
+
74
+ #define the K for the model
75
+ k_value = st.slider('K :', 0.0, 200.0, 40)
76
 
77
+ #define the temperature for the model
78
+ temperature = st.slider('Temperature :', 0.0, 50.0, 10.0)
 
79
 
80
+ #define the humidity for the model
81
+ humidity = st.slider('Humidity :', 0.0, 100.0, 40)
 
82
 
83
+ #define the ph for the model
84
+ ph_value = st.slider('ph :', 0.0, 10.0, 2.0)
 
85
 
86
+ #define the rainfall for the model
87
+ rainfall = st.slider('Rainfall :', 10.0, 300.0, 40)
 
88
 
89
+ if st.button("Recommend"):
90
+ output(n_value, p_value, k_value, temperature, humidity, ph_value, rainfall)
91
 
92