bhanusAI commited on
Commit
59ce7be
·
verified ·
1 Parent(s): 7bc8f9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -32,21 +32,26 @@ def analyse(img,plant_type):
32
  y_pred = dnn_model.predict(process_img)
33
  y_pred = y_pred[0]
34
  print("y pred",y_pred)
35
- indx = np.argmax(y_pred)
36
- max_prob_indx = plant_label_disease[plant_type.lower()][0]
 
 
37
  for disease in plant_label_disease[plant_type.lower()]:
38
- if y_pred[disease] > y_pred[max_prob_indx]:
39
- max_prob_indx = disease
40
- indx=str(indx)
41
- max_prob_indx=str(max_prob_indx)
42
- print(label_disease[indx])
43
- print(y_pred[0][indx])
44
- print(label_disease[max_prob_indx])
45
- print(y_pred[0][max_prob_indx])
46
- return int(indx),max_prob_indx,label_disease[indx],y_pred[0][indx],label_disease[max_prob_indx],y_pred[0][max_prob_indx]
 
 
 
47
 
48
  demo = gr.Interface(analyse,
49
  [gr.Image(),gr.Radio(["Apple","Blueberry","Cherry","Corn","Grape","Orange","Peach","Pepper","Potato","Raspberry","Soybean","Squash","Strawberry","Tomato"])],
50
- ["number","number","text","number","text","number"],
51
  )
52
  demo.launch(share=True,show_error=True)
 
32
  y_pred = dnn_model.predict(process_img)
33
  y_pred = y_pred[0]
34
  print("y pred",y_pred)
35
+
36
+ id = np.argmax(y_pred)
37
+ p_id = plant_label_disease[plant_type.lower()][0]
38
+
39
  for disease in plant_label_disease[plant_type.lower()]:
40
+ if y_pred[disease] > y_pred[p_id]:
41
+ p_id = disease
42
+
43
+ overall_predicted_id = id
44
+ overall_predicted_name = label_disease[str(overall_predicted_id)]
45
+ overall_predicted_acc = y_pred[overall_predicted_id]
46
+
47
+ plant_predicted_id =pid
48
+ plant_predicted_name = label_disease[str(plant_predicted_id)]
49
+ plant_predicted_acc = y_pred[plant_predicted_id]
50
+
51
+ return plant_predicted_id, plant_predicted_name, plant_predicted_acc, overall_predicted_id, overall_predicted_name, overall_predicted_acc
52
 
53
  demo = gr.Interface(analyse,
54
  [gr.Image(),gr.Radio(["Apple","Blueberry","Cherry","Corn","Grape","Orange","Peach","Pepper","Potato","Raspberry","Soybean","Squash","Strawberry","Tomato"])],
55
+ ["number","text","number","number","text","number"],
56
  )
57
  demo.launch(share=True,show_error=True)