Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
36 |
-
|
|
|
|
|
37 |
for disease in plant_label_disease[plant_type.lower()]:
|
38 |
-
if y_pred[disease] > y_pred[
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
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","
|
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)
|