Raghavendra0827 commited on
Commit
e454685
1 Parent(s): 358fb87

Upload 63 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. Agri_chatbot.py +132 -0
  3. Crop_Insurance_Risk.py +307 -0
  4. Crop_disease_prediction.py +142 -0
  5. Crop_recommendation.csv +0 -0
  6. Test Images/Apple_scab.JPG +0 -0
  7. Test Images/Grape_esca_black_measles.JPG +0 -0
  8. Test Images/Leaf_scorch.JPG +0 -0
  9. Test Images/Orange_Haunglongbing_citrus_greening.JPG +0 -0
  10. Test Images/Peach_bacterial_spot.JPG +0 -0
  11. Test Images/Pepper_bell_bacterial_spot.JPG +0 -0
  12. Test Images/Respberry_healthy.JPG +0 -0
  13. Test Images/Squash_Poedery_mildew.JPG +0 -0
  14. Test Images/Tomato_yellow_leaf_curl_virus.JPG +0 -0
  15. Test Images/apple_black_rot.JPG +0 -0
  16. Test Images/cedar_apple_rust.JPG +0 -0
  17. __pycache__/Agri_chatbot.cpython-310.pyc +0 -0
  18. __pycache__/Agri_chatbot.cpython-311.pyc +0 -0
  19. __pycache__/Crop_Insurance_Risk.cpython-310.pyc +0 -0
  20. __pycache__/Crop_Insurance_Risk.cpython-311.pyc +0 -0
  21. __pycache__/Crop_Recommendation.cpython-310.pyc +0 -0
  22. __pycache__/Crop_Recommendation.cpython-311.pyc +0 -0
  23. __pycache__/Crop_Recommendation.cpython-312.pyc +0 -0
  24. __pycache__/Crop_disease_prediction.cpython-310.pyc +0 -0
  25. __pycache__/Crop_disease_prediction.cpython-311.pyc +0 -0
  26. __pycache__/Crop_disease_prediction.cpython-312.pyc +0 -0
  27. __pycache__/Crop_yield.cpython-310.pyc +0 -0
  28. __pycache__/Crop_yield.cpython-311.pyc +0 -0
  29. __pycache__/Crop_yield.cpython-312.pyc +0 -0
  30. __pycache__/Insurance_risk.cpython-310.pyc +0 -0
  31. __pycache__/Insurance_risk.cpython-311.pyc +0 -0
  32. __pycache__/Mail.cpython-310.pyc +0 -0
  33. __pycache__/Mail.cpython-311.pyc +0 -0
  34. __pycache__/Rain_Forecast.cpython-310.pyc +0 -0
  35. __pycache__/Rain_Forecast.cpython-311.pyc +0 -0
  36. __pycache__/Rain_Forecast.cpython-312.pyc +0 -0
  37. __pycache__/Retrain_Crop_Recommendation.cpython-310.pyc +0 -0
  38. __pycache__/Weather_app.cpython-310.pyc +0 -0
  39. __pycache__/Weather_app.cpython-311.pyc +0 -0
  40. __pycache__/Weather_app.cpython-312.pyc +0 -0
  41. __pycache__/allmodelretrain.cpython-310.pyc +0 -0
  42. __pycache__/auth_module.cpython-310.pyc +0 -0
  43. __pycache__/auth_module.cpython-311.pyc +0 -0
  44. __pycache__/extra.cpython-311.pyc +0 -0
  45. __pycache__/feedback.cpython-310.pyc +0 -0
  46. __pycache__/feedbacko.cpython-310.pyc +0 -0
  47. __pycache__/feedbacko.cpython-311.pyc +0 -0
  48. __pycache__/gross_premimum.cpython-310.pyc +0 -0
  49. __pycache__/gross_premimum.cpython-311.pyc +0 -0
  50. __pycache__/retrain_Crop_yield.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ org_img/WhatsApp[[:space:]]Image[[:space:]]2024-01-06[[:space:]]at[[:space:]]00.30.46_332f69cb.jpg filter=lfs diff=lfs merge=lfs -text
