-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
157 lines (135 loc) · 6.2 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import streamlit as st
import tensorflow as tf
import numpy as np
from streamlit_option_menu import option_menu
from streamlit_extras.mention import mention
st.set_page_config(
page_title="Plant-Disease-Detection",
page_icon= "🌿",
initial_sidebar_state = "auto"
)
# Tensorflow model prediction
def model_prediction(input_image):
trained_model = tf.keras.models.load_model("model.keras")
image = tf.keras.preprocessing.image.load_img(input_image,target_size=(228,228))
input_arr = tf.keras.preprocessing.image.img_to_array(image)
input_arr = np.array([input_arr]) # To convert single image to batch
predictions = trained_model.predict(input_arr)
result_index = np.argmax(predictions)
return result_index
st.markdown("""
<style>
[data-testid=stSidebar] {
background-color: #bff2ca;
}
</style>
""", unsafe_allow_html=True)
# sidebar
img_side = "Images/img2.png"
with st.sidebar:
with st.container():
l, m, r = st.columns((1,3,1))
with l:
st.empty()
with m:
st.image(img_side, width=175)
with r:
st.empty()
choose = option_menu(
"Dashboard",
["Home","About","Disease Recognition"],
icons=['book half', 'globe', 'tools'],
menu_icon="plant",
default_index=0,
styles={
"container": {"padding": "0!important", "background-color": "#bff2ca"},
"icon": {"color": "darkorange", "font-size": "20px"},
"nav-link": {"font-size": "17px", "text-align": "left", "margin":"5px", "--hover-color": "#65eb82"},
"nav-link-selected": {"background-color": "#65eb82"},
}
)
if choose == "Home":
st.header("PLANT DISEASE RECOGNITION SYSTEM")
image_path = ("Images/plant.jpeg")
st.image(image_path,use_column_width=True)
st.markdown("""
Welcome to the Plant Disease Recognition System! 🌿🔍
Our mission to help in identifying plant disease efficintly. Upload an image of plant, and our system will and our system will analyze it to detect any signs of diseases. Together, let's protect our crops and ensure a healthier harvest!
### How It Works
1. **Upload Image:** Got to the **Disease Recognition** page and upload an Image of a plant with suspected diseases.
2. **Analysis:** Our system will process the image using advances algorithms to identify potential diseases.
3. **Results:** View the results and recomendations for further action.
### Why Choose Us?
- **Accuracy:** Our system utilizes state-of-the-art machine learning techniques for accurate disease detection.
- **User-Friendly:** Simple and intuitive interface for seamless user experience.
- **Fats and Efficient:** Receive results in seconds, allowing for quick decision-making.
### Get Started
Click on **Disease Recognition** page in the sidebar to upload and image and experience the power of our Plant Recognition System!
### About us
Learn about the project, our team, and our goals on the **About** page.
""")
st.markdown("""
## Check out the Github repo here 👉
# """)
mention(label = "Github Repo",icon = "github", url = "https://github.com/aman977381/Plant-Disease-Recoginition.git")
elif choose == "About":
st.header("About")
st.markdown("""
### About dataset
This dataset is recreated using offline augmentation from the original dataset. The original dataset can be found on this github repo. This dataset consists of about 87K rgb images of healthy and diseased crop leaves which is categorized into 38 different classes. The total dataset is divided into 80/20 ratio of training and validation set preserving the directory structure. A new directory containing 33 test images is created later for prediction purpose.
### Content
1. Train (70295 Images)
2. Valid (17572 Images)
3. Test (33 Images)
""")
elif choose == "Disease Recognition":
st.header("Disease Recognition")
input_image = st.file_uploader("Choose an Image:",type=['jpg', 'png', 'jpeg'])
if not input_image:
input_image = "Images/test.jpg"
if st.button("show image"):
st.image(input_image, use_column_width=True)
# Predicting Image
if st.button("Predict"):
st.write("Our Prediction")
result_index = model_prediction(input_image)
class_name = ['Apple___Apple_scab',
'Apple___Black_rot',
'Apple___Cedar_apple_rust',
'Apple___healthy',
'Blueberry___healthy',
'Cherry_(including_sour)___Powdery_mildew',
'Cherry_(including_sour)___healthy',
'Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot',
'Corn_(maize)___Common_rust_',
'Corn_(maize)___Northern_Leaf_Blight',
'Corn_(maize)___healthy',
'Grape___Black_rot',
'Grape___Esca_(Black_Measles)',
'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)',
'Grape___healthy',
'Orange___Haunglongbing_(Citrus_greening)',
'Peach___Bacterial_spot',
'Peach___healthy',
'Pepper,_bell___Bacterial_spot',
'Pepper,_bell___healthy',
'Potato___Early_blight',
'Potato___Late_blight',
'Potato___healthy',
'Raspberry___healthy',
'Soybean___healthy',
'Squash___Powdery_mildew',
'Strawberry___Leaf_scorch',
'Strawberry___healthy',
'Tomato___Bacterial_spot',
'Tomato___Early_blight',
'Tomato___Late_blight',
'Tomato___Leaf_Mold',
'Tomato___Septoria_leaf_spot',
'Tomato___Spider_mites Two-spotted_spider_mite',
'Tomato___Target_Spot',
'Tomato___Tomato_Yellow_Leaf_Curl_Virus',
'Tomato___Tomato_mosaic_virus',
'Tomato___healthy']
model_predicted = class_name[result_index]
st.success("Model is Predicting it's a {}".format(model_predicted))