File size: 805 Bytes
e4646c3
471a3ec
e4646c3
 
471a3ec
e4646c3
ed8c9ff
2bac3b5
 
 
 
 
ed8c9ff
e4646c3
 
07cc0ea
e4646c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import timm
import wandb
import gradio as gr
from pathlib import Path
from fastai.vision.all import load_learner

wandb.login(key='4d2ff70f59f0bfc0397e9fea4300819244bf3fce')
wandb.init(
    name='corn_fastai_gradio',
    project='plant_disease_detection',
    entity='jumashafara',
)

categories = ['cercospora', 'common_rust', 'healthy', 'northern_leaf_blight']

learner = load_learner(Path('corn_fastai_model.pkl'))

def classify(img):
    category, index, probs = learner.predict(img)
    return (dict(zip(categories, map(float, probs))))

image = gr.inputs.Image(shape=(224))
label = gr.outputs.Label()
example = []

interface = gr.Interface(fn=classify, 
                         inputs='image', 
                         outputs='label',
                         example=example)

interface.launch()