Agri_chatbot.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import random
3
+ import time
4
+
5
+
6
+ def chatbot():
7
+
8
+ # Initialize translation object
9
+
10
+
11
+ # Language selection
12
+ selected_language = st.sidebar.selectbox("Select Language", ["English", "Kannada"])
13
+
14
+ # Set language for translation
15
+
16
+
17
+ background_image = 'https://media.istockphoto.com/id/1401698307/photo/digital-chatbot-robot-application-conversation-assistant-ai-artificial-intelligence.jpg?s=612x612&w=0&k=20&c=aLZtTBAIcn_UP1lZ2NOffS_Xs6EhhUXkBsipKu8pG7Q='
18
+ html_code = f"""
19
+ <style>
20
+ body {{
21
+ background-image: url('{background_image}');
22
+ background-size: cover;
23
+ background-position: center;
24
+ background-repeat: no-repeat;
25
+ height: 100vh; /* Set the height of the background to fill the viewport */
26
+ margin: 0; /* Remove default body margin */
27
+ display: flex;
28
+ flex-direction: column;
29
+ justify-content: center;
30
+ align-items: center;
31
+ }}
32
+ .stApp {{
33
+ background: none; /* Remove Streamlit app background */
34
+ }}
35
+ </style>
36
+ """
37
+ st.markdown(html_code, unsafe_allow_html=True)
38
+
39
+ # Initialize chat history
40
+ if "messages" not in st.session_state:
41
+ st.session_state.messages = []
42
+
43
+ # Display chat messages from history on app rerun
44
+ for message in st.session_state.messages:
45
+ with st.chat_message(message["role"]):
46
+ st.markdown(message["content"])
47
+
48
+ # Accept user input
49
+
50
+
51
+ if selected_language == "English":
52
+ options = [ "Weather Forecast", "Crop Disease", "Crop Yield", "Crop Recommendation", "Insurance", "How are you"]
53
+ prebuilt_option = st.selectbox("Select an option", options)
54
+ if prebuilt_option != "Select an option":
55
+
56
+ # Add user message to chat history
57
+ st.session_state.messages.append({"role": "user", "content": prebuilt_option})
58
+ # Display user message in chat message container
59
+ with st.chat_message("user"):
60
+ st.markdown(prebuilt_option)
61
+
62
+ # Display assistant response in chat message container
63
+ with st.chat_message("assistant"):
64
+ message_placeholder = st.empty()
65
+ full_response = ""
66
+ if prebuilt_option == "Weather Forecast":
67
+ assistant_response = "Sure thing! A weather forecast is like a prediction about what the weather will be like in the future. It tells us if it's going to be hot or cold, rainy or sunny, and even if there will be wind. People use it to plan activities, like deciding when to go outside or what to wear. You can get weather forecasts on websites, apps, or even by asking voice assistants. It's a handy tool to help us get ready for the day!"
68
+ elif prebuilt_option == "Crop Disease":
69
+ assistant_response = "Absolutely! When we talk about 'Crop Disease,' it means sickness or problems that can affect plants we grow, like fruits and veggies. These diseases can harm the crops and make them not grow well. Farmers need to watch out for signs of sickness in their plants, like spots on leaves or changes in color. If they notice anything wrong, they might use special treatments to help the plants get better. It's like taking care of plants, just like we take care of ourselves when we're not feeling well."
70
+ elif prebuilt_option == "Crop Yield":
71
+ assistant_response = "Sure thing! 'Crop Yield' is like the amount of good stuff we get from plants we grow, such as fruits, veggies, or grains. It's how much we harvest or pick. Farmers want a good crop yield because it means they get lots of healthy and tasty produce. Factors like weather, soil, and how well the plants are taken care of can affect the crop yield. So, when everything goes well, we get more yummy fruits and veggies to enjoy!"
72
+ elif prebuilt_option == "Crop Recommendation":
73
+ assistant_response = "Absolutely! 'Crop Recommendation' is like having a helpful friend for farmers. It suggests the best plants or crops to grow based on things like the soil, weather, and other conditions. So, if a farmer wants to know what would grow well in their area, the recommendation can guide them to make smart choices. It's like getting advice on what plants will be happy and thrive in their farm. Super handy for a successful and happy harvest!"
74
+ elif prebuilt_option == "How are you":
75
+ assistant_response = "Howdy! I'm thriving in the virtual fields, ready to assist you with all things agriculture! Is there anything specific you'd like to know or discuss about farming, crops, or the latest in agri-tech?"
76
+ elif prebuilt_option == "Insurance":
77
+ assistant_response = "Sure thing! 'Insurance risk' is like the chance of something unexpected happening that could cause a loss or damage to the things you want to protect. For example, if you have insurance for your farm, the risk could be things like bad weather, diseases affecting crops, or other unexpected events. Insurance helps to cover or manage these risks, so if something happens, you're not left with all the costs on your own. It's like having a safety net for your farm."
78
+ else:
79
+ assistant_response = "I'm sorry, I didn't understand that. How can I assist you today?"
80
+
81
+ for chunk in assistant_response.split():
82
+ full_response += chunk + " "
83
+ time.sleep(0.05)
84
+ # Add a blinking cursor to simulate typing
85
+ message_placeholder.markdown(full_response + "▌")
86
+ message_placeholder.markdown(full_response)
87
+
88
+ # Add assistant response to chat history
89
+ st.session_state.messages.append({"role": "assistant", "content": assistant_response})
90
+
91
+ else:
92
+ options = [ "ಹವಾಮಾನ ಮುನ್ಸೂಚನೆ", "ಬೆಳೆ ರೋಗಗಳು", "ಬೆಳೆ ಇಳುವರಿ", "ಬೆಳೆ ಶಿಫಾರಸು", "ವಿಮೆ", "ನಾನು ಹೇಗೆ ಇದ್ದೀನಿ?"]
93
+ prebuilt_option = st.selectbox("ಒಂದು ಆಯ್ಕೆಯನ್ನು ಆರಿಸಿ", options)
94
+ if prebuilt_option != "Select an option":
95
+
96
+ # Add user message to chat history
97
+ st.session_state.messages.append({"role": "user", "content": prebuilt_option})
98
+ # Display user message in chat message container
99
+ with st.chat_message("user"):
100
+ st.markdown(prebuilt_option)
101
+
102
+ # Display assistant response in chat message container
103
+ with st.chat_message("assistant"):
104
+ message_placeholder = st.empty()
105
+ full_response = ""
106
+ if prebuilt_option == "ಹವಾಮಾನ ಮುನ್ಸೂಚನೆ":
107
+ assistant_response = "ಖಂಡಿತ! ಹವಾಮಾನ ಮುನ್ಸೂಚನೆ ಅಂದರೆ ಭವಿಷ್ಯದಲ್ಲಿ ಹವಾಮಾನ ಹೇಗಿರಬಹುದು ಅನ್ನೋದರ ಬಗ್ಗೆ ಒಂದು ಊಹೆ. ಅದು ಬಿಸಿಯಾಗಿರುತ್ತದೆಯೇ ಅಥವಾ ತಂಪಾಗಿರುತ್ತದೆಯೇ, ಮಳೆಯಾಗುತ್ತದೆಯೇ ಅಥವಾ ಬಿಸಿಲಾಗಿರುತ್ತದೆಯೇ, ಮತ್ತು ಗಾಳಿ ಇರುತ್ತದೆಯೇ ಎಂದು ನಮಗೆ ತಿಳಿಸುತ್ತದೆ. ಯಾವಾಗ ಹೊರಗೆ ಹೋಗಬೇಕು ಅಥವಾ ಏನು ಧರಿಸಬೇಕು ಎಂದು ನಿರ್ಧರಿಸುವಂತಹ ಚಟುವಟಿಕೆಗಳನ್ನು ಯೋಜಿಸಲು ಜನರು ಇದನ್ನು ಬಳಸುತ್ತಾರೆ. ನೀವು ವೆಬ್‌ಸೈಟ್‌ಗಳು, ಅಪ್ಲಿಕೇಶನ್‌ಗಳು ಅಥವಾ ಧ್ವನಿ ಸಹಾಯಕರನ್ನು ಕೇಳುವ ಮೂಲಕವೂ ಹವಾಮಾನ ಮುನ್ಸೂಚನೆಯನ್ನು ಪಡೆಯಬಹುದು. ದಿನಕ್ಕೆ ಸಿದ್ಧವಾಗಲು ಇದು ಒಂದು ಉಪಯುಕ್ತ ಸಾಧನವಾಗಿದೆ!"
108
+ elif prebuilt_option == "ಬೆಳೆ ರೋಗಗಳು":
109
+ assistant_response = "ಖಂಡಿತವಾಗಿ! ನಾವು 'ಬೆಳೆ ರೋಗ'ದ ಬಗ್ಗೆ ಮಾತನಾಡುವಾಗ, ನಾವು ಬೆಳೆಯುವ ಸಸ್ಯಗಳಿಗೆ, ಹಣ್ಣುಗಳು ಮತ್ತು ತರಕಾರಿಗಳಂತಹ ಸಮಸ್ಯೆಗಳು ಅಥವಾ ಕಾಯಿಲೆಗಳು ಎಂದು ಅರ್ಥ. ಈ ರೋಗಗಳು ಬೆಳೆಗಳಿಗೆ ಹಾನಿಯನ್ನುಂಟುಮಾಡಬಹುದು ಮತ್ತು ಅವುಗಳು ಚೆನ್ನಾಗಿ ಬೆಳೆಯದಂತೆ ಮಾಡಬಹುದು. ರೈತರು ತಮ್ಮ ಸಸ್ಯಗಳಲ್ಲಿ ರೋಗದ ಲಕ್ಷಣಗಳನ್ನು ಗಮನಿಸಬೇಕು, ಉದಾಹರಣೆಗೆ ಎಲೆಗಳ ಮೇಲೆ ಕಲೆಗಳು ಅಥವಾ ಬಣ್ಣದಲ್ಲಿ ಬದಲಾವಣೆಗಳು. ಏನ."
110
+ elif prebuilt_option == "ಬೆಳೆ ಇಳುವರಿ":
111
+ assistant_response = "ಇದು ನೀವು ಬೆಳೆಯುವ ಗಿಡದಿಂದ ನೀವು ಪಡೆಯುವ ಉತ್ಪನ್ನದ ಪ್ರಮಾಣವಾಗಿದೆ. ಹಣ್ಣುಗಳು, ತರಕಾರಿಗಳು ಅಥವಾ ಧಾನ್ಯಗಳು ಇದಕ್ಕೆ ಉದಾಹರಣೆಗಳು. ರೈತರು ಉತ್ತಮ ಇಳುವರಿಯನ್ನು ಬಯಸುತ್ತಾರೆ ಏಕೆಂದರೆ ಅದು ಅವರಿಗೆ ಹೆಚ್ಚಿನ ಆದಾಯವನ್ನು ನೀಡುತ್ತದೆ. ಹವಾಮಾನ, ಮಣ್ಣು ಮತ��ತು ಗಿಡಗಳನ್ನು ಹೇಗೆ ನೋಡಿಕೊಳ್ಳಲಾಗುತ್ತದೆ ಎಂಬಂತಹ ಅಂಶಗಳು ಇಳುವರಿಯ ಮೇಲೆ ಪರಿಣಾಮ ಬೀರಬಹುದು."
112
+ elif prebuilt_option == "ಬೆಳೆ ಶಿಫಾರಸು":
113
+ assistant_response = " ಇದು ರೈತರಿಗೆ ಯಾವ ಬೆಳೆಗಳನ್ನು ಬೆಳೆಯಬೇಕೆಂದು ಸಲಹೆ ನೀಡುವಂತಿದೆ. ಮಣ್ಣು, ಹವಾಮಾನ ಮತ್ತು ಇತರ ಪರಿಸ್ಥಿತಿಗಳನ್ನು ಆಧರಿಸಿ ಇದು ಉತ್ತಮವಾದ ಗಿಡಗಳನ್ನು ಸೂಚಿಸುತ್ತದೆ. ಆದ್ದರಿಂದ, ಒಬ್ಬ ರೈತ ತಮ್ಮ ವಲಯದಲ್ಲಿ ಯಾವುದು ಚೆನ್ನಾಗಿ ಬೆಳೆಯುತ್ತದೆ ಎಂದು ತಿಳಿಯಲು ಬಯಸಿದರೆ, ಶಿಫಾರಸು ಅವರಿಗೆ ಬುದ್ಧಿವಂತ ಆಯ್ಕೆಗಳನ್ನು ಮಾಡಲು ಮಾರ್ಗದರ್ಶನ ನೀಡುತ್ತದೆ."
114
+ elif prebuilt_option == "ನಾನು ಹೇಗೆ ಇದ್ದೀನಿ?":
115
+ assistant_response = " ನಾನು ಸಂತೋಷವಾಗಿದ್ದೇನೆ! ಕೃಷಿ, ಬೆಳೆಗಳು ಅಥವಾ ಇತ್ತೀಚಿನ ಕೃಷಿ ತಂತ್ರಜ್ಞಾನದ ಬಗ್ಗೆ ನಿಮ್ಮ ಎಲ್ಲಾ ಪ್ರಶ್ನೆಗಳಿಗೆ ಸಹಾಯ ಮಾಡಲು ನಾನು ಸಿದ್ಧನಿದ್ದೇನೆ."
116
+ elif prebuilt_option == "ವಿಮೆ":
117
+ assistant_response = "ವಿಮೆ: ಇದು ನಿಮ್ಮ ಬಯಕೆಯ ವಸ್ತುಗಳಿಗೆ ನಷ್ಟ ಅಥವಾ ಹಾನಿಯನ್ನುಂಟುಮಾಡುವ ಯಾವುದೇ ಅನಿರೀಕ್ಷಿತ ಘಟನೆಯ ಸಂಭವನೀಯತೆ. ಉದಾಹರಣೆಗೆ, ನಿಮ್ಮ ಜಮೀನಿಗೆ ವಿಮೆ ಇದ್ದರೆ, ಕೆಟ್ಟ ಹವಾಮಾನ, ಬೆಳೆಗಳಿಗೆ ರೋಗಗಳು ಅಥವಾ ಇತರ ಅನಿರೀಕ್ಷಿತ ಘಟನೆಗಳು ಅಪಾಯಗಳಾಗಿರಬಹುದು. ವಿಮೆ ಈ ಅಪಾಯಗಳನ್ನು ನಿರ್ವಹಿಸಲು ಸಹಾಯ ಮಾಡುತ್ತದೆ, ಆದ್ದರಿಂದ ಏನಾದರೂ ಸಂಭವಿಸಿದರೆ, ನೀವು ಎಲ್ಲಾ ವೆಚ್ಚಗಳನ್ನು ಒಬ್ಬಂಟಿಯೇ ನಿಭಾಯಿಸಬೇಕಾಗಿಲ್ಲ. ಇದು ನಿಮ್ಮ ಜಮೀನಿಗೆ ಭದ್ರತೆಯ ಜಾಲವಿದ್ದಂತೆ."
118
+ else:
119
+ assistant_response = "ನಿಮ್ಮ ಪ್ರಶ್ನೆಗಳಿಗೆ ನಾನು ಉತ್ತರ ಅಥವಾ ನಿಮ್ಮ ಆಯ್ಕೆಗಳ ಬಗ್ಗೆ ಹೆಚ್ಚಿನ ಮಾಹಿತಿಯನ್ನು ನೀಡಬಹುದಾದರೆ, ದಯವಿಟ್ಟು ಕೇಳಿರಿ!?"
120
+
121
+ for chunk in assistant_response.split():
122
+ full_response += chunk + " "
123
+ time.sleep(0.05)
124
+ # Add a blinking cursor to simulate typing
125
+ message_placeholder.markdown(full_response + "▌")
126
+ message_placeholder.markdown(full_response)
127
+
128
+ # Add assistant response to chat history
129
+ st.session_state.messages.append({"role": "assistant", "content": assistant_response})
130
+
131
+ if __name__ == "__main__":
132
+ chatbot()
Crop_Insurance_Risk.py ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pydeck as pdk
4
+ import pickle
5
+ import time
6
+ import sum_insurance as insu
7
+ import gross_premimum as gross
8
+ import numpy as np
9
+
10
+ def sum_insurance_prediction(input_data,crop_insurance_sum_Raghu):
11
+ input_data_asarray = np.asarray(input_data)
12
+ input_data_reshaped = input_data_asarray.reshape(1,-1)
13
+ prediction = crop_insurance_sum_Raghu.predict(input_data_reshaped)
14
+ return prediction
15
+
16
+ def crop_grosspremimum_pred(input_data,crop_insurance_sum_Raghu):
17
+ input_data_asarray = np.asarray(input_data)
18
+ input_data_reshaped = input_data_asarray.reshape(1,-1)
19
+ prediction = crop_insurance_sum_Raghu.predict(input_data_reshaped)
20
+ return prediction
21
+
22
+ def insurance_app():
23
+ tab1, tab2,tab3 = st.tabs(["Maximum amount an insurance pay for a covered loss.","Total Amount insurance Paid by company in given period.","Feedback"])
24
+ with tab1:
25
+ st.title('Predict Insurance Payout on loss')
26
+ background_image = 'https://img.freepik.com/premium-photo/photo-coins-plant-black-background-with-empty-space-text-design-elements_176841-5042.jpg'
27
+ html_code = f"""
28
+ <style>
29
+ body {{
30
+ background-image: url('{background_image}');
31
+ background-size: cover;
32
+ background-position: center;
33
+ background-repeat: no-repeat;
34
+ height: 100vh; /* Set the height of the background to fill the viewport */
35
+ margin: 0; /* Remove default body margin */
36
+ display: flex;
37
+ flex-direction: column;
38
+ justify-content: center;
39
+ align-items: center;
40
+ }}
41
+ .stApp {{
42
+ background: none; /* Remove Streamlit app background */
43
+ }}
44
+ </style>
45
+ """
46
+ st.markdown(html_code, unsafe_allow_html=True)
47
+ # season,scheme,state_name,district_name,area_insured,sum_insured,farmer_share,goi_share,state_share,iu_count
48
+ # kharif,PMFBY,Andhra Pradesh,Anantapur,17.44,9493.41,453.87,285.46,285.46,85
49
+ @st.cache_resource
50
+ def load():
51
+ return pickle.load(open('crop_insurance_sum_Raghu.pkl','rb'))
52
+ crop_insurance_sum_Raghu = load()
53
+ # st.subheader('Enter Input Values')
54
+ col1,col2 = st.columns([1,1])
55
+ with col1:
56
+ season1 = st.selectbox('Season', ('kharif', 'rabi'),key=1)
57
+ with col1:
58
+ scheme1 = st.selectbox('Scheme', ('PMFBY', 'WBCIS'),key=2)
59
+ with col1:
60
+ state_name1 = st.selectbox('State Name',('Assam' ,'Chhattisgarh', 'Goa' ,'Haryana',
61
+ 'Himachal Pradesh', 'Karnataka', 'Kerala' ,'Madhya Pradesh' ,'Maharashtra',
62
+ 'Meghalaya', 'Odisha', 'Puducherry', 'Rajasthan', 'Sikkim', 'Tamil Nadu',
63
+ 'Tripura', 'Uttar Pradesh', 'Uttarakhand'),key=3)
64
+ with col1:
65
+ district_names = ('Anantapur', 'Chittoor', 'East Godavari', 'Guntur', 'Krishna',
66
+ 'Kurnool', 'Prakasam','Srikakulam', 'Vizianagaram',
67
+ 'West Godavari', 'Baksa', 'Barpeta', 'Bongaigaon', 'Cachar',
68
+ 'Chirang', 'Darrang', 'Dhemaji', 'Dhubri', 'Dibrugarh', 'Goalpara',
69
+ 'Golaghat', 'Hailakandi', 'Jorhat', 'Kamrup', 'Karbi Anglong',
70
+ 'Karimganj', 'Lakhimpur', 'Nagaon', 'Nalbari', 'Sivasagar',
71
+ 'Sonitpur', 'Tinsukia', 'Udalguri', 'Balod', 'Baloda Bazar',
72
+ 'Balrampur', 'Bastar', 'Bemetara', 'Bijapur', 'Bilaspur',
73
+ 'Dhamtari', 'Durg', 'Gariyaband', 'Janjgir-champa', 'Jashpur',
74
+ 'Kondagaon', 'Korba', 'Mahasamund', 'Mungeli', 'Narayanpur',
75
+ 'Raigarh', 'Raipur', 'Rajnandgaon', 'Sukma', 'Surajpur', 'Surguja',
76
+ 'North Goa', 'South Goa', 'Banas Kantha', 'Patan', 'Ambala',
77
+ 'Bhiwani', 'Faridabad', 'Fatehabad', 'Hisar', 'Jhajjar', 'Jind',
78
+ 'Kaithal', 'Karnal', 'Kurukshetra', 'Mahendragarh', 'Palwal',
79
+ 'Panchkula', 'Panipat', 'Rewari', 'Rohtak', 'Sirsa', 'Sonipat',
80
+ 'Yamunanagar', 'Chamba', 'Hamirpur', 'Kangra', 'Kullu', 'Mandi',
81
+ 'Shimla', 'Sirmaur', 'Solan', 'Una', 'Doda', 'Jammu', 'Kathua',
82
+ 'Kishtwar', 'Rajouri', 'Ramban', 'Reasi', 'Samba', 'Udhampur',
83
+ 'Bokaro', 'Chatra', 'Deoghar', 'Dhanbad', 'Dumka', 'Garhwa',
84
+ 'Giridih', 'Godda', 'Gumla', 'Hazaribagh', 'Jamtara', 'Khunti',
85
+ 'Latehar', 'Lohardaga', 'Pakur', 'Palamu', 'Ramgarh', 'Ranchi',
86
+ 'Simdega', 'Ballari', 'Belagavi', 'Bengaluru Rural',
87
+ 'Bengaluru Urban', 'Bidar', 'Chikkamagaluru', 'Chitradurga',
88
+ 'Dakshina Kannada', 'Davangere', 'Dharwad', 'Gadag', 'Haveri',
89
+ 'Kodagu', 'Kolar', 'Koppal', 'Mandya', 'Mysuru', 'Raichur',
90
+ 'Ramanagara', 'Shivamogga', 'Tumakuru', 'Udupi', 'Vijayapura',
91
+ 'Alappuzha', 'Ernakulam', 'Idukki', 'Kannur', 'Kasaragod',
92
+ 'Kollam', 'Kottayam', 'Kozhikode', 'Malappuram', 'Palakkad',
93
+ 'Pathanamthitta', 'Thiruvananthapuram', 'Thrissur', 'Wayanad',
94
+ 'Agar Malwa', 'Alirajpur', 'Anuppur', 'Ashoknagar', 'Balaghat',
95
+ 'Barwani', 'Betul', 'Bhind', 'Bhopal', 'Burhanpur', 'Chhatarpur',
96
+ 'Chhindwara', 'Damoh', 'Datia', 'Dewas', 'Dhar', 'Dindori', 'Guna',
97
+ 'Gwalior', 'Harda', 'Indore', 'Jabalpur', 'Jhabua', 'Katni',
98
+ 'Mandla', 'Mandsaur', 'Morena', 'Neemuch', 'Panna', 'Raisen',
99
+ 'Rajgarh', 'Ratlam', 'Rewa', 'Sagar', 'Satna', 'Sehore', 'Seoni',
100
+ 'Shahdol', 'Shajapur', 'Sheopur', 'Shivpuri', 'Sidhi', 'Singrauli',
101
+ 'Tikamgarh', 'Ujjain', 'Umaria', 'Vidisha', 'Akola', 'Amravati',
102
+ 'Aurangabad', 'Bhandara', 'Chandrapur', 'Dhule', 'Gadchiroli',
103
+ 'Hingoli', 'Jalgaon', 'Jalna', 'Kolhapur', 'Latur', 'Nagpur',
104
+ 'Nanded', 'Nandurbar', 'Nashik', 'Osmanabad', 'Palghar',
105
+ 'Parbhani', 'Pune', 'Ratnagiri', 'Sangli', 'Satara', 'Sindhudurg',
106
+ 'Solapur', 'Thane', 'Wardha', 'Washim', 'Yavatmal', 'Anugul',
107
+ 'Balangir', 'Baleshwar', 'Bargarh', 'Bhadrak', 'Cuttack',
108
+ 'Dhenkanal', 'Gajapati', 'Ganjam', 'Jagatsinghapur', 'Jajapur',
109
+ 'Jharsuguda', 'Kalahandi', 'Kandhamal', 'Kendrapara', 'Kendujhar',
110
+ 'Khordha', 'Koraput', 'Malkangiri', 'Mayurbhanj', 'Nayagarh',
111
+ 'Nuapada', 'Puri', 'Rayagada', 'Sambalpur', 'Sundargarh', 'Ajmer',
112
+ 'Alwar', 'Banswara', 'Baran', 'Barmer', 'Bharatpur', 'Bhilwara',
113
+ 'Bikaner', 'Bundi', 'Churu', 'Dausa', 'Dungarpur', 'Hanumangarh',
114
+ 'Jaipur', 'Jaisalmer', 'Jhalawar', 'Jhunjhunu', 'Jodhpur',
115
+ 'Karauli', 'Kota', 'Nagaur', 'Pali', 'Pratapgarh', 'Rajsamand',
116
+ 'Sawai Madhopur', 'Sikar', 'Sirohi', 'Tonk', 'Udaipur', 'Ariyalur',
117
+ 'Coimbatore', 'Cuddalore', 'Dharmapuri', 'Dindigul', 'Erode',
118
+ 'Kanniyakumari', 'Karur', 'Krishnagiri', 'Madurai', 'Nagapattinam',
119
+ 'Namakkal', 'Perambalur', 'Pudukkottai', 'Salem', 'Sivaganga',
120
+ 'Thanjavur', 'The Nilgiris', 'Theni', 'Thiruvallur', 'Thiruvarur',
121
+ 'Tiruchirappalli', 'Tirunelveli', 'Tiruppur', 'Tiruvannamalai',
122
+ 'Vellore', 'Virudhunagar', 'Adilabad', 'Kamareddy', 'Karimnagar',
123
+ 'Khammam', 'Mahabubabad', 'Mancherial', 'Medak', 'Nagarkurnool',
124
+ 'Nalgonda', 'Nirmal', 'Nizamabad', 'Peddapalli', 'Ranga Reddy',
125
+ 'Sangareddy', 'Siddipet', 'Suryapet', 'Vikarabad', 'Wanaparthy',
126
+ 'Agra', 'Aligarh', 'Ambedkar Nagar', 'Amethi', 'Amroha', 'Auraiya',
127
+ 'Azamgarh', 'Baghpat', 'Bahraich', 'Ballia', 'Banda', 'Barabanki',
128
+ 'Bareilly', 'Basti', 'Bhadohi', 'Bijnor', 'Budaun', 'Bulandshahr',
129
+ 'Chandauli', 'Chitrakoot', 'Deoria', 'Etah', 'Etawah',
130
+ 'Farrukhabad', 'Fatehpur', 'Firozabad', 'Gautam Buddha Nagar',
131
+ 'Ghaziabad', 'Ghazipur', 'Gonda', 'Gorakhpur', 'Hapur', 'Hardoi',
132
+ 'Hathras', 'Jalaun', 'Jaunpur', 'Jhansi', 'Kannauj',
133
+ 'Kanpur Dehat', 'Kanpur Nagar', 'Kasganj', 'Kaushambi', 'Kheri',
134
+ 'Kushi Nagar', 'Lalitpur', 'Lucknow', 'Mahoba', 'Mainpuri',
135
+ 'Mathura', 'Mau', 'Meerut', 'Mirzapur', 'Moradabad',
136
+ 'Muzaffarnagar', 'Pilibhit', 'Rae Bareli', 'Rampur', 'Saharanpur',
137
+ 'Sambhal', 'Shahjahanpur', 'Shamli', 'Siddharth Nagar', 'Sitapur',
138
+ 'Sonbhadra', 'Sultanpur', 'Unnao', 'Varanasi', 'Almora',
139
+ 'Bageshwar', 'Chamoli', 'Champawat', 'Dehradun', 'Nainital',
140
+ 'Pithoragarh', 'Rudra Prayag', 'Tehri Garhwal', 'Uttar Kashi',
141
+ 'Alipurduar', 'Bankura', 'Birbhum', 'Jalpaiguri', 'Jhargram',
142
+ 'Kalimpong', 'Maldah', 'Murshidabad', 'Nadia', 'Paschim Bardhaman',
143
+ 'Purba Bardhaman', 'Kokrajhar', 'Arvalli', 'Bharuch', 'Bhavnagar',
144
+ 'Gandhinagar', 'Kheda', 'Mahesana', 'Panch Mahals', 'Porbandar',
145
+ 'Surendranagar', 'Kinnaur', 'Karaikal', 'Ramanathapuram', 'Dhalai',
146
+ 'Gomati', 'Khowai', 'North Tripura', 'Sepahijala', 'Unakoti',
147
+ 'West Tripura', 'Dima Hasao', 'Ahmadabad', 'Niwari', 'Bishnupur',
148
+ 'Chandel', 'Churachandpur', 'Imphal East', 'Imphal West',
149
+ 'Senapati', 'Thoubal', 'East Khasi Hills', 'North Garo Hills',
150
+ 'Ri Bhoi', 'South West Garo Hills', 'West Garo Hills',
151
+ 'West Khasi Hills', 'Mulugu', 'Narayanpet', 'South Tripura',
152
+ 'West Jaintia Hills', 'Chengalpattu', 'Kallakurichi', 'Ranipet',
153
+ 'Tenkasi', 'Tirupathur', 'Anantnag', 'Biswanath', 'Hojai',
154
+ 'Kamrup Metro', 'Majuli', 'Marigaon', 'South Salmara Mancachar',
155
+ 'West Karbi Anglong', 'Ukhrul', 'Mayiladuthurai',
156
+ 'Alluri Sitharama Raju', 'Anakapalli', 'Annamayya', 'Bapatla',
157
+ 'Eluru', 'Kakinada', 'Nandyal', 'Ntr', 'Palnadu',
158
+ 'Parvathipuram Manyam', 'Spsr Nellore', 'Sri Sathya Sai',
159
+ 'Tirupati', 'Visakhapatanam', 'Bajali', 'Charaideo', 'Dantewada',
160
+ 'Gaurella Pendra Marwahi', 'Kabirdham', 'Kanker', 'Korea',
161
+ 'Gurugram', 'Nuh', 'Lahul And Spiti', 'East Nimar', 'Khargone',
162
+ 'Narsinghpur', 'Ahmednagar', 'Beed', 'Buldhana', 'Gondia',
163
+ 'Raigad', 'Tamenglong', 'South Garo Hills', 'Boudh', 'Deogarh',
164
+ 'Nabarangpur', 'Sonepur', 'Pondicherry', 'Chittorgarh', 'Dholpur',
165
+ 'Jalore', 'Gangtok', 'Gyalshing', 'Namchi', 'Ayodhya',
166
+ 'Maharajganj', 'Prayagraj', 'Shravasti', 'Haridwar',
167
+ 'Pauri Garhwal', 'Kanchipuram', 'Tuticorin', 'Villupuram')
168
+ district_name1 = st.selectbox('District Name',district_names,key=4)
169
+ with col2:
170
+ area_insured1 = st.number_input('Total Area Covered for Insurence', value=17.44,min_value=1.0,max_value=3777.0,step=1.0,key=5)
171
+ with col2:
172
+ farmer_share1 = st.number_input('Premium Paid by Individual', value=453.87,min_value=1.0,max_value=8600.32,step=10.0,key=6)
173
+ with col2:
174
+ goi_share1 = st.number_input('Premium Paid by GOI', value=285.46,min_value=1.0,max_value=33292.16,step=10.0,key=7)
175
+ with col2:
176
+ state_share1 = st.number_input('Premium Paid by Govt', value=285.46,min_value=1.0,max_value=40723.02,step=10.0,key=8)
177
+ with col1:
178
+ iu_count1 = st.number_input('Count of Insurence Units', value=85.0,min_value=1.0,max_value=2492.00,step=5.0,key=9)
179
+
180
+
181
+ prediction1 = ''
182
+ input_data = [season1,scheme1,state_name1,district_name1,area_insured1,farmer_share1,goi_share1,state_share1,iu_count1]
183
+ if st.button('Predict'):
184
+ encode = insu.encoding(input_data)
185
+ try:
186
+ prediction1 = sum_insurance_prediction(encode,crop_insurance_sum_Raghu)
187
+ progress = st.progress(0)
188
+ for i in range(100):
189
+ time.sleep(0.005)
190
+ progress.progress(i+1)
191
+ st.subheader(f"Sum Insured: {round(prediction1[0],3)} Rupees")
192
+ except:
193
+ st.error("Invalid Inputs")
194
+
195
+
196
+
197
+
198
+ with tab2:
199
+ st.title('Gross Premium')
200
+ # background_image = 'https://img.freepik.com/premium-photo/photo-coins-plant-black-background-with-empty-space-text-design-elements_176841-5042.jpg'
201
+ # html_code = f"""
202
+ # <style>
203
+ # body {{
204
+ # background-image: url('{background_image}');
205
+ # background-size: cover;
206
+ # background-position: center;
207
+ # background-repeat: no-repeat;
208
+ # height: 100vh; /* Set the height of the background to fill the viewport */
209
+ # margin: 0; /* Remove default body margin */
210
+ # display: flex;
211
+ # flex-direction: column;
212
+ # justify-content: center;
213
+ # align-items: center;
214
+ # }}
215
+ # .stApp {{
216
+ # background: none; /* Remove Streamlit app background */
217
+ # }}
218
+ # </style>
219
+ # """
220
+ # st.markdown(html_code, unsafe_allow_html=True)
221
+
222
+ # season,scheme,state_name,district_name,area_insured,sum_insured,farmer_share,goi_share,state_share,iu_count,gross_premium
223
+ # kharif,PMFBY,Andhra Pradesh,Anantapur,17.44,9493.41,453.87,285.46,285.46,85,1024.79
224
+ def loada():
225
+ return pickle.load(open('crop_grosspremimum_Jp.pkl','rb'))
226
+ crop_grosspremimum = loada()
227
+ # st.subheader('Enter Input Values')
228
+ col1,col2 = st.columns([1,1])
229
+ with col1:
230
+ season = st.selectbox('Season', ('kharif', 'rabi'))
231
+ with col1:
232
+ scheme = st.selectbox('Scheme', ('PMFBY', 'WBCIS'))
233
+ with col1:
234
+ state_name = st.selectbox('State Name',('Assam' ,'Chhattisgarh', 'Goa' ,'Haryana',
235
+ 'Himachal Pradesh', 'Karnataka', 'Kerala' ,'Madhya Pradesh' ,'Maharashtra',
236
+ 'Meghalaya', 'Odisha', 'Puducherry', 'Rajasthan', 'Sikkim', 'Tamil Nadu',
237
+ 'Tripura', 'Uttar Pradesh', 'Uttarakhand'))
238
+ with col1:
239
+ district_name = st.selectbox('District Name', district_names,key = 34)
240
+ with col2:
241
+ area_insured = st.number_input('Total Area Covered for Insurence', value=17.44,min_value=1.0,max_value=3777.0,step=1.0)
242
+ with col2:
243
+ farmer_share = st.number_input('Premium Paid by Individual', value=453.87,min_value=1.0,max_value=8600.32,step=10.0)
244
+ with col2:
245
+ goi_share = st.number_input('Premium Paid by GOI', value=285.46,min_value=1.0,max_value=33292.15,step=10.0)
246
+ with col2:
247
+ state_share = st.number_input('Premium Paid by Govt', value=285.46,min_value=1.0,max_value=40723.02,step=10.0)
248
+ with col1:
249
+ iu_count = st.number_input('Count of Insurence Units', value=85.0,min_value=1.0,max_value=2492.00,step=5.0)
250
+ with col2:
251
+ sum_insured = st.number_input('YOur Sum Insured For The Crop', value=9493.41,min_value=1.0,max_value=535572.47,step=50.0)
252
+
253
+ prediction = ''
254
+ input_data = [season,scheme,state_name,district_name,area_insured,sum_insured,farmer_share,goi_share,state_share,iu_count]
255
+ if st.button('Predict',key=10):
256
+ encode = gross.encoding(input_data)
257
+ try:
258
+ prediction = crop_grosspremimum_pred(encode,crop_grosspremimum)
259
+ progress = st.progress(0)
260
+ for i in range(100):
261
+ time.sleep(0.005)
262
+ progress.progress(i+1)
263
+ st.subheader(f"gross premium: {round(prediction[0],3)} Rupees ")
264
+ except:
265
+ st.error("Invalid Inputs")
266
+
267
+ with tab3:
268
+ df = pd.read_csv('insurance.csv')
269
+ st.write('Current Dataset',df)
270
+ col1,col2 = st.columns(2)
271
+ with col1:
272
+ season = st.selectbox('Season', ('kharif', 'rabi'),key = 101)
273
+ with col1:
274
+ scheme = st.selectbox('Scheme', ('PMFBY', 'WBCIS'),key = 102)
275
+ with col1:
276
+ state_name = st.selectbox('State Name',('Assam' ,'Chhattisgarh', 'Goa' ,'Haryana',
277
+ 'Himachal Pradesh', 'Karnataka', 'Kerala' ,'Madhya Pradesh' ,'Maharashtra',
278
+ 'Meghalaya', 'Odisha', 'Puducherry', 'Rajasthan', 'Sikkim', 'Tamil Nadu',
279
+ 'Tripura', 'Uttar Pradesh', 'Uttarakhand'),key = 103)
280
+ with col1:
281
+ district_name = st.selectbox('District Name', district_names,key =104)
282
+ with col2:
283
+ area_insured = st.number_input('Total Area Covered for Insurence', value=17.44,min_value=1.0,max_value=3777.0,step=1.0,key = 105)
284
+ with col2:
285
+ farmer_share = st.number_input('Premium Paid by Individual', value=453.87,min_value=1.0,max_value=8600.32,step=10.0,key = 106)
286
+ with col2:
287
+ goi_share = st.number_input('Premium Paid by GOI', value=285.46,min_value=1.0,max_value=33292.15,step=10.0,key = 1062)
288
+ with col2:
289
+ state_share = st.number_input('Premium Paid by Govt', value=285.46,min_value=1.0,max_value=40723.02,step=10.0,key = 107)
290
+ with col1:
291
+ iu_count = st.number_input('Count of Insurence Units', value=85.0,min_value=1.0,max_value=2492.00,step=5.0,key = 108)
292
+ with col2:
293
+ sum_insured = st.number_input('YOur Sum Insured For The Crop', value=9493.41,min_value=1.0,max_value=535572.47,step=50.0,key = 109)
294
+ with col1:
295
+ gross_premium = st.number_input('Enter the amount after policy mature', value=2255.6,min_value=0.0,max_value=80103.4,step=5.0,key = 110)
296
+
297
+ if st.button('submit',key = 10111):
298
+ new_row = {'season':season, 'scheme':scheme, 'state_name':state_name, 'district_name':district_name, 'area_insured':area_insured,
299
+ 'sum_insured':sum_insured, 'farmer_share':farmer_share, 'goi_share':goi_share, 'state_share':state_share, 'iu_count':iu_count,
300
+ 'gross_premium':gross_premium}
301
+ df = df.append(new_row,ignore_index= True)
302
+ df.to_csv('insurance.csv')
303
+ st.success("Thanks for the feedback")
304
+ st.write("Updated Dataset",df)
305
+
306
+ if __name__=='__main__':
307
+ insurance_app()
Crop_disease_prediction.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import matplotlib.pyplot as plt
3
+ import tensorflow as tf
4
+ from tensorflow.keras.models import load_model
5
+
6
+ # Load the saved model from Google Drive
7
+ @st.cache_resource
8
+ def loadu():
9
+ reso = load_model("model.h5")
10
+ return reso
11
+ loaded_model = loadu()
12
+ class_names = ['Apple___Apple_scab', 'Apple___Black_rot', 'Apple___Cedar_apple_rust', 'Apple___healthy',
13
+ 'Blueberry___healthy', 'Cherry_(including_sour)___Powdery_mildew',
14
+ 'Cherry_(including_sour)___healthy', 'Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot',
15
+ 'Corn_(maize)___Common_rust_', 'Corn_(maize)___Northern_Leaf_Blight', 'Corn_(maize)___healthy',
16
+ 'Grape___Black_rot', 'Grape___Esca_(Black_Measles)', 'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)',
17
+ 'Grape___healthy', 'Orange___Haunglongbing_(Citrus_greening)', 'Peach___Bacterial_spot',
18
+ 'Peach___healthy', 'Pepper,_bell___Bacterial_spot', 'Pepper,_bell___healthy', 'Potato___Early_blight',
19
+ 'Potato___Late_blight', 'Potato___healthy', 'Raspberry___healthy', 'Soybean___healthy',
20
+ 'Squash___Powdery_mildew', 'Strawberry___Leaf_scorch', 'Strawberry___healthy',
21
+ 'Tomato___Bacterial_spot', 'Tomato___Early_blight', 'Tomato___Late_blight', 'Tomato___Leaf_Mold',
22
+ 'Tomato___Septoria_leaf_spot', 'Tomato___Spider_mites Two-spotted_spider_mite', 'Tomato___Target_Spot',
23
+ 'Tomato___Tomato_Yellow_Leaf_Curl_Virus', 'Tomato___Tomato_mosaic_virus', 'Tomato___healthy']
24
+
25
+ crop_medicines = {
26
+ 'Apple___Apple_scab': ['Fungicides (e.g., sulfur or copper-based products)', 'Sanitation practices'],
27
+ 'Apple___Black_rot': ['Fungicides', 'Proper sanitation practices'],
28
+ 'Apple___Cedar_apple_rust': ['Fungicides', 'Removal of infected juniper plants'],
29
+ 'Apple___healthy': ['No specific treatment'],
30
+
31
+ 'Blueberry___healthy': ['Well-drained soil', 'Proper irrigation'],
32
+
33
+ 'Cherry_(including_sour)___Powdery_mildew': ['Fungicides', 'Pruning for air circulation', 'Proper sanitation'],
34
+ 'Cherry_(including_sour)___healthy': ['No specific treatment'],
35
+
36
+ 'Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot': ['Fungicides', 'Crop rotation'],
37
+ 'Corn_(maize)___Common_rust_': ['Fungicides', 'Resistant varieties'],
38
+ 'Corn_(maize)___Northern_Leaf_Blight': ['Fungicides', 'Crop rotation'],
39
+ 'Corn_(maize)___healthy': ['No specific treatment'],
40
+
41
+ 'Grape___Black_rot': ['Fungicides', 'Proper pruning'],
42
+ 'Grape___Esca_(Black_Measles)': ['Pruning', 'Cultural practices'],
43
+ 'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)': ['Fungicides', 'Proper canopy management'],
44
+ 'Grape___healthy': ['No specific treatment'],
45
+
46
+ 'Orange___Haunglongbing_(Citrus_greening)': ['Vector control', 'Removing infected trees'],
47
+
48
+ 'Peach___Bacterial_spot': ['Copper-based fungicides', 'Proper sanitation'],
49
+ 'Peach___healthy': ['No specific treatment'],
50
+
51
+ 'Pepper,_bell___Bacterial_spot': ['Copper-based fungicides', 'Resistant varieties'],
52
+ 'Pepper,_bell___healthy': ['No specific treatment'],
53
+
54
+ 'Potato___Early_blight': ['Fungicides', 'Crop rotation', 'Proper field hygiene'],
55
+ 'Potato___Late_blight': ['Fungicides', 'Resistant varieties', 'Proper plant spacing'],
56
+ 'Potato___healthy': ['No specific treatment'],
57
+
58
+ 'Raspberry___healthy': ['Well-drained soil', 'Proper pruning'],
59
+
60
+ 'Soybean___healthy': ['Proper crop rotation'],
61
+
62
+ 'Squash___Powdery_mildew': ['Fungicides', 'Proper spacing for air circulation'],
63
+
64
+ 'Strawberry___Leaf_scorch': ['Fungicides', 'Proper irrigation'],
65
+ 'Strawberry___healthy': ['No specific treatment'],
66
+
67
+ 'Tomato___Bacterial_spot': ['Copper-based fungicides', 'Resistant varieties'],
68
+ 'Tomato___Early_blight': ['Fungicides', 'Resistant varieties', 'Proper plant spacing'],
69
+ 'Tomato___Late_blight': ['Fungicides', 'Resistant varieties', 'Proper plant spacing'],
70
+ 'Tomato___Leaf_Mold': ['Fungicides', 'Proper ventilation'],
71
+ 'Tomato___Septoria_leaf_spot': ['Fungicides', 'Proper plant spacing'],
72
+ 'Tomato___Spider_mites Two-spotted_spider_mite': ['Miticides', 'Biological control'],
73
+ 'Tomato___Target_Spot': ['Fungicides', 'Proper plant hygiene'],
74
+ 'Tomato___Tomato_Yellow_Leaf_Curl_Virus': ['Vector control', 'Resistant varieties'],
75
+ 'Tomato___Tomato_mosaic_virus': ['Resistant varieties', 'Vector control'],
76
+ 'Tomato___healthy': ['No specific treatment']
77
+ }
78
+
79
+
80
+ IMAGE_SIZE = (224, 224)
81
+
82
+ def load_and_preprocess_image(image_path):
83
+ try:
84
+ img = tf.io.read_file(image_path)
85
+ img = tf.image.decode_image(img)
86
+ img = tf.image.resize(img, size=IMAGE_SIZE)
87
+ return img
88
+ except Exception as e:
89
+ st.error(f"Error loading or preprocessing image: {e}")
90
+ return None
91
+
92
+ # def disease_predict(image_path):
93
+ # image = load_and_preprocess_image(image_path)
94
+
95
+ # if image is not None:
96
+ # try:
97
+ # pred = loaded_model.predict(tf.expand_dims(image, axis=0))
98
+ # predicted_value = class_names[pred.argmax()]
99
+ # display_prediction(predicted_value, image)
100
+ # except Exception as e:
101
+ # st.error(f"Error predicting disease: {e}")
102
+
103
+ def disease_predict(image_path):
104
+ image = load_and_preprocess_image(image_path)
105
+
106
+ if image is not None:
107
+ try:
108
+ pred = loaded_model.predict(tf.expand_dims(image, axis=0))
109
+ if max(pred[0]) >= 0.90:
110
+ predicted_value = class_names[pred.argmax()]
111
+ display_prediction(predicted_value, image)
112
+ else:
113
+ st.error("Invalid Image")
114
+ except Exception as e:
115
+ st.error(f"Error predicting disease: {e}")
116
+
117
+ def display_prediction(predicted_value, image):
118
+ st.image(image.numpy() / 255., caption=f"Predicted Disease: {predicted_value}", use_column_width=True)
119
+ st.success(f"Disease: **{predicted_value }**")
120
+ treatment(predicted_value)
121
+ # st.write(f"Image Shape: {image.shape}")
122
+
123
+ def treatment(predicted_value):
124
+ medicines = crop_medicines.get(predicted_value, [])
125
+ st.subheader("Solution for this Disease:")
126
+ st.write("Medicines:")
127
+ for medicine in medicines:
128
+ st.write(f"- {medicine}")
129
+
130
+ def disease_app():
131
+ st.title('Agricultural Disease Detector 🦠')
132
+ uploaded_file = st.file_uploader("Upload an Image for Disease Analysis", type="jpg")
133
+ if uploaded_file is None:
134
+ uploaded_file = st.camera_input("Capture a photo")
135
+ if uploaded_file is not None:
136
+ img_path = f"uploaded_image.jpg"
137
+ with open(img_path, "wb") as f:
138
+ f.write(uploaded_file.read())
139
+ disease_predict(img_path)
140
+
141
+ # if __name__ == "__main__":
142
+
Crop_recommendation.csv ADDED
The diff for this file is too large to render. See raw diff
 
