-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.py
52 lines (38 loc) · 1.59 KB
/
Example.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
import cv2
from matplotlib import pyplot as plt
import os
import numpy as np
from tensorflow.keras.preprocessing.image import load_img
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
filepath = 'C:/Users/vishw/Downloads/Plant-Leaf-Disease-Prediction-main/Plant-Leaf-Disease-Prediction-main/model.h5'
model = load_model(filepath)
print(model)
print("Model Loaded Successfully")
tomato_plant = cv2.imread('C:/Users/vishw/Downloads/Plant-Leaf-Disease-Prediction-main/Plant-Leaf-Disease-Prediction-main/Dataset/test/Tomato___Late_blight (1).JPG')
test_image = cv2.resize(tomato_plant, (128,128)) # load image
test_image = img_to_array(test_image)/255 # convert image to np array and normalize
test_image = np.expand_dims(test_image, axis = 0) # change dimention 3D to 4D
result = model.predict(test_image) # predict diseased palnt or not
pred = np.argmax(result, axis=1)
print(pred)
if pred==0:
print( "Tomato - Bacteria Spot Disease")
elif pred==1:
print("Tomato - Early Blight Disease")
elif pred==2:
print("Tomato - Healthy and Fresh")
elif pred==3:
print("Tomato - Late Blight Disease")
elif pred==4:
print("Tomato - Leaf Mold Disease")
elif pred==5:
print("Tomato - Septoria Leaf Spot Disease")
elif pred==6:
print("Tomato - Target Spot Disease")
elif pred==7:
print("Tomato - Tomoato Yellow Leaf Curl Virus Disease")
elif pred==8:
print("Tomato - Tomato Mosaic Virus Disease")
elif pred==9:
print("Tomato - Two Spotted Spider Mite Disease")