Spaces:
Build error
Build error
| import cv2 | |
| from keras.models import load_model,Model | |
| model = load_model('Model1') | |
| import numpy as np | |
| import gradio as gr | |
| class_to_label = { | |
| 0: 'Apple Scab', | |
| 1: 'Apple_Black Rot', | |
| 2: 'Bacterial Spot_Pepper', | |
| 3: 'Bacterial Spot_peach', | |
| 4: 'Bacterial Spot_tmt', | |
| 5: 'Black Rot_grape', | |
| 6: 'Cedar Apple Rust', | |
| 7: 'Cercospora Leaf Spot_corn', | |
| 8: 'Common Rust_corn', | |
| 9: 'Early Blight_potato', | |
| 10: 'Early Blight_tmt', | |
| 11: 'Esca (Black Measles)_grape', | |
| 12: 'Healthy_Apple', | |
| 13: 'Healthy_Pepper', | |
| 14: 'Healthy_cherry', | |
| 15: 'Healthy_corn', | |
| 16: 'Healthy_grape', | |
| 17: 'Healthy_peach', | |
| 18: 'Healthy_potato', | |
| 19: 'Healthy_strb', | |
| 20: 'Healthy_tmt', | |
| 21: 'Late Blight_potato', | |
| 22: 'Late Blight_tmt', | |
| 23: 'Leaf Blight_grape', | |
| 24: 'Leaf Scorch_strb', | |
| 25: 'Northern Leaf Blight_corn', | |
| 26: 'Powdery Mildew_cherry', | |
| 27: 'Septoria Leaf Spot_tmt', | |
| 28: 'Yellow Leaf Curl Virus_tmt' | |
| } | |
| def process1(img): | |
| img1 = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| img2 = cv2.resize(img1, (256,256)) | |
| img_tensor = np.expand_dims(img2, axis=0) | |
| fast_pred = model(img_tensor, training=False) | |
| k = np.argmax(fast_pred) | |
| s=class_to_label[k] | |
| return s | |
| demo = gr.Interface( | |
| fn=process1, | |
| inputs=[gr.Image()], | |
| outputs=['number'], | |
| ) | |
| demo.launch() | |