Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,70 +7,22 @@ import cv2
|
|
7 |
import tensorflow as tf
|
8 |
import h5py
|
9 |
def analyse(img,plant_type):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
9 : 'Corn___Common_rust',
|
21 |
-
10: 'Corn___Northern_Leaf_Blight',
|
22 |
-
11: 'Corn___healthy',
|
23 |
-
12: 'Grape___Black_rot',
|
24 |
-
13: 'Grape___Esca_(Black_Measles)',
|
25 |
-
14: 'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)',
|
26 |
-
15: 'Grape___healthy',
|
27 |
-
16: 'Orange___Haunglongbing_Citrus_greening',
|
28 |
-
17: 'Peach___Bacterial_spot',
|
29 |
-
18: 'Peach___healthy',
|
30 |
-
19: 'Pepper_bell___Bacterial_spot',
|
31 |
-
20: 'Pepper_bell___healthy',
|
32 |
-
21: 'Potato___Early_blight',
|
33 |
-
22: 'Potato___Late_blight',
|
34 |
-
23: 'Potato___healthy',
|
35 |
-
24: 'Raspberry___healthy',
|
36 |
-
25: 'Soybean___healthy',
|
37 |
-
26: 'Squash___Powdery_mildew',
|
38 |
-
27: 'Strawberry___Leaf_scorch',
|
39 |
-
28: 'Strawberry___healthy',
|
40 |
-
29: 'Tomato___Bacterial_spot',
|
41 |
-
30: 'Tomato___Early_blight',
|
42 |
-
31: 'Tomato___Late_blight',
|
43 |
-
32: 'Tomato___Leaf_Mold',
|
44 |
-
33: 'Tomato___Septoria_leaf_spot',
|
45 |
-
34: 'Tomato___Spider_mites_Two-,spotted_spider_mite',
|
46 |
-
35: 'Tomato___Target_Spot',
|
47 |
-
36: 'Tomato___Tomato_Yellow_Leaf_Curl_Virus',
|
48 |
-
37: 'Tomato___Tomato_mosaic_virus',
|
49 |
-
38: 'Tomato___healthy',
|
50 |
-
}
|
51 |
-
plant_label_disease={
|
52 |
-
"apple":[0,1,2,3],
|
53 |
-
"background_without_leaves":[4],
|
54 |
-
"blueberry" : [5],
|
55 |
-
"cherry" : [6,7],
|
56 |
-
"corn" : [8,9,10,11],
|
57 |
-
"grape" : [12,13,14,15],
|
58 |
-
"orange" : [16] ,
|
59 |
-
"peach" : [17,18],
|
60 |
-
"pepper" : [19,20],
|
61 |
-
"potato" : [21,22,23],
|
62 |
-
"raspberry" : [24],
|
63 |
-
"soybean" : [25],
|
64 |
-
"squash" : [26],
|
65 |
-
"strawberry" : [27,28],
|
66 |
-
"tomato" : [29,30,31,32,33,34,35,36,37,38]
|
67 |
-
}
|
68 |
HEIGHT = 256
|
69 |
WIDTH = 256
|
70 |
-
|
71 |
-
|
72 |
-
dnn_model.
|
73 |
-
|
74 |
|
75 |
process_img = cv2.resize(img, (HEIGHT, WIDTH),interpolation = cv2.INTER_LINEAR)
|
76 |
process_img = process_img/(255)
|
|
|
7 |
import tensorflow as tf
|
8 |
import h5py
|
9 |
def analyse(img,plant_type):
|
10 |
+
import json
|
11 |
+
|
12 |
+
# Load label_disease.json
|
13 |
+
with open('data/label_disease.json', 'r') as f:
|
14 |
+
label_disease = json.load(f)
|
15 |
+
|
16 |
+
# Load plant_label_disease.json
|
17 |
+
with open('data/plant_label_disease.json', 'r') as f:
|
18 |
+
plant_label_disease = json.load(f)
|
19 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
HEIGHT = 256
|
21 |
WIDTH = 256
|
22 |
+
modelArchitecturePath ='model/model_architecture.h5'
|
23 |
+
modelWeightsPath = 'model/model_weights.h5'
|
24 |
+
dnn_model = keras.models.load_model(modelArchitecturePath,compile=False)
|
25 |
+
dnn_model.load_weights(modelWeightsPath)
|
26 |
|
27 |
process_img = cv2.resize(img, (HEIGHT, WIDTH),interpolation = cv2.INTER_LINEAR)
|
28 |
process_img = process_img/(255)
|