Test Images/Apple_scab.JPG ADDED
Test Images/Grape_esca_black_measles.JPG ADDED
Test Images/Leaf_scorch.JPG ADDED
Test Images/Orange_Haunglongbing_citrus_greening.JPG ADDED
Test Images/Peach_bacterial_spot.JPG ADDED
Test Images/Pepper_bell_bacterial_spot.JPG ADDED
Test Images/Respberry_healthy.JPG ADDED
Test Images/Squash_Poedery_mildew.JPG ADDED
Test Images/Tomato_yellow_leaf_curl_virus.JPG ADDED
Test Images/apple_black_rot.JPG ADDED
Test Images/cedar_apple_rust.JPG ADDED
__pycache__/Agri_chatbot.cpython-310.pyc ADDED
Binary file (11.1 kB). View file
 
__pycache__/Agri_chatbot.cpython-311.pyc ADDED
Binary file (13.8 kB). View file
 
__pycache__/Crop_Insurance_Risk.cpython-310.pyc ADDED
Binary file (12.1 kB). View file
 
__pycache__/Crop_Insurance_Risk.cpython-311.pyc ADDED
Binary file (17.4 kB). View file
 
__pycache__/Crop_Recommendation.cpython-310.pyc ADDED
Binary file (13.3 kB). View file
 
