File size: 841 Bytes
a86dc43
 
 
b70ea9a
a86dc43
eae93cf
a86dc43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import tensorflow as tf
import gradio as gr
import cv2
import os

used_model = tf.keras.layers.TFSMLayer('/model', call_endpoint='serving_default')
new_classes = ['blight', 'common_rust', 'gray_leaf_spot','healthy']

def classify_image(img_dt):
  img_dt = cv2.resize(img_dt,(256,256))
  img_dt = img_dt.reshape((-1,256,256,3)) 
  prediction = used_model.predict(img_dt).flatten()
  confidences = {new_classes[i]: float(prediction[i]) for i in range (4) }
  return confidences


with gr.Blocks() as demo:
    with gr.Row():
        signal = gr.Markdown(''' #Welcome to Maize Classifier, This model can identify if a leaf is 
        **HEALTHY**, has **COMMON RUST**, **BLIGHT** or **GRAY LEAF SPOT**''')
        inp = gr.image()
        out = gr.Label()
        inp.upload(fn= classify_image, inputs = inp, outputs = out, show_progrss = True)