Spaces:
Runtime error
Runtime error
## libraries for data preprocessing | |
import numpy as np | |
import pandas as pd | |
## libraries for training dl models | |
import tensorflow as tf | |
from tensorflow import keras | |
## libraries for pre-trained neural network | |
from tensorflow.keras.applications.xception import preprocess_input | |
## libraries for loading batch images | |
from tensorflow.keras.preprocessing.image import load_img | |
import gradio as gr | |
## lets load the model | |
model = keras.models.load_model('xception_v1_17_0.859.h5') | |
def maize_disease_classifier(image): | |
x = np.array(image) | |
X = np.array([x]) | |
X = preprocess_input(X) | |
pred = model.predict(X) | |
result = pred[0].argmax() | |
## lets create our labels | |
labels = { | |
0: 'maize ear rot', | |
1: 'maize fall armyworm', | |
2: 'maize stem borer' | |
} | |
label = labels[pred[0].argmax()] | |
return label | |
################### Gradio Web APP ################################ | |
title = "Maize Disease Classification App" | |
Input = gr.Image(shape=(299, 299), label="Please Upload An Image") | |
Output1 = gr.Textbox(label="Type Of Maize Disease") | |
description = "Type Of Diseases: Maize Ear Rot, Maize Fall ArmyWorm, Maize Stem Borer" | |
iface = gr.Interface(fn=maize_disease_classifier, inputs=Input, outputs=Output1, title=title, description=description) | |
iface.launch(inline=False) |