__pycache__/Crop_Recommendation.cpython-311.pyc ADDED
Binary file (17.9 kB). View file
 
__pycache__/Crop_Recommendation.cpython-312.pyc ADDED
Binary file (4.68 kB). View file
 
__pycache__/Crop_disease_prediction.cpython-310.pyc ADDED
Binary file (4.83 kB). View file
 
__pycache__/Crop_disease_prediction.cpython-311.pyc ADDED
Binary file (7.3 kB). View file
 
__pycache__/Crop_disease_prediction.cpython-312.pyc ADDED
Binary file (6.28 kB). View file
 
__pycache__/Crop_yield.cpython-310.pyc ADDED
Binary file (11.5 kB). View file
 
__pycache__/Crop_yield.cpython-311.pyc ADDED
Binary file (17.3 kB). View file
 
__pycache__/Crop_yield.cpython-312.pyc ADDED
Binary file (7.3 kB). View file
 
__pycache__/Insurance_risk.cpython-310.pyc ADDED
Binary file (3.95 kB). View file
 
__pycache__/Insurance_risk.cpython-311.pyc ADDED
Binary file (8.26 kB). View file
 
__pycache__/Mail.cpython-310.pyc ADDED
Binary file (954 Bytes). View file
 
__pycache__/Mail.cpython-311.pyc ADDED
Binary file (1.55 kB). View file
 
