bhanusAI commited on
Commit
65d5227
·
verified ·
1 Parent(s): 30e23bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -62
app.py CHANGED
@@ -7,70 +7,22 @@ import cv2
7
  import tensorflow as tf
8
  import h5py
9
  def analyse(img,plant_type):
10
- label_disease = {
11
- 0 : 'Apple___Apple_scab',
12
- 1 : 'Apple___Black_rot',
13
- 2 : 'Apple___Cedar_apple_rust',
14
- 3 : 'Apple___healthy',
15
- 4 : 'Background_without_leaves',
16
- 5 : 'Blueberry___healthy',
17
- 6 : 'Cherry___Powdery_mildew',
18
- 7 : 'Cherry___healthy',
19
- 8 : 'Corn___Cercospora_leaf_spot_Gray_leaf_spot',
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
- dnn_model = keras.models.load_model('untrained_model.h5',compile=False)
71
- weights_path = 'keras_savedmodel_weights.h5'
72
- dnn_model.load_weights(weights_path)
73
- # dnn_model = tf.saved_model.load(model_path)
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)