File size: 772 Bytes
01eb14c
 
49c2c83
2e3c384
 
 
 
 
5fa5b31
dfdcb11
 
 
01eb14c
 
 
 
dfdcb11
ed463d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from transformers import pipeline

def predict_image(img):
  img_4d=img.reshape(-1,180,180,3)
  prediction=model.predict(img_4d)[0]
  return {class_names[i]: float(prediction[i]) for i in range(4)}

pipe = pipeline(task = 'image-classification', model = "google/vit-base-patch16-224")

image = gr.inputs.Image(shape=(180,180))
label = gr.outputs.Label(num_top_classes=4)

gr.Interface.from_pipeline(pipe,
                           title = "Maize Leaf Disease Detection",
                           description = "Corn Leaf disease classification",
                           fn=predict_image, inputs=image, outputs=label,interpretation='default',
                           allow_flagging = "never").launch(inbrowser=True, debug='True', share='True')