kartikeyjadli commited on
Commit
ad38d23
1 Parent(s): e4f5158

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import app as st
3
+ from keras.models import load_model
4
+ import numpy as np
5
+
6
+ model=load_model("crop_prediction_model.h5",compile=True)
7
+
8
+ 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"]
9
+
10
+ def classify_image(img):
11
+ img = img.reshape((-1, 256, 256, 3))
12
+ type=predict_crop(img)
13
+ return type
14
+
15
+ def predict_crop(img):
16
+ crop_class=model.predict(img)
17
+ index=np.argmax(crop_class)
18
+ label=labels[index]
19
+ return label
20
+
21
+ img = st.camera_input("Take a picture")
22
+
23
+ if img:
24
+ class_of_plant=classify_image(img)
25
+ st.write(class_of_plant)
26
+ else :
27
+ st.write("Image is not clear.")