Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- .gitattributes +1 -0
- main.py +55 -0
- trained_plant_disease_model.keras +3 -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 |
+
trained_plant_disease_model.keras filter=lfs diff=lfs merge=lfs -text
|
main.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
def model_prediction(test_image):
|
5 |
+
model = tf.keras.models.load_model("trained_plant_disease_model.keras")
|
6 |
+
image = tf.keras.preprocessing.image.load_img(test_image,target_size=(128,128))
|
7 |
+
input_arr = tf.keras.preprocessing.image.img_to_array(image)
|
8 |
+
input_arr = np.array([input_arr]) #convert single image to batch
|
9 |
+
predictions = model.predict(input_arr)
|
10 |
+
return np.argmax(predictions) #return index of max element
|
11 |
+
|
12 |
+
#Sidebar
|
13 |
+
st.sidebar.title("AgriSens")
|
14 |
+
app_mode = st.sidebar.selectbox("Select Page",["HOME","DISEASE RECOGNITION"])
|
15 |
+
#app_mode = st.sidebar.selectbox("Select Page",["Home","About","Disease Recognition"])
|
16 |
+
|
17 |
+
# import Image from pillow to open images
|
18 |
+
from PIL import Image
|
19 |
+
img = Image.open("Diseases.png")
|
20 |
+
|
21 |
+
# display image using streamlit
|
22 |
+
# width is used to set the width of an image
|
23 |
+
st.image(img)
|
24 |
+
|
25 |
+
#Main Page
|
26 |
+
if(app_mode=="HOME"):
|
27 |
+
st.markdown("<h1 style='text-align: center;'>SMART DISEASE DETECTION", unsafe_allow_html=True)
|
28 |
+
|
29 |
+
#Prediction Page
|
30 |
+
elif(app_mode=="DISEASE RECOGNITION"):
|
31 |
+
st.header("DISEASE RECOGNITION")
|
32 |
+
test_image = st.file_uploader("Choose an Image:")
|
33 |
+
if(st.button("Show Image")):
|
34 |
+
st.image(test_image,width=4,use_column_width=True)
|
35 |
+
#Predict button
|
36 |
+
if(st.button("Predict")):
|
37 |
+
st.snow()
|
38 |
+
st.write("Our Prediction")
|
39 |
+
result_index = model_prediction(test_image)
|
40 |
+
#Reading Labels
|
41 |
+
class_name = ['Apple___Apple_scab', 'Apple___Black_rot', 'Apple___Cedar_apple_rust', 'Apple___healthy',
|
42 |
+
'Blueberry___healthy', 'Cherry_(including_sour)___Powdery_mildew',
|
43 |
+
'Cherry_(including_sour)___healthy', 'Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot',
|
44 |
+
'Corn_(maize)___Common_rust_', 'Corn_(maize)___Northern_Leaf_Blight', 'Corn_(maize)___healthy',
|
45 |
+
'Grape___Black_rot', 'Grape___Esca_(Black_Measles)', 'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)',
|
46 |
+
'Grape___healthy', 'Orange___Haunglongbing_(Citrus_greening)', 'Peach___Bacterial_spot',
|
47 |
+
'Peach___healthy', 'Pepper,_bell___Bacterial_spot', 'Pepper,_bell___healthy',
|
48 |
+
'Potato___Early_blight', 'Potato___Late_blight', 'Potato___healthy',
|
49 |
+
'Raspberry___healthy', 'Soybean___healthy', 'Squash___Powdery_mildew',
|
50 |
+
'Strawberry___Leaf_scorch', 'Strawberry___healthy', 'Tomato___Bacterial_spot',
|
51 |
+
'Tomato___Early_blight', 'Tomato___Late_blight', 'Tomato___Leaf_Mold',
|
52 |
+
'Tomato___Septoria_leaf_spot', 'Tomato___Spider_mites Two-spotted_spider_mite',
|
53 |
+
'Tomato___Target_Spot', 'Tomato___Tomato_Yellow_Leaf_Curl_Virus', 'Tomato___Tomato_mosaic_virus',
|
54 |
+
'Tomato___healthy']
|
55 |
+
st.success("Model is Predicting it's a {}".format(class_name[result_index]))
|
trained_plant_disease_model.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b2958851ea32bd3e01e131f1042a2eb7e64bd719b7fc4470dbdbd1e513386201
|
3 |
+
size 94195019
|