File size: 849 Bytes
74c59ff
cb039f6
74c59ff
 
9880bdc
cb039f6
e288522
6ebbab1
 
74c59ff
 
 
 
 
 
e42b554
f0ac2cb
 
74c59ff
 
 
 
 
 
 
 
f0ac2cb
 
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
import tf_keras as keras
import gradio as gr
import cv2
import os



print(os.listdir('./model'))
used_model = keras.models.load_model('./model')
new_classes = ['Potato___Early_blight', 'Potato___Late_blight', 'Potato___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 (3) }
  return confidences


with gr.Blocks() as demo:
    signal = gr.Markdown(''' Welcome to Maize Classifier,This model can identify if a leaf is 
        **HEALTHY**, has **'Potato___Early_blight'** or **Potato_late___blight**''')
    with gr.Row():
        inp = gr.Image()
        out = gr.Label()
        inp.upload(fn= classify_image, inputs = inp, outputs = out)

demo.launch()