Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import app as st
|
2 |
+
from keras.models import load_model
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
model=load_model("crop_prediction_model.h5",compile=True)
|
6 |
+
|
7 |
+
labels=["Tomato Bacterial Spot","Early Blight","Healthy","Late Blight","Leaf Mold","Tomato Septoria leaf spot", "Tomato___Spider_mites Two spotted spider mite","Tomato___Target_Spot","Tomato___Tomato_mosaic_virus", "Tomato___Tomato_Yellow_Leaf_Curl_Virus"]
|
8 |
+
|
9 |
+
def classify_image(img):
|
10 |
+
img = img.reshape((-1, 256, 256, 3))
|
11 |
+
type=predict_crop(img)
|
12 |
+
return type
|
13 |
+
|
14 |
+
def predict_crop(img):
|
15 |
+
crop_class=model.predict(img)
|
16 |
+
index=np.argmax(crop_class)
|
17 |
+
label=labels[index]
|
18 |
+
return label
|
19 |
+
|
20 |
+
img = st.camera_input("Take a picture")
|
21 |
+
|
22 |
+
if img:
|
23 |
+
class_of_plant=classify_image(img)
|
24 |
+
st.write(class_of_plant)
|
25 |
+
else :
|
26 |
+
st.write("Image is not clear.")
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
|