File size: 774 Bytes
dd61043
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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='pepper_fastai_gradio',
    project='plant_disease_detection',
    entity='jumashafara',
)

categories = ['bacterial_spot', 'healthy']

learner = load_learner(Path('pepper_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()