Spaces:
Runtime error
Runtime error
File size: 1,324 Bytes
a8ce70c f8beffd a8ce70c 4bfda83 1dac230 07aaf7e c6d8ba0 37b2653 a8ce70c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
## 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) |