__pycache__/Rain_Forecast.cpython-310.pyc ADDED
Binary file (856 Bytes). View file
 
__pycache__/Rain_Forecast.cpython-311.pyc ADDED
Binary file (1.28 kB). View file
 
__pycache__/Rain_Forecast.cpython-312.pyc ADDED
Binary file (952 Bytes). View file
 
__pycache__/Retrain_Crop_Recommendation.cpython-310.pyc ADDED
Binary file (1.56 kB). View file
 
__pycache__/Weather_app.cpython-310.pyc ADDED
Binary file (4.5 kB). View file
 
__pycache__/Weather_app.cpython-311.pyc ADDED
Binary file (8.28 kB). View file
 
__pycache__/Weather_app.cpython-312.pyc ADDED
Binary file (7.11 kB). View file
 
__pycache__/allmodelretrain.cpython-310.pyc ADDED
Binary file (1.76 kB). View file
 
__pycache__/auth_module.cpython-310.pyc ADDED
Binary file (1.29 kB). View file
 
__pycache__/auth_module.cpython-311.pyc ADDED
Binary file (2.31 kB). View file
 
__pycache__/extra.cpython-311.pyc ADDED
Binary file (440 Bytes). View file
 
__pycache__/feedback.cpython-310.pyc ADDED
Binary file (771 Bytes). View file
 
__pycache__/feedbacko.cpython-310.pyc ADDED
Binary file (1.09 kB). View file
 
__pycache__/feedbacko.cpython-311.pyc ADDED
Binary file (1.59 kB). View file
 
__pycache__/gross_premimum.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
__pycache__/gross_premimum.cpython-311.pyc ADDED
Binary file (4.87 kB). View file
 
__pycache__/retrain_Crop_yield.cpython-310.pyc ADDED
Binary file (1.34 kB). View file