Upload 4 files
Browse files- app.py +43 -0
- grapevine_disease.jpeg +0 -0
- model_grapevine_disease_detection.h5 +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from tensorflow.keras.models import load_model
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
model = load_model("model_grapevine_disease_detection.h5")
|
7 |
+
|
8 |
+
def process_image(img):
|
9 |
+
img = img.convert("RGB")
|
10 |
+
img = img.resize((50,50))
|
11 |
+
img = np.array(img)
|
12 |
+
if img.ndim == 2:
|
13 |
+
img = np.stack((img,)*3, axis=-1)
|
14 |
+
img = img/255.0
|
15 |
+
img = np.expand_dims(img, axis=0)
|
16 |
+
return img
|
17 |
+
|
18 |
+
st.title("GRAPEVINE DISEASE CLASSIFICATION")
|
19 |
+
st.divider()
|
20 |
+
|
21 |
+
col1, col2, col3 = st.columns([1,2,1])
|
22 |
+
with col2:
|
23 |
+
st.image("grapevine_disease.jpeg")
|
24 |
+
st.divider()
|
25 |
+
|
26 |
+
st.success("Upload your grapevine image and classify the images with the following labels: Black Rot, ESCA, Healthy, and Leaf Blight with CNN deep learning.")
|
27 |
+
st.divider()
|
28 |
+
|
29 |
+
st.write("Upload your image and see the results")
|
30 |
+
st.divider()
|
31 |
+
|
32 |
+
file = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png", "webp"])
|
33 |
+
|
34 |
+
if file is not None:
|
35 |
+
img = Image.open(file)
|
36 |
+
st.image(img, caption="Downloaded image")
|
37 |
+
image = process_image(img)
|
38 |
+
prediction = model.predict(image)
|
39 |
+
predicted_class = np.argmax(prediction)
|
40 |
+
|
41 |
+
class_names = {0:"Black Rot", 1:"ESCA", 2:"Healthy", 3:"Leaf Blight"}
|
42 |
+
|
43 |
+
st.write(f"Predicted Grapevine Disease: {class_names[predicted_class]}")
|
grapevine_disease.jpeg
ADDED
![]() |
model_grapevine_disease_detection.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:73e6bed46d2e30c75f1e87fa5b712d34547ad8f8860d56ecd05068ff94806988
|
3 |
+
size 64980992
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
scikit-learn
|