-
Notifications
You must be signed in to change notification settings - Fork 7
/
final+plant+disease+output.py
executable file
·98 lines (44 loc) · 2 KB
/
final+plant+disease+output.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# coding: utf-8
# In[1]:
import numpy as np
import keras
import cv2
import matplotlib.pyplot as plt
get_ipython().magic(u'matplotlib inline')
# In[2]:
from keras.models import load_model
# In[3]:
model = load_model('plant_disease_final.h5')
# In[4]:
model.summary()
# In[5]:
from keras import models
from keras import layers
from keras import optimizers
# In[6]:
model.compile(loss='categorical_crossentropy',
optimizer=optimizers.RMSprop(lr=1e-4),
metrics=['acc'])
# In[22]:
img3 = cv2.imread('/home/shashank/Desktop/plant_disease_final_working/pot_EB.JPG')
img3 = cv2.cvtColor(img3, cv2.COLOR_BGR2RGB)
img3 = cv2.resize(img3,(224,224))
img4 = np.reshape(img3,[1,224,224,3])
# {'Tomato Early Blight': 7, 'Corn Gray Leaf Spot': 3, 'Tomato LeafMold': 9, 'grape black rot': 16, 'TomatoBacterial Spot ': 12, 'Tomato Late Blight': 8, 'Potato Healthy': 6, ' Potato Late Blight ': 1, 'grape leaf blight': 18, 'TomatoTwo Spotted Spider Mite': 13, ' Corn Northern Leaf Blight': 0, 'Tomato Yellow Leaf Curl': 11, 'Corn CommonRust': 2, 'Potato Early Blight': 5, 'Corn healthy': 4, 'grape healthy': 17, 'Tomatohealthy': 14, 'Tomato Target Spot': 10, 'grape black measles': 15}
# In[23]:
plt.imshow(img3)
plt.show()
# In[24]:
disease = model.predict_classes(img4)
prediction = disease[0]
print prediction
# In[25]:
reverse_mapping = [' Corn Northern Leaf Blight','Potato Late Blight','Corn Common Rust','Corn Gray Leaf Spot', 'Corn healthy','Potato Early Blight','Potato Healthy','Tomato Early Blight','Tomato Late Blight','Tomato Leaf Mold','Tomato Target Spot','Tomato Yellow Leaf Curl','Tomato Bacterial Spot','Tomato Two Spotted Spider Mite','Tomato healthy','grape black measles','grape black rot','grape healthy', 'grape leaf blight' ]
# In[26]:
prediction_name = reverse_mapping[prediction]
prediction_name
# In[53]:
# result = firebase.get('/user' , None) #none = one
# print result
# result_put = firebase.put('user' , {"third" : {'bye': 'ok'}})
# print result_put